poetry-core icon indicating copy to clipboard operation
poetry-core copied to clipboard

Fix problem with deleting temporary folders on Windows

Open eblis opened this issue 3 years ago • 1 comments

This is another attempt for pull request https://github.com/python-poetry/poetry/pull/5171

  • [x] Added tests for changed code.
  • [x] Updated documentation for changed code.

From what I can tell the relevant code has been moved from poetry to poetry-core, I've created a new pull request targeting this repository.

eblis avatar Sep 02 '22 11:09 eblis

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Sep 02 '22 11:09 sonarqubecloud[bot]

This issue still exists (albeit intermittently) and is again blocking our CI process, is there anything we as users can do to get this fix expedited?

da1910 avatar Oct 10 '22 12:10 da1910

I'm seeing this issue as well. From what I can tell, this fix will resolve the issue and stop our intermittent Windows build failures.

Andy-Grigg avatar Oct 11 '22 13:10 Andy-Grigg

Hi, I'm waiting for this PR to merge. Can anyone give us some feedback on how is it going? How can we help to make it happen?

HenriqueAJNB avatar Jan 04 '23 17:01 HenriqueAJNB

I would also really appreciate this fix, as I am once again sitting in front of my computer, restarting poetry commands over and over for simply adding a new dependency.

DudeNr33 avatar Jan 05 '23 13:01 DudeNr33

@da1910 sorry, github suggested you as a reviewer so I just went ahead and accepted. I hope it doesn't take too long for this to get reviewed again, or else we'll have the same problem with stale code yet again.

eblis avatar Apr 26 '23 04:04 eblis

that would be great to see this merged soon <3 this problem is affecting me in a CI workflow for windows thanks @eblis for working on that

xmnlab avatar Apr 26 '23 12:04 xmnlab

https://github.com/python/cpython/pull/24793 adds ignore_cleanup_errors to the parameters of tempfile.TemporaryDirectory(), from python 3.10 onwards - which seems to be aimed at exactly this.

So perhaps the implementation of temporary_directory() should go: "if python >= 3.10 then use TemporaryDirectory(ignore_cleanup_errors=True), else do this much more complicated thing"

Or perhaps - given how longstanding this must be (https://github.com/python-poetry/poetry/issues/1031) - poetry should simply use TemporaryDirectory always, with ignore_cleanup_errors=True where available. Windows users on older pythons must be an ever-smaller minority.

dimbleby avatar Apr 26 '23 16:04 dimbleby

python/cpython#24793 adds ignore_cleanup_errors to the parameters of tempfile.TemporaryDirectory(), from python 3.10 onwards - which seems to be aimed at exactly this.

So perhaps the implementation of temporary_directory() should go: "if python >= 3.10 then use TemporaryDirectory(ignore_cleanup_errors=True), else do this much more complicated thing"

Or perhaps - given how longstanding this must be (python-poetry/poetry#1031) - poetry should simply use TemporaryDirectory always, with ignore_cleanup_errors=True where available. Windows users on older pythons must be an ever-smaller minority.

I would strongly favour making some effort to fix this for python 3.8 and 3.9, the fact that it's taken this long to address isn't really a reason to wash our hands of support, Python 3.9 is supported for another two and a half years after all!

da1910 avatar Apr 27 '23 09:04 da1910

Python 3.9 is supported for another two and a half years after all!

Sure. However, the current situation has been tolerated for all of that and then some; and for the huge majority who are not using older Pythons on Windows, I'd have a much higher degree of confidence in the standard library's temporary-directory implementation than in a home-grown implementation .

So I do think it would be preferable in general to use TemporaryDirectory(). I don't have very strong opinions about whether Windows with python 3.8 and 3.9 are important; but IMO it would at least be not absurd to choose to keep poetry code simple and decline to fix this for them.

dimbleby avatar Apr 27 '23 11:04 dimbleby

Python 3.9 is supported for another two and a half years after all!

Sure. However, the current situation has been tolerated for all of that and then some; and for the huge majority who are not using older Pythons on Windows, I'd have a much higher degree of confidence in the standard library's temporary-directory implementation than in a home-grown implementation .

So I do think it would be preferable in general to use TemporaryDirectory(). I don't have very strong opinions about whether Windows with python 3.8 and 3.9 are important; but IMO it would at least be not absurd to choose to keep poetry code simple and decline to fix this for them.

I would agree about simplicity for certain, but I'm going to disagree with you about the scope of the problem. I've personally wasted several days of my life rerunning CI because of this issue, and there are plenty of other people on the original thread who have had the same experience for the last four years (I've only been using poetry 'in anger' for the last year or so).

Windows may be a minority for open-source developers, but for casual python users it's vastly the most common OS, and to have a project like poetry deprioritise fixes for windows specific bugs with in-support python versions seems slightly unfriendly.

da1910 avatar Apr 27 '23 11:04 da1910

So perhaps the implementation of temporary_directory() should go: "if python >= 3.10 then use TemporaryDirectory(ignore_cleanup_errors=True), else do this much more complicated thing"

This is the solution I would go for and which is the most likely going to be accepted.

Secrus avatar Apr 27 '23 12:04 Secrus

"unfriendly" isn't the aim, more like "pragmatic"!

Windows makes up less than 3% of poetry's downloads according to https://pypistats.org/packages/poetry - bottom of page. This is surely a very imperfect measure but, so far as I know, the best we have.

I don't know how to split this up by python version, and I certainly don't know how to split this up by "open-source developers" vs "casual users". Either way I suppose it's true that 3% of poetry's users today is a larger absolute number than 3% of poetry's users was in 2019.

Anyway: if maintainers prefer to take on the additional complication, I've no fight to pick with that.

dimbleby avatar Apr 27 '23 14:04 dimbleby

re the typing errors in the pipeline: so far as I can see no-one ever passes any arguments to temporary_directory(), so I'd just remove the args and kwargs altogether.

dimbleby avatar Apr 27 '23 14:04 dimbleby

re the typing errors in the pipeline: so far as I can see no-one ever passes any arguments to temporary_directory(), so I'd just remove the args and kwargs altogether.

I saw this message too late, spent a bit of time fighting with mypy and in the end just added the argument to kwargs before calling the function, seemed to please mypy.

eblis avatar Apr 27 '23 15:04 eblis

Windows makes up less than 3% of poetry's downloads according to https://pypistats.org/packages/poetry

but maybe this analysis about this number could be a bit biased ... because poetry would be used more by devs and on CI ... the experience programming on windows is not that great ... so probably most python dev doesn't use windows (IMHO) ... and if we it is not working on CI using windows, no one is testing their packages with poetry for windows. (that is my case)

so I guess that this number makes sense. but maybe if the poetry works well for windows .. that number will increase (at least a bit)

xmnlab avatar Apr 27 '23 15:04 xmnlab

and just as an extra info, on conda/conda-forge the downloads for windows is almost the same number for osx (for the latest version there): https://anaconda.org/conda-forge/poetry/files

xmnlab avatar Apr 27 '23 15:04 xmnlab

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Apr 30 '23 11:04 sonarqubecloud[bot]