-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@@ -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), |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
4433e90
to
8421e5d
Compare
@@ -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), |
There was a problem hiding this comment.
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.
5cc5f80
to
e588f89
Compare
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 |
There was a problem hiding this comment.
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.
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
newsfragments/
.(See documentation for details)