Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.py: Fix ModuleNotFoundError #144

Merged
merged 1 commit into from
Jul 19, 2022
Merged

setup.py: Fix ModuleNotFoundError #144

merged 1 commit into from
Jul 19, 2022

Conversation

martinpitt
Copy link
Owner

Commit 842d250 broke pip install and also some variants of
PEP-517 build tools: . is not in their default sys.path any more.
Merely adding that to the search path is not sufficient: building an
sdist in a venv is tripping over the missing import dbus, as
dbus-python is just a runtime dependency, not a build-time one.

So instead of importing dbusmock.__version__ in setup.py, ask
setuptools to dynamically generate the version in a declarative way, in
setup.cfg.

Many thanks to Michał Górny for analyzing this and proposing this
solution!

Fixes #142

Commit 842d250 broke `pip install` and also some variants of
PEP-517 build tools: `.` is not in their default `sys.path` any more.
Merely adding that to the search path is not sufficient: building an
sdist in a venv is tripping over the missing `import dbus`, as
dbus-python is just a runtime dependency, not a build-time one.

So instead of importing `dbusmock.__version__` in setup.py, ask
setuptools to dynamically generate the version in a declarative way, in
setup.cfg.

Many thanks to Michał Górny for analyzing this and proposing this
solution!

Fixes #142
@martinpitt
Copy link
Owner Author

I tested this with both python3 -m build --sdist and python3 setup.py sdist. @mgorny , WDYT?

Copy link

@mgorny mgorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. BTW, you may consider switching fully to setup.cfg:
https://setuptools.pypa.io/en/latest/userguide/declarative_config.html

It's there since 2017, so I think it should be safe to use by now ;-). It can also replace reading README.md manually.

@martinpitt
Copy link
Owner Author

@mgorny: Ack, thanks! I'll look into that. I also want to add a test for python3 -m build --sdist to make sure that this keeps working from now on. I'll do that in a new PR.

@martinpitt martinpitt merged commit dd2cf84 into master Jul 19, 2022
@martinpitt martinpitt deleted the fix-version branch July 19, 2022 08:05
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.

setup.py does not set sys.path correctly for importing dbusmock (when using PEP517 backend)
2 participants