【问题标题】:setup.py is not install dependenciessetup.py 不是安装依赖项
【发布时间】:2022-01-15 09:20:31
【问题描述】:

我正在尝试创建一个可以通过pip install git+https://github.com/project/neat_util.git@master#egg=neat_util 安装的命令行实用程序,并且我正在使用python setup.py install 在本地进行测试。

import os
import pathlib

import setuptools

with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setuptools.setup(
    name="neat_util",
    version="1.0.0",
    author="Cogito Ergo Sum",
    author_email="cogito@ergo.sum",
    description="Util for utilization",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://gitlab.com/project/repo",
    classifiers=[
        "Programming Language :: Python :: 3"
    ],
    package_dir={"": "bin"},
    packages=setuptools.find_packages(where="bin"),
    include_package_data=True,,
    dependency_links=['git+https://github.com/company/dependency.git@master#egg=dependency'],
    python_requires=">=3.6",
    scripts=['bin/neat_util']
)

当我在本地测试它时,它安装得很好,我可以从命令行调用它,但我得到一个 ModuleNotFoundError" No module named dependency 错误。

根据此处https://pip.pypa.io/en/stable/topics/vcs-support/ 特别是git+https://git.example.com/MyProject.git@master#egg=MyProject 的文档,github url 似乎是正确的

运行 pip install git+https://github.com/company/dependency.git@master#egg=dependency 实际上也能正常工作,所以我确信 URL 不是问题。

项目结构:

├── bin
│   ├── script1
│   ├── script2
│   ├── script3
│   ├── neat_util
│   ├── script4
│   └── script5
├── collections.csv
├── config.cfg
├── config.cfg.example
├── env.sh
├── env.sh.example
├── example.csv
├── main.py
├── README.md
├── requirements.txt
├── setup.py
└── tests

这里的任何指针将不胜感激。

【问题讨论】:

    标签: python setup.py


    【解决方案1】:

    dependency_links 被宣布为过时,最后在pip 19.0 中宣布removed。它的替换是 install_requires 具有特殊语法(自 pip 19.1 起支持):

    install_requires=[
        'dependency @ git+https://github.com/company/dependency.git@master',
    ]
    

    https://www.python.org/dev/peps/pep-0440/#direct-references

    这需要pip install,包括pip install .,不适用于python setup.py install

    【讨论】:

      猜你喜欢
      • 2015-01-10
      • 1970-01-01
      • 2020-01-09
      • 2020-09-23
      • 2013-07-19
      • 2014-11-03
      • 1970-01-01
      • 1970-01-01
      • 2014-11-03
      相关资源
      最近更新 更多