Skip to content

Migrate away from pkg-resources #195

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

Merged
merged 2 commits into from
Sep 15, 2023
Merged

Conversation

kroenlein
Copy link
Collaborator

As of Python 3.7, distributing files within a package are supposed to use importlib.resources instead. This was causing a large number of import warnings.

Ostentibly no changes in functionality, though some of these interfaces deserve rethinking.

@kroenlein kroenlein requested a review from bfolie September 8, 2023 22:10
Comment on lines +21 to +27
def _deploy_default_files() -> str:
"""Copy the units & constants file into a temporary directory."""
default_dir = TemporaryDirectory()
_TEMP_DIRECTORIES.append(default_dir)

units_path = Path(default_dir.name) / "citrine_en.txt"
units_path.write_text(read_text("gemd.units", "citrine_en.txt"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The change in package behavior required a bunch of rework here because the units file imports the constants file via a relative file link, but importlib refuses to give a path-like object (as it may be unpacking a ZIP).

_scaling_preprocessor
],
autoconvert_offset_to_baseunit=True)
# TODO: Pint 0.18 doesn't accept paths; must stringify
Copy link

Choose a reason for hiding this comment

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

0.18 is an old version, yes? We'll be updating Pint soon-ish?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Support for 0.18 gets dropped with dropping Python 3.7.

@kroenlein kroenlein merged commit 9bf30c4 into main Sep 15, 2023
@kroenlein kroenlein deleted the maintain/remove-pkg-resources branch September 15, 2023 19:26
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