python setup.py 安装忽略 install_requires

python setup.py install ignores install_requires

我无法使用 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 上发现了这个问题,但没有给我任何关于它如何工作的指示或解决方案。

欢迎任何帮助,提前致谢!

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

Our policy to date has been that if using pip install fixes your problem, you should use pip install and we won't fix the issue.

我相信这符合 Python 社区中打包工具和技术的当前发展。因此,如果可以通过 pip install .pip install --editable . 安装具有此要求符号的基于 setuptools 的项目,则无需再寻找。


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