Skip to content

Commit 2486463

Browse files
authored
Merge pull request #156 from frostming/parallel_install
fix parallel installation
2 parents a607fbb + 633b044 commit 2486463

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
pip install .
4242
- name: Install Dev Dependencies
4343
run: |
44-
pdm config set parallel_install false
4544
pdm install -dvv
4645
- name: Run Tests
4746
run: pdm run pytest -n auto tests

news/156.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that installation in parallel will cause encoding initialization error on Ubuntu.

pdm/cli/actions.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,13 @@ def do_build(
337337
shutil.rmtree(dest, ignore_errors=True)
338338
with project.environment.activate(True), cd(project.root), stream.logging("build"):
339339
if sdist:
340-
build_sdist(".", dest)
340+
stream.echo("Building sdist...")
341+
loc = build_sdist(".", dest)
342+
stream.echo(f"Built sdist at {loc}")
341343
if wheel:
342-
build_wheel(".", dest)
344+
stream.echo("Building wheel...")
345+
loc = build_wheel(".", dest)
346+
stream.echo(f"Built wheel at {loc}")
343347

344348

345349
def do_init(

pdm/models/builders.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
class IsolatedEnvironment(_Environment):
2424
"""A subclass of ``build.env.IsolatedEnvironment`` to provide rich output for PDM"""
2525

26+
def __enter__(self) -> "IsolatedEnvironment":
27+
inst = super().__enter__()
28+
# Setting PYTHONHOME will cause encoding initialization error in threads.
29+
os.environ.pop("PYTHONHOME", None)
30+
return inst
31+
2632
def install(self, requirements: Iterable[str]) -> None:
2733
if not requirements:
2834
return
@@ -64,26 +70,22 @@ def log_subprocessor(cmd, cwd=None, extra_environ=None):
6470
def build_wheel(src_dir: str, out_dir: str) -> str:
6571
"""Build wheel and return the full path of the artifact."""
6672
builder = ProjectBuilder(srcdir=src_dir)
67-
stream.echo("Building wheel...")
6873
with IsolatedEnvironment.for_current() as env, builder.hook.subprocess_runner(
6974
log_subprocessor
7075
):
7176
env.install(builder.build_dependencies)
7277
filename = builder.hook.build_wheel(out_dir)
73-
stream.echo(f"Built {filename}")
7478
return os.path.join(out_dir, filename)
7579

7680

7781
def build_sdist(src_dir: str, out_dir: str) -> str:
7882
"""Build sdist and return the full path of the artifact."""
7983
builder = ProjectBuilder(srcdir=src_dir)
80-
stream.echo("Building sdist...")
8184
with IsolatedEnvironment.for_current() as env, builder.hook.subprocess_runner(
8285
log_subprocessor
8386
):
8487
env.install(builder.build_dependencies)
8588
filename = builder.hook.build_sdist(out_dir)
86-
stream.echo(f"Built {filename}")
8789
return os.path.join(out_dir, filename)
8890

8991

@@ -105,8 +107,6 @@ def build_egg_info(src_dir: str, out_dir: str) -> str:
105107
env.install(["setuptools"])
106108
args = [sys.executable, "-c", _SETUPTOOLS_SHIM.format(setup_py_path)]
107109
args.extend(["egg_info", "--egg-base", out_dir])
108-
stream.echo("Building egg info...")
109110
log_subprocessor(args, cwd=src_dir)
110111
filename = _find_egg_info(out_dir)
111-
stream.echo(f"Built {filename}")
112112
return os.path.join(out_dir, filename)

0 commit comments

Comments
 (0)