From 122b23ae05ca3f50a23dd9b9552c0a1b48977991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Tue, 14 Nov 2023 09:45:56 +0100 Subject: [PATCH] Start wheel build from an empty directory Start build from an empty directory, to avoid accidentally importing python files from the addon root directory during the build process. --- newsfragments/270.bugfix | 2 ++ src/oca_github_bot/build_wheels.py | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 newsfragments/270.bugfix diff --git a/newsfragments/270.bugfix b/newsfragments/270.bugfix new file mode 100644 index 00000000..4a0d5cc4 --- /dev/null +++ b/newsfragments/270.bugfix @@ -0,0 +1,2 @@ +Start wheel build from an empty directory, to avoid accidentally importing +python files from the addon root directory during the build process. diff --git a/src/oca_github_bot/build_wheels.py b/src/oca_github_bot/build_wheels.py index 4c1e6708..818f870c 100644 --- a/src/oca_github_bot/build_wheels.py +++ b/src/oca_github_bot/build_wheels.py @@ -45,18 +45,22 @@ def __init__(self): ) def build_wheel(self, project_dir: Path, dist_dir: str) -> None: - check_call( - [ - self.env_python, - "-m", - "build", - "--wheel", - "--outdir", - dist_dir, - "--no-isolation", - ], - cwd=project_dir, - ) + with tempfile.TemporaryDirectory() as empty_dir: + # Start build from an empty directory, to avoid accidentally importing + # python files from the addon root directory during the build process. + check_call( + [ + self.env_python, + "-m", + "build", + "--wheel", + "--outdir", + dist_dir, + "--no-isolation", + project_dir, + ], + cwd=empty_dir, + ) self._check_wheels(dist_dir) return True