From 48f463f1732d7803333e52b4f78ba136907b15bb Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 29 Jan 2022 13:11:23 -0500 Subject: [PATCH] Rely on 'session' context when building wheel and sdist. Fixes #3059. --- setup.cfg | 1 - setuptools/tests/contexts.py | 13 ------------- setuptools/tests/fixtures.py | 32 ++++++++++++-------------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/setup.cfg b/setup.cfg index 0dc9043866b..4e31dc1d49e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,7 +64,6 @@ testing = sphinx>=4.3.2 jaraco.path>=3.2.0 build[virtualenv] - filelock>=3.4.0 pip_run>=8.8 testing-integration = diff --git a/setuptools/tests/contexts.py b/setuptools/tests/contexts.py index 5316e599c53..51ce8984e04 100644 --- a/setuptools/tests/contexts.py +++ b/setuptools/tests/contexts.py @@ -7,7 +7,6 @@ import io import pkg_resources -from filelock import FileLock @contextlib.contextmanager @@ -97,15 +96,3 @@ def suppress_exceptions(*excs): yield except excs: pass - - -@contextlib.contextmanager -def session_locked_tmp_dir(tmp_path_factory, name): - """Uses a file lock to guarantee only one worker can access a temp dir""" - root_tmp_dir = tmp_path_factory.getbasetemp().parent - # ^-- get the temp directory shared by all workers - locked_dir = root_tmp_dir / name - with FileLock(locked_dir.with_suffix(".lock")): - # ^-- prevent multiple workers to access the directory at once - locked_dir.mkdir(exist_ok=True, parents=True) - yield locked_dir diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py index 9b91d7d712e..777bb9f03ba 100644 --- a/setuptools/tests/fixtures.py +++ b/setuptools/tests/fixtures.py @@ -64,30 +64,22 @@ def sample_project(tmp_path): @pytest.fixture(scope="session") def setuptools_sdist(tmp_path_factory, request): - with contexts.session_locked_tmp_dir(tmp_path_factory, "sdist_build") as tmp: - dist = next(tmp.glob("*.tar.gz"), None) - if dist: - return dist - - subprocess.check_call([ - sys.executable, "-m", "build", "--sdist", - "--outdir", str(tmp), str(request.config.rootdir) - ]) - return next(tmp.glob("*.tar.gz")) + target = tmp_path_factory.mktemp('sdist_build') + subprocess.check_call([ + sys.executable, "-m", "build", "--sdist", + "--outdir", str(target), str(request.config.rootdir), + ]) + return next(target.glob("*.tar.gz")) @pytest.fixture(scope="session") def setuptools_wheel(tmp_path_factory, request): - with contexts.session_locked_tmp_dir(tmp_path_factory, "wheel_build") as tmp: - dist = next(tmp.glob("*.whl"), None) - if dist: - return dist - - subprocess.check_call([ - sys.executable, "-m", "build", "--wheel", - "--outdir", str(tmp) , str(request.config.rootdir) - ]) - return next(tmp.glob("*.whl")) + target = tmp_path_factory.mktemp('wheel_build') + subprocess.check_call([ + sys.executable, "-m", "build", "--wheel", + "--outdir", str(target) , str(request.config.rootdir) + ]) + return next(target.glob("*.whl")) @pytest.fixture