ppannuto / python-titlecase

Python library to capitalize strings as specified by the New York Times Manual of Style
MIT License
249 stars 38 forks source link

setup.py: The ‘regex’ package does not get automatically installed as a dependency #56

Closed igorburago closed 4 years ago

igorburago commented 4 years ago

If the regex package is not installed on the user’s system, the current setup.py file does not install it automatically, causing the ModuleNotFoundError exception in any module importing titlecase:

Traceback (most recent call last):
  …
  File "/Users/ib/Library/Python/3.7/lib/python/site-packages/titlecase/__init__.py", line 16, in <module>
    import regex
ModuleNotFoundError: No module named 'regex'

This is due to regex being listed in the setup_requires argument in the setup call only, and not being listed in the install_requires one.

The issue can be resolved by adding the following argument to the setup() call:

    install_requires=['regex>=2020.4.4'],

We should be aware that this exposes a known issue with setuptools when the same package is listed both in setup_requires and install_requires. However, this only applies to the cases when the setup.py is invoked manually.

It is my understanding that when the package is installed via pip install, everything works correctly. Given that, I think, the tradeoff in adding regex to install_requires is well justified (especially given that the setuptools issue will hopefully be addressed in the future—if not already).

igorburago commented 4 years ago

Actually, do we need the regex module to be present during setup, if we have it as an install dependency?

Perhaps I am missing something, but I cannot see any reason why it is necessary to have regex in setup_requires, if we have it in install_requires.

ppannuto commented 4 years ago

Prior to the version fix, because it was imported in setup, it was needed in setup. I'm guessing way back in the day, setup ran before install and so things used to work.

I'll update this to move to install.

igorburago commented 4 years ago

Sounds good.