Skip to content

Conversation

@dimbleby
Copy link
Contributor

@dimbleby dimbleby commented Mar 18, 2023

dropping python 3.7 per #7674 moves poetry past the Windows python 3.7 bugs that made the homegrown temporary_directory() worthwhile

Summary by Sourcery

Enhancements:

  • Use stdlib TemporaryDirectory with ignore_cleanup_errors=True across metadata inspection, installation, HTTP download, and ephemeral environment creation paths.

@dimbleby dimbleby force-pushed the temporary-directory branch from 9e5031d to 5746e62 Compare March 18, 2023 19:46
@dimbleby dimbleby force-pushed the temporary-directory branch 2 times, most recently from c1d26e2 to 84ac784 Compare April 25, 2023 10:03
@dimbleby dimbleby force-pushed the temporary-directory branch from 84ac784 to e6620c8 Compare April 27, 2023 19:49
eamanu
eamanu previously approved these changes May 14, 2023
Copy link
Contributor

@eamanu eamanu left a comment

Choose a reason for hiding this comment

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

LGTM, we just need to wait for 3.7 drop :-)

@dimbleby
Copy link
Contributor Author

LGTM, we just need to wait for 3.7 drop :-)

In fact python-poetry/poetry-core#460 seems to leave poetry committed to its own implementation until support for python 3.9 (or windows!) can be dropped

@eamanu
Copy link
Contributor

eamanu commented May 20, 2023

@dimbleby try to avoid force push

@dimbleby
Copy link
Contributor Author

@eamanu thanks but no thanks.

per my last comment this is unlikely to be merged for quite some time and it is absolutely more sensible that when that time comes it will be best represented as a single commit on top of main.

All due respect but you have now made two low-value comments on this MR, please stop.

@dimbleby dimbleby force-pushed the temporary-directory branch from 8c7cd5f to 1e8e831 Compare June 4, 2023 14:17
@dimbleby dimbleby force-pushed the temporary-directory branch from 1e8e831 to daf5147 Compare October 20, 2023 23:16
@dimbleby dimbleby marked this pull request as draft October 28, 2023 16:06
@dimbleby dimbleby force-pushed the temporary-directory branch from daf5147 to ddc6ecc Compare March 2, 2024 14:25
@dimbleby dimbleby force-pushed the temporary-directory branch from ddc6ecc to 8b66b68 Compare April 8, 2024 19:41
@dimbleby dimbleby force-pushed the temporary-directory branch from 8b66b68 to b46efeb Compare January 12, 2025 13:53
@dimbleby dimbleby force-pushed the temporary-directory branch from b46efeb to a3deb9c Compare December 20, 2025 11:15
@dimbleby
Copy link
Contributor Author

dimbleby commented Dec 20, 2025

with support for python 3.9 now dropped, ignore_cleanup_errors is always available in the standard library TemporaryDirectory - so homegrown workarounds are no longer needed

@dimbleby dimbleby marked this pull request as ready for review December 20, 2025 11:25
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 20, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replace usages of a custom temporary_directory context manager and default tempfile.TemporaryDirectory with the standard library’s TemporaryDirectory while enabling ignore_cleanup_errors to avoid cleanup failures, now that Python 3.7 compatibility is dropped.

File-Level Changes

Change Details Files
Replace custom temporary directory helper with stdlib TemporaryDirectory using ignore_cleanup_errors where temporary workspaces are created.
  • Swap temporary_directory() usages for TemporaryDirectory(ignore_cleanup_errors=True) in sdist inspection, installation, HTTP download caching, and ephemeral environment creation paths.
  • Ensure all temporary directories created for extraction, download, and virtualenv setup tolerate cleanup errors during context manager exit.
src/poetry/inspection/info.py
src/poetry/installation/chef.py
src/poetry/repositories/http_repository.py
src/poetry/utils/env/__init__.py
Align existing tempfile.TemporaryDirectory usage with new ignore_cleanup_errors behavior.
  • Update get_pep517_metadata to pass ignore_cleanup_errors=True to tempfile.TemporaryDirectory for consistent cleanup behavior with other temporary directory usages.
src/poetry/inspection/info.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The switch between TemporaryDirectory(...) and tempfile.TemporaryDirectory(...) is inconsistent across files; consider standardizing on one import style to keep usage uniform.
  • Since ignore_cleanup_errors=True is now repeated at each call site, consider wrapping TemporaryDirectory in a small local helper/contextmanager so the Windows-specific behavior is centralized and easier to adjust later.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The switch between `TemporaryDirectory(...)` and `tempfile.TemporaryDirectory(...)` is inconsistent across files; consider standardizing on one import style to keep usage uniform.
- Since `ignore_cleanup_errors=True` is now repeated at each call site, consider wrapping `TemporaryDirectory` in a small local helper/contextmanager so the Windows-specific behavior is centralized and easier to adjust later.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Secrus Secrus merged commit c21cd35 into python-poetry:main Dec 20, 2025
54 checks passed
@dimbleby dimbleby deleted the temporary-directory branch December 20, 2025 11:36
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.

3 participants