【问题标题】:python setup.py install ignores install_requirespython setup.py install 忽略 install_requires
【发布时间】:2020-02-24 07:00:31
【问题描述】:

我无法使用 setup.py 安装本地软件包

这是项目结构:

my-project/
  lib/
     local1/
        local1.1.0.whl
        index.html
     local2/
        local2.1.0.whl
        index.html
  setup.py

setup.py

import os

from setuptools import setup

setup(name='my project',
      version='1.0',
      description='my project',
      install_requires=[
        'lxml >= 4.3.0',
        'local1 @ file://localhost/{}/lib/local1/local1.1.0.whl'.format(os.getcwd()),
        'local2 @ file://localhost/{}/lib/local2/local2.2.0.whl'.format(os.getcwd()),
      ]
      )

如果我将依赖项放在requirements.txt 文件中并使用pip install -r requirements.txt --extra-index-url lib/,我可以安装,但我想知道为什么不能执行python setup.py install 或者如果我遗漏了什么。

这是我得到的错误 -

No local packages or working download links found for local2@ file://localhost//Users/anusha/Documents/my-project/lib/local2/local2.1.0.whl
error: Could not find suitable distribution for Requirement.parse('local2@ file://localhost//Users/anusha/Documents/my-project/lib/local2/local2.1.0.whl')

在搜索时,我在github 上发现了这个问题,但没有给我任何关于它如何工作的指示或解决方案。

欢迎任何帮助,在此先感谢!

【问题讨论】:

  • 不完全确定 setuptools 支持这种表示法。你指的是"direct references" of PEP440吗?注意三 (3) 个斜线!
  • 因为我指定localhost 2 个斜杠就足够了,即使我不确定 setuptools 是否支持这一点,但没有找到任何支持文件来证明这一点!我试过pip install git+file//$PWD/,它似乎工作
  • 是的,在这期间我读到了"File URLs" section of PEP 440,它似乎指定了这个符号,因此支持你的主张。

标签: python pip setup.py


【解决方案1】:

注意这个comment from pganssle in the discussion "Setuptools install fails with PEP508 URLs" in setuptools's issue tracker

迄今为止,我们的政策是,如果使用 pip install 解决了您的问题,您应该使用 pip install,我们不会解决问题。

我相信这符合 Python 社区中打包工具和技术的当前演变。因此,如果您的基于 setuptools 的项目可以通过 pip install .pip install --editable . 安装,那么请不要再犹豫了。


关于该主题的更完整(详尽)的文章:

【讨论】:

  • 谢谢!足够的证据不要挂断python setup.py install
猜你喜欢
  • 2014-03-21
  • 2020-02-20
  • 2016-10-08
  • 1970-01-01
  • 1970-01-01
  • 2018-11-03
  • 2012-04-06
  • 1970-01-01
  • 2019-12-18
相关资源
最近更新 更多