简体   繁体   English

Setup.py 从 requirements.txt 跳过开发依赖

[英]Setup.py skip dev dependency from requirements.txt

I have a requirements.txt file with following dependecies:我有一个具有以下依赖项的 requirements.txt 文件:

PyYAML
requests
nose
tox
mock
coverage

I would like setup.py to skip nose, tox mock and coverage dependencies.我希望 setup.py 跳过鼻子、tox 模拟和覆盖范围的依赖关系。 My setup.py file looks like:我的 setup.py 文件如下所示:

#!/usr/bin/env python3
"""Setup Information."""
from setuptools import setup, find_packages

with open('requirements.txt') as f:
    required_dependencies = f.read().splitlines()

setup(
    name="DemoModule",
    version="1.0",
    description="A library with inputs",
    packages=find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: SomeLicences.com",
        "Operating System :: OS Independent",
    ],
    install_requires=required_dependencies,
)

The simple answer would be to add a line to your setup.py like the following简单的答案是在 setup.py 中添加一行,如下所示

#!/usr/bin/env python3
"""Setup Information."""
from setuptools import setup, find_packages

with open('requirements.txt') as f:
    required_dependencies = f.read().splitlines()

# Do not install nose
required_dependencies.remove('nose')

setup(
    name="DemoModule",
    version="1.0",
    description="A library with inputs",
    packages=find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: SomeLicences.com",
        "Operating System :: OS Independent",
    ],
    install_requires=required_dependencies,
)

However, removing it from the requirements.txt would perhaps be cleaner and accomplish the same thing.但是,从 requirements.txt 中删除它可能会更清晰并完成同样的事情。

It would be helpful to know more about the issue and why installing nose is giving you problems.了解更多关于这个问题以及为什么安装鼻子会给你带来问题会很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 setup.py&pip:覆盖requirements.txt中依赖项的子依赖项之一 - setup.py & pip: override one of the dependency's sub-dependency from requirements.txt requirements.txt 与 setup.py - requirements.txt vs setup.py Pyramid config .ini文件,setup.py和requirements.txt - Pyramid config .ini files, setup.py and requirements.txt 使用 requirements.txt 的 setup.py 文件 - setup.py file using requirements.txt setup.py没有看到我的requirements.txt - setup.py doesn't see my requirements.txt cffi (setup.py) 的构建轮...在 django 中从 requirements.txt 安装软件包时出错 - Building wheel for cffi (setup.py) ... error while installing the packages from requirements.txt in django 如何安装 github zip 文件与 pip 和 setup.py 来自 requirements.txt? - How can I install a github zip file with pip and setup.py from requirements.txt? 为什么使用点“.”从 setup.py 安装 `install_requires` 在 Dockerfile 中的 requirements.txt 失败? - Why does installing `install_requires` from setup.py using a dot “.” in the requirements.txt fail in Dockerfile? 结构化setup.py和requirements.txt,以便正确安装pip - Structuring setup.py and requirements.txt so that pip installs properly Requirements.txt中的python版本与setup.py中的安装问题有关 - python version in requirements.txt issues with install requires in setup.py
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM