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

Fix version attr module path with setuptools static attr parser #363

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

jameshilliard
Copy link
Contributor

Setuptools attr parser does not support following imports which results in setuptools falling back to dynamically executing the module during a build which can break when runtime dependencies are not yet present.

See:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#attr

Fixes:

Traceback (most recent call last):
  File "/home/buildroot/buildroot/output/per-package/python-logbook/host/lib/python3.11/site-packages/setuptools/config/expand.py", line 193, in read_attr
    return getattr(StaticModule(module_name, spec), attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildroot/buildroot/output/per-package/python-logbook/host/lib/python3.11/site-packages/setuptools/config/expand.py", line 87, in __getattr__
    raise AttributeError(f"{self.name} has no attribute {attr}") from e
AttributeError: logbook has no attribute __version__

Setuptools attr parser does not support following imports which
results in setuptools falling back to dynamically executing the
module during a build which can break when runtime dependencies
are not yet present.

See:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#attr

Fixes:
Traceback (most recent call last):
  File "/home/buildroot/buildroot/output/per-package/python-logbook/host/lib/python3.11/site-packages/setuptools/config/expand.py", line 193, in read_attr
    return getattr(StaticModule(module_name, spec), attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildroot/buildroot/output/per-package/python-logbook/host/lib/python3.11/site-packages/setuptools/config/expand.py", line 87, in __getattr__
    raise AttributeError(f"{self.name} has no attribute {attr}") from e
AttributeError: logbook has no attribute __version__

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
@RazerM
Copy link
Collaborator

RazerM commented Nov 9, 2023

In which scenario does this actually fail? I can do pip install --no-binary logbook logbook in a clean venv no bother.

I agree the StaticModule branch is better and I'll accept the PR, but I don't see any deprecation notice about the fallback method.

@jameshilliard
Copy link
Contributor Author

In which scenario does this actually fail?

When cross compiling for example with a host python interpreter that say doesn't have say ssl support.

I can do pip install --no-binary logbook logbook in a clean venv no bother.

Might be that the venv has ssl support while the cross host python interpreter does not in my case.

I don't see any deprecation notice about the fallback method.

Yeah, it's not deprecated AFAIU, it just happens to not function correctly when cross compiling if there are any target dependencies needed to execute the fallback method. Cross compiling python is a bit weird as you have both a host and target interpreter with separate site-packages.

@RazerM RazerM merged commit 11e7932 into getlogbook:develop Nov 10, 2023
25 checks passed
@jameshilliard jameshilliard deleted the fix-version-attr branch November 10, 2023 23:25
@RazerM
Copy link
Collaborator

RazerM commented Nov 10, 2023

v1.7.0.post0 has been released with the fix

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