Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including external binaries in python package

I have a python module that is basically a big wrapper (which does lots more stuff besides) for an external binary (non python). I would like to include the binaries (1 binary for osx, 1 for linux) along with my code. I currently have the following in my setup.py:

package_data={'packagename': ['lib/app-osx/*', 'lib/app-linux/*', 'lib/*.awk']},

and the files are located at:

/packagename
 /lib
  script.awk
  /app-osx/
    app
  /app-linux
    app

I can't seem to find where they are installed, if they are at all? Is there a convention for this? I obviously can't use dependencies for this :(

And then, what's the best way of finding their location within the python script?

Thanks

like image 916
GarethPrice Avatar asked Jul 08 '14 22:07

GarethPrice


People also ask

How do you include data in a Python package?

Place the files that you want to include in the package directory (in our case, the data has to reside in the roman/ directory). Add the field include_package_data=True in setup.py. Add the field package_data={'': [... patterns for files you want to include, relative to package dir...]} in setup.py .

What are binary packages in Python?

A binary Python package is usually a packaged Python library that comes with one or more pre-compiled binary modules. Theses modules are usually . so or . dll libraries in binary (compiled) form.

Is setuptools included in Python?

Even in a vanilla version of Python 3.7. 6 (installed via pyenv ), the packages installed by default are both pip and setuptools .

How do I include non Python files in a package?

In order to include your non-Python files into said package, you'll need to supply include_package_data=True to the setup() function.


1 Answers

With Jonathon's prompting, I went through the chat and found the solution that Lukas provided me. The solution was simply to add the following to the setup.py:

zip_safe=False
like image 96
GarethPrice Avatar answered Oct 10 '22 18:10

GarethPrice