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

Stop using pkg_resources #158

Merged
merged 6 commits into from
Mar 9, 2023
Merged

Stop using pkg_resources #158

merged 6 commits into from
Mar 9, 2023

Conversation

bmw
Copy link
Member

@bmw bmw commented Mar 7, 2023

When working on #157, I got errors because the new version of setuptools deprecates pkg_resources. To fix that, I used the "Attention" message at the top of https://setuptools.pypa.io/en/latest/pkg_resources.html and https://importlib-resources.readthedocs.io/en/latest/index.html. Importing testdata as a package like this after adding __init__.py Just Works™ for the same reason import test_util works.

@bmw bmw marked this pull request as ready for review March 7, 2023 23:15

def vector_path(*names: str) -> str:
"""Path to a test vector."""
return pkg_resources.resource_filename(
__name__, os.path.join('testdata', *names))
file_manager = contextlib.ExitStack()
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to have an explanatory comment here.

For me, it was not obvious that as_file might generate temporary files on disk that need to be cleaned up.

Copy link
Member Author

@bmw bmw Mar 9, 2023

Choose a reason for hiding this comment

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

That's totally reasonable. I linked to the migration guide I based this code on.

@alexzorin alexzorin self-assigned this Mar 8, 2023
Copy link
Collaborator

@alexzorin alexzorin left a comment

Choose a reason for hiding this comment

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

LGTM!

@alexzorin alexzorin merged commit 8f1b4b5 into master Mar 9, 2023
@alexzorin alexzorin deleted the no-pkg-resources branch March 9, 2023 21:00
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