0

I have tried the following installation methods with no success to install a python package with a specific commit of a git repository:

$ python3 setup.py install --user

$ pip3 install -e .

$ python3 -m pip install -e .

Here is setup.py:

import sys
from setuptools import setup

install_requires = [
    # 'numpy>=1.9.0' # works
    # 'numpy' # works
    # 'git+https://github.com/numpy/numpy' # works
    # 'git+https://github.com/numpy/numpy@4c83c0444c68b89b051f7ef8d8eb1a2276439d78' # does not work
    # 'git+git://github.com/numpy/numpy.git@4c83c0444c68b89b051f7ef8d8eb1a2276439d78' # does not work
    # 'numpy@git+git://github.com/numpy/numpy.git@4c83c04' # installs the "best match" for numpy, not this commit
    # 'numpy @ git+ssh://git@github.com/numpy/numpy@4c83c0444c68b89b051f7ef8d8eb1a2276439d78#egg=numpy' # installs the "best match" for numpy, not this commit
    ]

setup(
      install_requires=install_requires,
      )

I've updated pip and setuptools both locally and as root: pip install -U pip setuptools

No change.

I've scanned setuptools, pip and other docs with no example that provides a working result.

How you specify a specific commit of a specific git repo as a dependency in a python package using setuptools?

khaverim
  • 3,386
  • 5
  • 36
  • 46
  • no, those answers seem to have a way to identify the package by release version but not by specific commit. – khaverim Nov 03 '20 at 18:37
  • https://stackoverflow.com/search?q=%5Bgit%5D+%5Bpip%5D+commit – phd Nov 03 '20 at 19:21
  • `install_requires = ['git+https://github.com/numpy/numpy@8b15e57718042c75af22a25a7d604fa0f938f16e']` – phd Nov 03 '20 at 19:22
  • `'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'+https:/'"` @phd – khaverim Nov 03 '20 at 22:38
  • https://stackoverflow.com/a/59164147/7976758: `pip install -U pip setuptools` Found in https://stackoverflow.com/search?q=%5Bpip%5D+install_requires+must+be+a+string+or+list+of+strings – phd Nov 03 '20 at 22:40
  • Yes, `pip` is the only way to install from git repo. – phd Nov 03 '20 at 23:18
  • does `python3 setup.py install` implicitly use pip, then? It works fine for `git+https://github.com/numpy/numpy` but not for `git+https://github.com/numpy/numpy@4c83c0444c68b89b051f7ef8d8eb1a2276439d78` – khaverim Nov 03 '20 at 23:20
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224070/discussion-between-khaverim-and-phd). – khaverim Nov 03 '20 at 23:31

1 Answers1

-1

You can find the correct way of doing it here: https://python-packaging.readthedocs.io/en/latest/dependencies.html#packages-not-on-pypi

The important thing is not to give a link to a git repository, but a link to a tarball which is generated by Github

EG

dependency_links=['http://github.com/user/repo/tarball/master#egg=package-1.0']

mmaaartin
  • 1
  • 3