使用带有setup.py的额外python包索引url

时间:2022-09-12 07:30:11

Is there a way to use an extra python package index (ala pip --extra-index-url pypi.example.org mypackage) with setup.py so that running python setup.py install can find the packages hosted on pypi.example.org?

有没有办法使用setup.py额外的python包索引(ala pip --extra-index-url pypi.example.org mypackage),以便运行python setup.py install可以找到pypi.example上托管的包。 ORG?

4 个解决方案

#1


21  

If you're the package maintainer, and you want to host one or more dependencies for your package somewhere other than PyPi, you can use the dependency_links option of setuptools in your distribution's setup.py file. This allows you to provide an explicit location where your package can be located.

如果您是软件包维护者,并且希望在PyPi以外的地方托管一个或多个依赖项,则可以在分发的setup.py文件中使用setuptools的dependency_links选项。这允许您提供可以找到包的明确位置。

For example:

例如:

from setuptools import setup

setup(
    name='somepackage',
    install_requires=[
        'somedep'
    ],
    dependency_links=[
        'https://pypi.example.org/pypi/somedep/'
    ]
    # ...
)

If you host your own index server, you'll need to provide links to the pages containing the actual download links for each egg, not the page listing all of the packages (e.g. https://pypi.example.org/pypi/somedep/, not https://pypi.example.org/)

如果您拥有自己的索引服务器,则需要提供指向包含每个鸡蛋的实际下载链接的页面的链接,而不是列出所有包的页面(例如https://pypi.example.org/pypi/somedep) /,而不是https://pypi.example.org/)

#2


3  

setuptools uses easy_install under the hood.

setuptools在引擎盖下使用easy_install。

It relies on either setup.cfg or ~/.pydistutils.cfg as documented here.

它依赖于setup.cfg或〜/ .pydistutils.cfg,如此处所述。

Extra paths to packages can be defined in either of these files with the find_links. You can override the registry url with index_url but cannot supply an extra-index-url. Example below inspired by the docs:

可以使用find_links在这些文件中定义包的额外路径。您可以使用index_url覆盖注册表URL,但不能提供额外的index-url。以下示例受文档启发:

[easy_install]
find_links = http://mypackages.example.com/somedir/
             http://turbogears.org/download/
             http://peak.telecommunity.com/dist/
index-url = https://mypi.example.com

#3


0  

As far as I know, you cant do that. You need to tell pip this, or by passing a parameter like you mentioned, or by setting this on the user environment.

据我所知,你不能这样做。你需要告诉pip,或者通过传递你提到的参数,或者在用户环境中设置它。

Check my ~/.pip/pip.conf:

检查我的〜/ .pip / pip.conf:

[global]
download_cache = ~/.cache/pip
index-url = http://user:pass@localpypiserver.com:80/simple
timeout = 300

In this case, my local pypiserver also proxies all packages from pypi.python.org, so I dont need to add a 2nd entry.

在这种情况下,我的本地pypiserver也代理pypi.python.org中的所有包,所以我不需要添加第二个条目。

#4


-2  

You can include --extra-index-urls in a requirements.txt file. See: http://pip.readthedocs.org/en/0.8.3/requirement-format.html

您可以在requirements.txt文件中包含--extra-index-urls。请参阅:http://pip.readthedocs.org/en/0.8.3/requirement-format.html

#1


21  

If you're the package maintainer, and you want to host one or more dependencies for your package somewhere other than PyPi, you can use the dependency_links option of setuptools in your distribution's setup.py file. This allows you to provide an explicit location where your package can be located.

如果您是软件包维护者,并且希望在PyPi以外的地方托管一个或多个依赖项,则可以在分发的setup.py文件中使用setuptools的dependency_links选项。这允许您提供可以找到包的明确位置。

For example:

例如:

from setuptools import setup

setup(
    name='somepackage',
    install_requires=[
        'somedep'
    ],
    dependency_links=[
        'https://pypi.example.org/pypi/somedep/'
    ]
    # ...
)

If you host your own index server, you'll need to provide links to the pages containing the actual download links for each egg, not the page listing all of the packages (e.g. https://pypi.example.org/pypi/somedep/, not https://pypi.example.org/)

如果您拥有自己的索引服务器,则需要提供指向包含每个鸡蛋的实际下载链接的页面的链接,而不是列出所有包的页面(例如https://pypi.example.org/pypi/somedep) /,而不是https://pypi.example.org/)

#2


3  

setuptools uses easy_install under the hood.

setuptools在引擎盖下使用easy_install。

It relies on either setup.cfg or ~/.pydistutils.cfg as documented here.

它依赖于setup.cfg或〜/ .pydistutils.cfg,如此处所述。

Extra paths to packages can be defined in either of these files with the find_links. You can override the registry url with index_url but cannot supply an extra-index-url. Example below inspired by the docs:

可以使用find_links在这些文件中定义包的额外路径。您可以使用index_url覆盖注册表URL,但不能提供额外的index-url。以下示例受文档启发:

[easy_install]
find_links = http://mypackages.example.com/somedir/
             http://turbogears.org/download/
             http://peak.telecommunity.com/dist/
index-url = https://mypi.example.com

#3


0  

As far as I know, you cant do that. You need to tell pip this, or by passing a parameter like you mentioned, or by setting this on the user environment.

据我所知,你不能这样做。你需要告诉pip,或者通过传递你提到的参数,或者在用户环境中设置它。

Check my ~/.pip/pip.conf:

检查我的〜/ .pip / pip.conf:

[global]
download_cache = ~/.cache/pip
index-url = http://user:pass@localpypiserver.com:80/simple
timeout = 300

In this case, my local pypiserver also proxies all packages from pypi.python.org, so I dont need to add a 2nd entry.

在这种情况下,我的本地pypiserver也代理pypi.python.org中的所有包,所以我不需要添加第二个条目。

#4


-2  

You can include --extra-index-urls in a requirements.txt file. See: http://pip.readthedocs.org/en/0.8.3/requirement-format.html

您可以在requirements.txt文件中包含--extra-index-urls。请参阅:http://pip.readthedocs.org/en/0.8.3/requirement-format.html