Pip忽略中的依赖项\u链接设置.py尽管形式恰当

2024-06-13 22:05:44 发布

您现在位置:Python中文网/ 问答频道 /正文

作为过去的解决方案,例如 pip ignores dependency_links in setup.py,此配置应该有效。在

我的相关内容设置.py在

packages=find_packages(),
dependency_links=['http://github.com/koji-project/koji/tarball/master#egg=koji'],
install_requires=['jira', 'PyYAML', 'requests', 'psycopg2',
                  'elasticsearch', 'beanbag', 'pyzabbix', 'enum34',
                  'beautifulsoup4', 'pytz', 'koji'],
tests_require=['flake8', 'autopep8', 'mock'],
include_package_data=True,
cmdclass={'test': setupTestRequirements}

我唯一能想到的是我的网址是无效的。我不明白为什么会这样,因为它的版本是1.14.0。在

在运行pip install .时,我得到。在

^{pr2}$

运行python setup.py develop --user时,输出没有提到Koji


Tags: installpipinpygithubhttp内容packages
1条回答
网友
1楼 · 发布于 2024-06-13 22:05:44

您的配置正确。然而,问题出在别处。看看^{} repo on github:项目没有提交setup.py。只要没有setup.py脚本,pip和{}(通过setup.py install/setup.py develop)都无法安装您的项目,因为它们根本无法安装koji依赖项,因为它根本就不是有效的python包。在

更新:

github上的kojirepo的问题是,它只是位于Fedora Pagure上的实际dev repo的镜像,没有与上游同步。因此,正确的答案是使用真实的开发存储库,而不是github镜像:

dependency_links=['git+https://pagure.io/koji.git#egg=koji-1.14.0']

别紧张。:-)

原始答案(过时,仅当您想从Github上的kojis repo mirror安装时):

我认为有两种方法可以解决这种情况:

分叉

  1. github上的forkkoji
  2. 编写您自己的setup.py脚本或将其复制到某处(有关详细信息,请参阅下面的内容),提交并推送
  3. 在项目的setup.py中调整dependency_links中的URL。在

为了测试,我准备了一个fork of ^{} with a setup script;如果我使用它的URL而不是上游repo,则安装成功。我还用koji-1.14.0.post1标记了我自己的“release”,以区分带有安装脚本的版本和普通版本。具有新依赖项的示例setup.py

^{pr2}$

使用pip测试安装结果:

$ pip install .  process-dependency-links
Obtaining file:///home/hoefling/python/spam
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting koji==1.14.0.post1 (from spam==0.1)
  Downloading https://github.com/hoefling/koji/tarball/master (1.4MB)
    100% |████████████████████████████████| 1.4MB 759kB/s 
Collecting pyOpenSSL (from koji==1.14.0.post1->spam==0.1)
  Using cached pyOpenSSL-17.5.0-py2.py3-none-any.whl
Collecting pycurl (from koji==1.14.0.post1->spam==0.1)
  Using cached pycurl-7.43.0.1.tar.gz
...
Installing collected packages: six, idna, asn1crypto, pycparser, cffi, 
cryptography, pyOpenSSL, pycurl, python-dateutil, chardet, certifi, 
urllib3, requests, pykerberos, requests-kerberos, rpm-py-installer, 
koji, spam
  Running setup.py install for rpm-py-installer ... done
  Running setup.py install for koji ... done
  Running setup.py install for spam ... done
Successfully installed asn1crypto-0.23.0 certifi-2017.11.5 cffi-1.11.2 
chardet-3.0.4 cryptography-2.1.4 idna-2.6 koji-1.14.0.post1 pyOpenSSL-17.5.0 
pycparser-2.18 pycurl-7.43.0.1 pykerberos-1.1.14 python-dateutil-2.6.1 
requests-2.18.4 requests-kerberos-0.11.0 rpm-py-installer-0.5.0 six-1.11.0 
spam-0.1 urllib3-1.22

安装的软件包看起来不错:

$ pip list
Package           Version     
        -       
asn1crypto        0.23.0      
certifi           2017.11.5   
cffi              1.11.2      
chardet           3.0.4       
cryptography      2.1.4       
idna              2.6         
koji              1.14.0.post1
pip               9.0.1       
pycparser         2.18        
pycurl            7.43.0.1    
pykerberos        1.1.14      
pyOpenSSL         17.5.0      
python-dateutil   2.6.1       
requests          2.18.4      
requests-kerberos 0.11.0      
rpm-py-installer  0.5.0       
rpm-python        4.11.3      
setuptools        38.2.4      
six               1.11.0      
spam              0.1         
urllib3           1.22        
wheel             0.30.0

这种方法的缺点是在安装脚本合并到上游之前维护fork的额外开销。这包括测试并最终在您的fork中调整koji的{},每次您想要同步上游更新。我可能会创建一个单独的分支,并在那里提交安装脚本,sync the fork as usual,然后在fork的主节点上重新建立分支的基础,但是如果您习惯了另一个更新策略,请坚持使用它。在

使用来自TestPyPI

实际上,我在TestPyPI上找到了一些最新版本的koji轮子。这也是我得到上面fork的setup.py的地方-我下载了源tar,解包并复制了安装脚本。这意味着koji开发人员正在研究通过PyPI分发项目,并正在编写安装脚本,但尚未提交。当他们处理它时,您可以使用测试包索引作为解决方法。这样,您就不会从源代码构建包,而是使用kojidevs构建和上载的轮子:

setup(
    ...
    dependency_links=['https://testpypi.python.org/pypi/koji'],
    install_requires=['koji'],
)

这种方法的缺点是:

  1. 您根本不知道TestPyPI中的koji包是否可以安装。即使是这样,也不能保证所安装的代码能按预期工作(尽管应该如此)。当你有了fork,你总是可以自己修复安装脚本-在这里,如果wheel文件有错误,你就完了。在
  2. TestPyPI上的包会定期删除。From the docs

    Note: The database for TestPyPI may be periodically pruned, so it is not unusual for user accounts to be deleted.

最后一个注释eh3>

当然,您可以结合这两种解决方法,并在dependency_links中使用这两个url:

setup(
    ...
    dependency_links=[
        'https://testpypi.python.org/pypi/koji',
        'https://github.com/hoefling/tarball/master#egg=koji-1.14.0.post1',
    ],
    install_requires=['koji'],
)

这样,如果在TestPyPI上找不到包,那么它将从fork构建。在

最后注2

您可能需要安装一些附加的系统包;至少对于我的系统CentOS Linux release 7.3.1611 (Core)我必须安装curl-devel来满足pycurl。在

相关问题 更多 >