I'm adding functionality to an existing pip-installable project, and the project owner feels that my adding of pandas
to the setup.py installation requirements is 'too heavy', as the project should remain slim. The functionality I'm adding does not require pandas
(because the functionality is operations on top of a pandas.DataFrame
object), but the unit tests I wrote for it require invoking pandas
to setUp
a test DataFrame to mutate with.
Is there some way to require pandas
only for the unit tests? Or do I just not add it to the requirements, and raise an error to manually install pandas
when that unit test is run?
Install packages with pip: -r requirements.txt You can name the configuration file whatever you like, but requirements.txt is often used. Put requirements.txt in the directory where the command will be executed. If it is in another directory, specify its path like path/to/requirements.txt .
Tests are put in files of the form test_*. py or *_test.py , and are usually placed in a directory called tests/ in a package's root.
The intent of this package is to provide a simple module that can be easily installed and uninstalled. This provides a straightforward mechanism for showing that an arbitrary environment is capable of installing third party modules via pip.
Yes, it's simple in setuptools
:
# setup.py
from setuptools import setup
setup(
name='your_app',
...
install_requires=...
extras_require={
'dev': [
'pytest', 'pandas', 'coverage', # etc
]
},
)
Now when you develop on the app, use:
pip install --editable .[dev]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With