1

I have a python package my-package that depends on a binary binary.exe but this binary is too big to be uploaded to pypi. Therefore I want to execute a bash script when the user does pip install ... that will wget the binary from my github and place it in their site-packages/my-package folder. Is this possible? If so, how would I go about doing this?

CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
  • pip can install stuff directly from github. Perhaps this could be of help: https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch – entropy Mar 04 '19 at 13:57

2 Answers2

1

One approach you could follow is adding the code to fetch the binary in your package itself, so that any time it gets imported, it first downloads the binary. You can do this using requests, or you can simply run your wget command using the subprocess module, though the requests approach is more robust.

entropy
  • 840
  • 6
  • 16
  • *any time it gets imported, it first downloads the binary* Will not work because: 1) the network could be down when the script is ran; 2) the user who runs the script may not have write access to the installation directory. – phd Mar 04 '19 at 12:48
1

There is no way. pip lags far behind real package namers like deb/rpm; pip-installable packages are rather primitive ones, they don't have pre/post-(un)install scripts.

You have to create your own installer using PyInstaller, py2exe, py2app or cx_Freeze. Or said deb/rpm — there are plugins for setuptools to generate debs and rpms.

phd
  • 82,685
  • 13
  • 120
  • 165