23
23
class IsolatedEnvironment (_Environment ):
24
24
"""A subclass of ``build.env.IsolatedEnvironment`` to provide rich output for PDM"""
25
25
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
+
26
32
def install (self , requirements : Iterable [str ]) -> None :
27
33
if not requirements :
28
34
return
@@ -64,26 +70,22 @@ def log_subprocessor(cmd, cwd=None, extra_environ=None):
64
70
def build_wheel (src_dir : str , out_dir : str ) -> str :
65
71
"""Build wheel and return the full path of the artifact."""
66
72
builder = ProjectBuilder (srcdir = src_dir )
67
- stream .echo ("Building wheel..." )
68
73
with IsolatedEnvironment .for_current () as env , builder .hook .subprocess_runner (
69
74
log_subprocessor
70
75
):
71
76
env .install (builder .build_dependencies )
72
77
filename = builder .hook .build_wheel (out_dir )
73
- stream .echo (f"Built { filename } " )
74
78
return os .path .join (out_dir , filename )
75
79
76
80
77
81
def build_sdist (src_dir : str , out_dir : str ) -> str :
78
82
"""Build sdist and return the full path of the artifact."""
79
83
builder = ProjectBuilder (srcdir = src_dir )
80
- stream .echo ("Building sdist..." )
81
84
with IsolatedEnvironment .for_current () as env , builder .hook .subprocess_runner (
82
85
log_subprocessor
83
86
):
84
87
env .install (builder .build_dependencies )
85
88
filename = builder .hook .build_sdist (out_dir )
86
- stream .echo (f"Built { filename } " )
87
89
return os .path .join (out_dir , filename )
88
90
89
91
@@ -105,8 +107,6 @@ def build_egg_info(src_dir: str, out_dir: str) -> str:
105
107
env .install (["setuptools" ])
106
108
args = [sys .executable , "-c" , _SETUPTOOLS_SHIM .format (setup_py_path )]
107
109
args .extend (["egg_info" , "--egg-base" , out_dir ])
108
- stream .echo ("Building egg info..." )
109
110
log_subprocessor (args , cwd = src_dir )
110
111
filename = _find_egg_info (out_dir )
111
- stream .echo (f"Built { filename } " )
112
112
return os .path .join (out_dir , filename )
0 commit comments