@@ -27,6 +27,7 @@ def delete_dir(path: pathlib.Path, ignore_errors=None):
2727
2828 shutil .rmtree (os .fspath (path ))
2929
30+
3031@nox .session ()
3132def install_python_libs (session : nox .Session ):
3233 requirements = [
@@ -63,79 +64,6 @@ def install_python_libs(session: nox.Session):
6364 if pathlib .Path ("./python_files/lib/temp" ).exists ():
6465 shutil .rmtree ("./python_files/lib/temp" )
6566
66- @nox .session ()
67- def azure_pet_checkout (session : nox .Session ):
68- branch = os .getenv ("PYTHON_ENV_TOOLS_REF" , "main" )
69-
70- # dest dir should be <vscode-python repo root>/python-env-tools
71- dest_dir = (pathlib .Path (os .getenv ("PYTHON_ENV_TOOLS_DEST" )) / "python-env-tools" ).resolve ()
72-
73- # temp dir should be <agent temp dir>
74- temp_dir = (pathlib .Path (os .getenv ("PYTHON_ENV_TOOLS_TEMP" )) / "python-env-tools" ).resolve ()
75- session .log (f"Cloning python-environment-tools to { temp_dir } " )
76- temp_dir .mkdir (0o766 , parents = True , exist_ok = True )
77-
78- try :
79- with session .cd (temp_dir ):
80- session .run ("git" , "init" , external = True )
81- session .run (
82- "git" ,
83- "remote" ,
84- "add" ,
85- "origin" ,
86- "https://github.com/microsoft/python-environment-tools" ,
87- external = True ,
88- )
89- session .run ("git" , "fetch" , "origin" , branch , external = True )
90- session .run (
91- "git" , "checkout" , "--force" , "-B" , branch , f"origin/{ branch } " , external = True
92- )
93- delete_dir (temp_dir / ".git" )
94- delete_dir (temp_dir / ".github" )
95- delete_dir (temp_dir / ".vscode" )
96- (temp_dir / "CODE_OF_CONDUCT.md" ).unlink ()
97- shutil .move (os .fspath (temp_dir ), os .fspath (dest_dir ))
98- except PermissionError as e :
99- print (f"Permission error: { e } " )
100- if not dest_dir .exists ():
101- raise
102- finally :
103- delete_dir (temp_dir , ignore_errors = True )
104-
105-
106- @nox .session ()
107- def azure_pet_build_before (session : nox .Session ):
108- source_dir = pathlib .Path (pathlib .Path .cwd () / "python-env-tools" ).resolve ()
109- config_toml_disabled = source_dir / ".cargo" / "config.toml.disabled"
110- config_toml = source_dir / ".cargo" / "config.toml"
111- if config_toml_disabled .exists () and not config_toml .exists ():
112- config_toml .write_bytes (config_toml_disabled .read_bytes ())
113-
114-
115- @nox .session ()
116- def azure_pet_build_after (session : nox .Session ):
117- source_dir = pathlib .Path (pathlib .Path .cwd () / "python-env-tools" ).resolve ()
118- ext = sysconfig .get_config_var ("EXE" ) or ""
119- bin_name = f"pet{ ext } "
120-
121- abs_bin_path = None
122- for root , _ , files in os .walk (os .fspath (source_dir / "target" )):
123- bin_path = pathlib .Path (root ) / "release" / bin_name
124- if bin_path .exists ():
125- abs_bin_path = bin_path .absolute ()
126- break
127-
128- assert abs_bin_path
129-
130- dest_dir = pathlib .Path (pathlib .Path .cwd () / "python-env-tools" ).resolve ()
131- if not pathlib .Path (dest_dir / "bin" ).exists ():
132- pathlib .Path (dest_dir / "bin" ).mkdir ()
133- bin_dest = dest_dir / "bin" / bin_name
134- shutil .copyfile (abs_bin_path , bin_dest )
135-
136- if sys .platform != "win32" :
137- os .chmod (os .fspath (bin_dest ), 0o755 )
138-
13967
14068@nox .session ()
14169def native_build (session : nox .Session ):
0 commit comments