ppannuto / python-titlecase

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

Installation not possible because of missing module regex #50

Closed 1kastner closed 4 years ago

1kastner commented 4 years ago
(base) PS C:\XXX\titlecase> python setup.py install --user   
Traceback (most recent call last):
  File "setup.py", line 10, in <module>
    from titlecase import __version__
  File "C:\XXX\titlecase\titlecase\__init__.py", line 19, in <module>
    import regex
ModuleNotFoundError: No module named 'regex'
(base) PS C:\XXX\titlecase> 

The version should be kept somewhere else or other adjustments in the code are necessary.

igorburago commented 4 years ago

The ModuleNotFoundError exception is raised because the regex module is not loaded at the time of the titlecase module import— even though the regex module is listed in setup_requires—because the call to setup() is not yet executed then.

The Python Packaging User Guide recommends several ways to directly parse the version string without loading the module to avoid situations exactly like this one. PR #54 follows the first of those approaches.

If there exist reasons why another technique might be preferable instead, it can, of course, be discussed. Otherwise, merging #54 should suffice to fix this issue and unblock #52, I believe.

ppannuto commented 4 years ago

Closed by #55 (really #54, thanks again @iburago!)