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

Avoid adding an empty/incomplete .egg-info to sys.path while traversing importlib.metadata.entry_points #4670

Closed
wants to merge 7 commits into from

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Oct 7, 2024

Related to the discussion in pypa/pyproject-hooks#206 (specifically pypa/pyproject-hooks#206 (comment)).

Summary of changes

  • Approach generate the whole directory first in a staging area before moving it to the final location.

  • 2220d40 and aa7e04f are refactoring.

  • 47c215b is the bulk of the change.

  • e1cd904 modifies a test which expectation no longer matches the implementation

  • 4433e90 post-pones some due deprecations (just so that the CI can pass, the deprecations should be discussed in a different issue/PR).

Closes

Pull Request Checklist

setuptools/dist.py Outdated Show resolved Hide resolved
@@ -504,7 +504,7 @@ def warn_dash_deprecation(self, opt, section):
versions. Please use the underscore name {underscore_opt!r} instead.
""",
see_docs="userguide/declarative_config.html",
due_date=(2024, 9, 26),
due_date=(2025, 3, 3),
Copy link
Contributor Author

@abravalheri abravalheri Oct 7, 2024

Choose a reason for hiding this comment

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

@@ -165,19 +165,17 @@ def test_expected_files_produced(self, tmpdir_cwd, env):
]
assert sorted(actual) == expected

def test_handling_utime_error(self, tmpdir_cwd, env):
dist = Distribution()
def test_handling_file_system_error(self, tmpdir_cwd, env):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Repurposing test, since the implementation no longer uses utime.


def rmdir(path, **opts):
if os.path.isdir(path):
rmtree(path, **opts)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This module was extracted from easy_install for re-use.

It seems that there are many projects that haven't adapted yet, so
we should probably avoid disruption.

Evidence: https://github.com/search?q=%2Fauthor-email%7Cmaintainer-email%7Clong-description%7Clicense-file%2F+path%3Asetup.cfg&type=code
@abravalheri abravalheri force-pushed the issue-pyproject-hooks-206 branch from 4433e90 to 8421e5d Compare October 7, 2024 14:51
@abravalheri abravalheri marked this pull request as ready for review October 7, 2024 15:02
@@ -529,7 +529,7 @@ def make_option_lowercase(self, opt, section):
future versions. Please use lowercase {lowercase_opt!r} instead.
""",
see_docs="userguide/declarative_config.html",
due_date=(2024, 9, 26),
due_date=(2025, 3, 3),
Copy link
Contributor Author

@abravalheri abravalheri Oct 7, 2024

Choose a reason for hiding this comment

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

Should be discussed in a separated issue/PR. For now just postponing to get the CI error out of the way.

#4672

@abravalheri abravalheri force-pushed the issue-pyproject-hooks-206 branch from 5cc5f80 to e588f89 Compare October 7, 2024 15:24
@abravalheri abravalheri requested a review from jaraco October 7, 2024 15:51
log.info(f"renaming {staging!r} to {self.egg_info!r}")
except OSError as e:
msg = f"Cannot create directory '{self.egg_info}' ({e})"
raise distutils.errors.DistutilsFileError(msg) from e
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaraco in this rewrite the main idea is to use a temporary directory to avoid adding an empty .egg-info to the path right before iterating over importlib_metadata.entry_points.

May be a bit convoluted, but this is what I could come up to make the process a bit more atomic.

This is related to the discussion in pypa/pyproject-hooks#206.

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.

1 participant