FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-93584: Avoid file race condition in build process by tiran · Pull Request #93586 · python/cpython · GitHub

/ cpython Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion Lib/_bootsubprocess.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
subprocess is unavailable. setup.py is not used on Windows.
"""
import os
import time


# distutils.spawn used by distutils.command.build_ext
Expand Down Expand Up @@ -70,7 +71,9 @@ def check_output(cmd, **kwargs):
if not _check_cmd(cmd):
raise ValueError(f"unsupported command: {cmd!r}")

tmp_filename = "check_output.tmp"
# include pid and time stamp to avoid file name clashes with parallel
# builds.
tmp_filename = f"check_output-{os.getpid()}-{int(time.time() )}.tmp"
if not isinstance(cmd, str):
cmd = " ".join(cmd)
cmd = f"{cmd} >{tmp_filename}"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Avoid file race condition in ``setup.py`` ``add_multiarch_paths()`` method
and ``_bootsubprocess.check_output()`` function.
17 changes: 11 additions & 6 deletions setup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import shlex
import sys
import sysconfig
import time
import warnings
from glob import glob, escape
import _osx_support
Expand Down Expand Up @@ -688,9 +689,15 @@ def check_extension_import(self, ext):
def add_multiarch_paths(self):
# Debian/Ubuntu multiarch support.
# https://wiki.ubuntu.com/MultiarchSpec
tmpfile = os.path.join(self.build_temp, 'multiarch')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)

# Poor man's conflict avoidance. PGO build use $(MAKE), which runs
# make in a separate, untracked process. Sometimes main and subproces
# run `make sharedmods` at the same time. One process removes
# "multiarch" file of the other process.
tmpfile = os.path.join(
self.build_temp, f"multiarch-{os.getpid()}-{int(time.time() )}.tmp"
)
os.makedirs(self.build_temp, exist_ok=True)
ret = run_command(
'%s -print-multiarch > %s 2> /dev/null' % (CC, tmpfile))
multiarch_path_component = ''
Expand All @@ -713,9 +720,7 @@ def add_multiarch_paths(self):
opt = ''
if CROSS_COMPILING:
opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE')
tmpfile = os.path.join(self.build_temp, 'multiarch')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
os.makedirs(self.build_temp, exist_ok=True)
ret = run_command(
'dpkg-architecture %s -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
(opt, tmpfile))
Expand Down

Back | FazBrowse Home | New Git URL