简体   繁体   中英

Setup.py skip dev dependency from requirements.txt

I have a requirements.txt file with following dependecies:

PyYAML
requests
nose
tox
mock
coverage

I would like setup.py to skip nose, tox mock and coverage dependencies. My setup.py file looks like:

#!/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

#!/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.

It would be helpful to know more about the issue and why installing nose is giving you problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM