How to package headers and shared libs

65 views
Skip to first unread message

p0r1

unread,
Jan 2, 2023, 10:46:47 AM1/2/23
to Anaconda - Public
I have a simple C++/python project that builds some C++ shared libraries (via make) and some python extensions (via setuptools).  

I've been battling with conda for weeks, but I can't find a way to create a recipe or a python setup.py for a package that will install my pure C++ headers, shared libs and binaries into the root include, lib, and bin folders in a conda environment.  All the examples I've found online seem to just be wrappers around pip, is there not a way to package these with conda/setuptools?

I've tried using the package_data and data_files arguments using setuptools in my setup.py, but it installs my C++ files under the python3.11/site-packages subfolder, rather than in the correct include, lib, and bin folders in the root of the environment.  I've also tried using MANIFEST.in but this seems to be ignored by my conda build.sh script which calls  'python setup.py install'

Are there any example conda recipes that package C++ libs/headers/bins online?

Thanks

Antonio Cavallo

unread,
Jan 2, 2023, 6:40:09 PM1/2/23
to anac...@anaconda.com
You can always add a copy command for the headers in the recipe (build.sh & bld.bat) is the install step.
Is the code on a public repo?

On Jan 2, 2023, at 10:46, p0r1 <pa...@scruby.com> wrote:


--
Community Discussion Forum for Anaconda
---
You received this message because you are subscribed to the Google Groups "Anaconda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anaconda+u...@anaconda.com.
To view this discussion on the web visit https://groups.google.com/a/anaconda.com/d/msgid/anaconda/a8e01ec3-b4ad-48b9-a86c-941450bb894dn%40anaconda.com.

p0r1

unread,
Jan 4, 2023, 6:48:50 AM1/4/23
to Anaconda - Public, antonio.c...@gmail.com
Thanks Antonio, as you suggested I ended up manually copying the headers, shared libs and binaries into the conda env.  The cleanest way that I found to do this was to extend the setup tools 'install' command class, like this:

Getting conda to work with setuptools was challenging, especially because it added environment variables which appended additional rpaths to setuptool's extensions that broke the linking to local libraries in the repository from python extensions.  Anyway after a week of pain, I have managed to get something working well.  Here is a public 'skeleton' repository that demonstrates conda/setuptools working with hybrid C++/python projects in case anyone else finds it useful in the future.
Reply all
Reply to author
Forward
0 new messages