1

I'm following the python documentation about "distributing packages using setuptools". It doesn't mention what to do if a python package you want to include in your install_requires requires a system installation. For example:

I'd like to include the package pysoundfile, but this requires me to install libsndfile1 via my system package manager, e.g. sudo apt-get install libsndfile1.

I've got as far as understanding I need to make a binary distribution, given advice in the docs here, but that sends me to the docs listed above.

How do I automate this process such that users of my package can simply pip install my_package and not have to apt-get install libsndfile1?

EDIT: My question is not linux specific so apt dependies for pypi package does not solve my question. To clarify: my users will be cross-platform, and I want everyone to be able to pip install my_package regardless of their platform. Is this possible?

EDIT 2: Ah, hmm, sorry I missed this bit from the answer:

If you want to distribute Python package from PyPI there is no way for the package to declare system dependencies. The only way to handle this is to document dependencies and let the user handle them.

So, I guess if that is true, that is my answer... i.e. it is not possible to make a pypi package that any user can simply pip install if it requires non-python packages.

Full disclosure: this question exists on the Software Engineering Stack Exchange with no answer - the site does not appear very active. If you think this question would be more appropriate on another Stack Exchange site, please feel free to direct me to it and I will delete the question here...

James Owers
  • 7,948
  • 10
  • 55
  • 71
  • I thought this was interesting https://stackoverflow.com/a/18159969/642070 – tdelaney Apr 10 '20 at 18:04
  • My question is not linux specific so [apt dependies for pypi package](https://stackoverflow.com/questions/58816180/apt-dependies-for-pypi-package) does not solve. My users will be cross platform, and I would rather they could simply `pip install` regardless of platform. – James Owers Apr 10 '20 at 19:33
  • @tdelaney thanks, it does look like I could use this to solve my problem. I'd be surprised if there isn't a standard way of doing this though... – James Owers Apr 10 '20 at 19:36
  • 1
    You could pip install an installer that then does the right thing for the platform. There are quite a few products out there that do that sort of thing. Dropbox and vscode on my ubuntu machine for instance. – tdelaney Apr 10 '20 at 20:12
  • 1
    Or conversely have .deb .rpm and .msi that pip install your package. One of the challenges is the rights you need. The platform install may need root/admin while the pip may be user and within a virtualenv. Even then is messy because something like anaconda has its own package manager. – tdelaney Apr 10 '20 at 20:15
  • This is very helpful @tdelaney, thank you. It looks like this is what I'll have to go with, given the 'answer' to this q appears to be non-trivial! – James Owers Apr 10 '20 at 21:24

0 Answers0