Python setup.py with private repository on GitLab as dependency_links based on commit ID

前端 未结 2 1641
一向
一向 2021-01-24 19:32

I am trying to install a private dependency (not something that Python could find on PyPI).

I have added to the file setup.py this (as explained here: https

相关标签:
2条回答
  • 2021-01-24 20:18

    https://python-packaging.readthedocs.io/ is quite old and outdated. Its sources was last updated at Dec 29, 2016 and most parts of it were not updated since 2012. Python packaging landscape changed significantly since that times. The new docs are at https://packaging.python.org/

    dependency_links were declared obsolete and finally removed in pip 19.0. The replacement for it is install_requires with special syntax (supported since pip 19.1):

    install_requires=[
        'package_name @ git+https://gitlab.com/<PRIVATE_ORG>/<PRIVATE_REPO>.git@<COMMIT_ID>'
    ]
    

    See https://pip.readthedocs.io/en/stable/reference/pip_install/#requirement-specifiers and https://www.python.org/dev/peps/pep-0440/#direct-references

    This requires pip install including pip install . and doesn't work with python setup.py install.

    0 讨论(0)
  • 2021-01-24 20:36

    I've read multiple answers, but only this one worked for me (using pip 20.2.3 and Gitlab Pypi feature):

    pip3 install --extra-index-url https://__token__:my_personal_token@gitlab.com/api/v4/projects/347/packages/pypi/simple .
    

    My setup.py looked like:

    from setuptools import setup
    
    setup(name='whatever_production_scripts',
          version='0.0.1',
          description='Whatever production scripts',
          url='https://gitlab.com/user/whatever',
          author='Me Myself',
          author_email='user@whatever.com',
          license='All rights reserved',
          scripts=[
              'whatever_production_scripts/production/insomnia.py',
              'whatever_production_scripts/production/rdsmaintenance.py',
              'whatever_production_scripts/production/changeinstancetype.py',
          ],
          packages=[
              'whatever_production_scripts',
              'whatever_production_scripts.production',
          ],
          classifiers=[
              "Development Status :: 3 - Alpha",
              "Intended Audience :: System Administrators",
              "Operating System :: POSIX :: Linux",
              "Topic :: Internet",
              "Topic :: System :: Systems Administration",
              "Programming Language :: Python :: 3 :: Only"
          ],
          install_requires=[
              'privatepackage1>=0.1',
              'publicpackage1>=7',
              'publicpackage2>=2'
          ],
          zip_safe=False)
    
    0 讨论(0)
提交回复
热议问题