From ac6cf9cc2331dda5ecf2f37e1de73f7ac53e8ee6 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Tue, 9 May 2023 17:47:09 +0800 Subject: [PATCH] fix: the PATH env isn't set correctly under no-build-isolation Signed-off-by: Frost Ming --- src/pdm/builders/base.py | 7 +++++-- src/pdm/cli/options.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pdm/builders/base.py b/src/pdm/builders/base.py index 60705bd759..b663bc2556 100644 --- a/src/pdm/builders/base.py +++ b/src/pdm/builders/base.py @@ -226,7 +226,7 @@ def _env_vars(self) -> dict[str, str]: paths = self._prefix.bin_dirs if "PATH" in os.environ: paths.append(os.getenv("PATH", "")) - env = {"PATH": os.pathsep.join(paths)} + env: dict[str, str] = {} if self.isolated: env.update( { @@ -235,13 +235,16 @@ def _env_vars(self) -> dict[str, str]: } ) else: - project_libs = self._env.get_paths()["purelib"] + env_paths = self._env.get_paths() + project_libs = env_paths["purelib"] pythonpath = [*self._prefix.lib_dirs, project_libs] if "PYTHONPATH" in os.environ: pythonpath.append(os.getenv("PYTHONPATH", "")) env.update( PYTHONPATH=os.pathsep.join(pythonpath), ) + paths.append(env_paths["scripts"]) + env["PATH"] = os.pathsep.join(paths) return env def subprocess_runner( diff --git a/src/pdm/cli/options.py b/src/pdm/cli/options.py index 62b94a4701..e0bce0ad79 100644 --- a/src/pdm/cli/options.py +++ b/src/pdm/cli/options.py @@ -163,8 +163,9 @@ def pep582_option(project: Project, namespace: argparse.Namespace, values: str | install_group.add_argument( "--no-self", action="store_true", + default=bool(os.getenv("PDM_NO_SELF")), dest="no_self", - help="Don't install the project itself", + help="Don't install the project itself. [env var: PDM_NO_SELF]", ) install_group.add_argument("--fail-fast", "-x", action="store_true", help="Abort on first installation error")