question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sdist race condition and temp dir customization

See original GitHub issue

Currently 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:closed
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Dec 7, 2017

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”).

0reactions
rainwoodmancommented, Dec 12, 2017

Thanks for the suggestions. I’ll do something along the lines. But this issue I’ll close as it is a wont fix.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found