Skip to content

setup.py: Read version from __init__.py to avoid importing the module - #55

Merged
ppannuto merged 1 commit into
masterfrom
how-is-this-the-hard-part
Jun 12, 2020
Merged

setup.py: Read version from __init__.py to avoid importing the module#55
ppannuto merged 1 commit into
masterfrom
how-is-this-the-hard-part

Conversation

@ppannuto

Copy link
Copy Markdown
Owner

The module import happens before setup() is executed, and therefore,
none of the modules specified in 'setup_requires' (or 'install_requires',
for that matter) are loaded at that moment, causing the import to fail
with ModuleNotFoundError.

Following the first recommendation from the 'Single-sourcing the
package version' section of the Python Package User Guide 1, in this
commit we switch to reading the version string from the 'init.py'
file instead of attempting to import the module.


Also includes updates in patch at
#54 (comment)

The module import happens before setup() is executed, and therefore,
none of the modules specified in 'setup_requires' (or 'install_requires',
for that matter) are loaded at that moment, causing the import to fail
with ModuleNotFoundError.

Following the first recommendation from the 'Single-sourcing the
package version' section of the Python Package User Guide [1], in this
commit we switch to reading the version string from the '__init__.py'
file instead of attempting to import the module.

[1]: https://packaging.python.org/guides/single-sourcing-package-version/

---

Also includes updates in patch at
#54 (comment)
@ppannuto

Copy link
Copy Markdown
Owner Author

Closes #50, #54

Thanks @iburago!!

@ppannuto
ppannuto merged commit 76789da into master Jun 12, 2020
@ppannuto
ppannuto deleted the how-is-this-the-hard-part branch June 12, 2020 15:25
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 82.927% when pulling 4b7aa31 on how-is-this-the-hard-part into f7ae65c on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants