未验证 提交 5d6b9b6a 编写于 作者: F Frost Ming

fix parallel installation

上级 a607fbbd
......@@ -41,7 +41,6 @@ jobs:
pip install .
- name: Install Dev Dependencies
run: |
pdm config set parallel_install false
pdm install -dvv
- name: Run Tests
run: pdm run pytest -n auto tests
......@@ -337,9 +337,13 @@ def do_build(
shutil.rmtree(dest, ignore_errors=True)
with project.environment.activate(True), cd(project.root), stream.logging("build"):
if sdist:
build_sdist(".", dest)
stream.echo("Building sdist...")
loc = build_sdist(".", dest)
stream.echo(f"Built sdist at {loc}")
if wheel:
build_wheel(".", dest)
stream.echo("Building wheel...")
loc = build_wheel(".", dest)
stream.echo(f"Built wheel at {loc}")
def do_init(
......
......@@ -23,6 +23,12 @@ _SETUPTOOLS_SHIM = (
class IsolatedEnvironment(_Environment):
"""A subclass of ``build.env.IsolatedEnvironment`` to provide rich output for PDM"""
def __enter__(self) -> "IsolatedEnvironment":
inst = super().__enter__()
# Setting PYTHONHOME will cause encoding initialization error in threads.
os.environ.pop("PYTHONHOME", None)
return inst
def install(self, requirements: Iterable[str]) -> None:
if not requirements:
return
......@@ -64,26 +70,22 @@ def log_subprocessor(cmd, cwd=None, extra_environ=None):
def build_wheel(src_dir: str, out_dir: str) -> str:
"""Build wheel and return the full path of the artifact."""
builder = ProjectBuilder(srcdir=src_dir)
stream.echo("Building wheel...")
with IsolatedEnvironment.for_current() as env, builder.hook.subprocess_runner(
log_subprocessor
):
env.install(builder.build_dependencies)
filename = builder.hook.build_wheel(out_dir)
stream.echo(f"Built {filename}")
return os.path.join(out_dir, filename)
def build_sdist(src_dir: str, out_dir: str) -> str:
"""Build sdist and return the full path of the artifact."""
builder = ProjectBuilder(srcdir=src_dir)
stream.echo("Building sdist...")
with IsolatedEnvironment.for_current() as env, builder.hook.subprocess_runner(
log_subprocessor
):
env.install(builder.build_dependencies)
filename = builder.hook.build_sdist(out_dir)
stream.echo(f"Built {filename}")
return os.path.join(out_dir, filename)
......@@ -105,8 +107,6 @@ def build_egg_info(src_dir: str, out_dir: str) -> str:
env.install(["setuptools"])
args = [sys.executable, "-c", _SETUPTOOLS_SHIM.format(setup_py_path)]
args.extend(["egg_info", "--egg-base", out_dir])
stream.echo("Building egg info...")
log_subprocessor(args, cwd=src_dir)
filename = _find_egg_info(out_dir)
stream.echo(f"Built {filename}")
return os.path.join(out_dir, filename)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册