mocnik-science / osm-python-tools

A library to access OpenStreetMap related services
GNU General Public License v3.0
440 stars 48 forks source link

Test dependencies in `setup.py` #45

Closed simonTurintech closed 2 years ago

simonTurintech commented 3 years ago

Hi, first of all thank you very much for all your work on this package.

While insalling this package, I realised that it introduces a dependency on pytest and pytest-sugar (see this line and this line).

Are those dependencies needed for end users, or should they be distributed somewhere else for developer of this library only? I'm asking this question because installing the package produces a side-effect for me which is modifying my pytest interface.

Thank you for your time.

franz-benjamin commented 3 years ago

Dear Simon, Thanks for your message and your appreciation of this package. The dependencies you name are needed when testing the package, which should be possible when installing it (as an option). How would you propose to hide this dependency when not being a developer? Thanks for your appreciated reply! Franz-Benjamin

simonTurintech commented 3 years ago

If this is indeed a requirement for developpers, when testing the application (as I expected), I know of 2 separate solutions:

A separate requirements file

As this is targeted to developpers, you can provide a separate file for requirements, for example requirements_test.txt. You probably don't run the tests without cloning the repository first, so that makes sense.

You'd implement this solution by isolating the two test-specific line in a separate txt.

Setuptools extra-requires

Setuptools allows you to create optional dependencies in your setup.py. The keyword extra_requires (see the docs, don't forget to click "setup.py") would allow you to declare an optional dependency like test, that would be installed with pip install OSMPythonTools[test].

You'd implement this solution by adding a new keyword argument in setup.py, right below install_requires:

install_requires={
    'test': ['pytest', 'pytest-sugar']
}

And of course removing those from the regular install_requires.


If any of those two solution would work for you, I can make a PR implementing either one.

mocnik-science commented 2 years ago

Thanks for your kind reply. I have many other tasks on my table but hope to be able to follow up soon. I prefer to have a look at the matter myself before making an informed decision.

mocnik-science commented 2 years ago

Yes, I like your second suggestion and have implemented it. I would be delighted if you could briefly test and confirm that the version released officially can be installed with and without the test dependencies. Thank you in advance!

simonTurintech commented 2 years ago

Hi, your release 0.3.3 is working exactly as expected! Thank you very much.

mocnik-science commented 2 years ago

Great. Thanks for having checked!