Python setuptools: How can I list a private repository under install_requires?

前端 未结 8 1426
南旧
南旧 2020-12-04 15:07

I am creating a setup.py file for a project which depends on private GitHub repositories. The relevant parts of the file look like this:

from s         


        
相关标签:
8条回答
  • 2020-12-04 15:31

    Using archive URL from github works for me, for public repositories. E.g.

    dependency_links = [
      'https://github.com/username/reponame/archive/master.zip#egg=eggname-version',
    ]
    
    0 讨论(0)
  • 2020-12-04 15:36

    This work for our scenario:

    1. package is on github in a private repo
    2. we want to install it into site-packages (not into ./src with -e)
    3. being able to use pip install -r requirements.txt
    4. being able to use pip install -e reposdir (or from github), where the dependencies are only specified in requirements.txt

    https://github.com/pypa/pip/issues/3610#issuecomment-356687173

    0 讨论(0)
  • 2020-12-04 15:39

    Here's what worked for me:

      install_requires=[
          'private_package_name==1.1',
      ],
      dependency_links=[
          'git+ssh://git@github.com/username/private_repo.git#egg=private_package_name-1.1',
      ]
    

    Note that you have to have the version number in the egg name, otherwise it will say it can't find the package.

    0 讨论(0)
  • 2020-12-04 15:42

    Via Tom Hemmes' answer I found this is the only thing that worked for me:

        install_requires=[
            '<package> @ https://github.com/<username>/<package>/archive/<branch_name>.zip']
    
    0 讨论(0)
  • 2020-12-04 15:43

    I was trying to get this to work for installing with pip, but the above was not working for me. From [1] I understood the PEP508 standard should be used, from [2] I retrieved an example which actually does work (at least for my case).

    Please note; this is with pip 20.0.2 on Python 3.7.4

    setup(
        name='<package>',
    ...
        install_requires=[
            '<normal_dependency>',
             # Private repository
            '<dependency_name> @ git+ssh://git@github.com/<user>/<repo_name>@<branch>',
             # Public repository
            '<dependency_name> @ git+https://github.com/<user>/<repo_name>@<branch>',
        ],
    )
    

    After specifying my package this way installation works fine (also with -e settings and without the need to specify --process-dependency-links).

    References [1] https://github.com/pypa/pip/issues/4187 [2] https://github.com/pypa/pip/issues/5566

    0 讨论(0)
  • 2020-12-04 15:43

    I found a (hacky) workaround:

    #!/usr/bin/env python
    
    from setuptools import setup
    import os
    
    os.system('pip install git+https://github-private.corp.com/user/repo.git@master')
    
    setup( name='original-name'
         , ...
         , install_requires=['repo'] )
    

    I understand that there are ethical issues with having a system call in a setup script, but I can't think of another way to do this.

    0 讨论(0)
提交回复
热议问题