sdist race condition and temp dir customization
See original GitHub issueCurrently if two sdist commands are ran at the same time there is a race condition. One sdist command can be purging the temp files under {packagename}-{packageversion} in the setup.py directory while the other is zipping it, causing error messages like this
Creating tar archive
removing 'cosmo4d-0.0.0' (and everything under it)
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/setup.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/tests/test_engine.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/tests/test_pmesh.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/tests/test_map2d.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/tests'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/iotools.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/pmeshengine.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/__init__.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/version.py'
error removing cosmo4d-0.0.0: [Errno 2] No such file or directory: 'cosmo4d-0.0.0/cosmo4d/options.py'
Processing /tmp/VlnJRkP/cosmo4d-0.0.0.tar.gz
Skipping bdist_wheel for cosmo4d, due to binaries being disabled for it.
One possible solution to avoid the racing is to allow an argument --temproot to allow redirection of the temp directory to a different location. Then the caller to setup.py (or sdist itself) can use mktemp -d
to avoid building sdist from the same temp dir; or at least to minimize the chances of racing.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Race Conditions in /tmp
Race Conditions in /tmp. Another very common problem involves the creation of files with predictable names, typically in the /tmp directory.
Read more >distutils-r1 — standard Python build systems
The distutils build system has a major unresolved bug regarding race conditions. If the same source file is used to build multiple Python...
Read more >History - setuptools 65.6.3.post20221216 documentation
#1083: Avoid race condition on directory creation in pkg_resources.ensure_directory . Removed deprecation of and restored support for upload_docs command ...
Read more >Possible to create python sdist from different directory?
So I generate a setup.py and MANIFEST.in (with recursive-include * to grab all files) in a python tempfile.mkdtemp directory (in an unrelated ...
Read more >10.5. tempfile — Generate temporary files and directories - Python ...
This function creates a temporary directory using mkdtemp() (the supplied arguments are passed ... There are no race conditions in the directory's creation....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Threads aren’t the only way to access and API concurrently (processes?). The proposed “global setuptools lock” would be file-based to prevent concurrent access by multiple processes as well. That said, this isn’t something that is going to even matter in setuptools because a frontend will be doing the locking.
The point is that running any distutils command concurrently for the same setup.py is not supported. In addition, there is no way that it could be supported because setuptools is simply wrapping other people’s scripts that aren’t thread-safe (which yes, includes “processes”).
Thanks for the suggestions. I’ll do something along the lines. But this issue I’ll close as it is a wont fix.