Skip to content

Commit 4d58411

Browse files
authored
Fix issues with localization and signing (#23939)
Fixes microsoft/python-environment-tools#139 Related #23926
1 parent aa2825b commit 4d58411

File tree

3 files changed

+77
-67
lines changed

3 files changed

+77
-67
lines changed

build/azure-pipeline.pre-release.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ resources:
1818
ref: main
1919
endpoint: Monaco
2020

21-
- repository: python-environment-tools
22-
type: github
23-
name: microsoft/python-environment-tools
24-
ref: main
25-
endpoint: Monaco
26-
27-
2821
parameters:
2922
- name: publishExtension
3023
displayName: 🚀 Publish Extension
@@ -38,11 +31,7 @@ extends:
3831
ghCreateTag: false
3932
standardizedVersioning: true
4033
l10nSourcePaths: ./src/client
41-
sourceRepositoriesToScan:
42-
include:
43-
- repository: python-environment-tools
44-
exclude:
45-
- repository: translations
34+
needsTools: true
4635

4736
buildPlatforms:
4837
- name: Linux
@@ -76,10 +65,6 @@ extends:
7665
vsceTarget: win32-x64
7766

7867
buildSteps:
79-
- checkout: self
80-
displayName: Checkout Python Extension
81-
path: ./s
82-
8368
- task: NodeTool@0
8469
inputs:
8570
versionSpec: '18.17.1'
@@ -104,9 +89,6 @@ extends:
10489
- script: nox --session install_python_libs
10590
displayName: Install Jedi, get-pip, etc
10691

107-
# - script: python ./build/update_ext_version.py --for-publishing
108-
# displayName: Update build number
109-
11092
- script: python ./build/update_package_file.py
11193
displayName: Update telemetry in package.json
11294

@@ -116,9 +98,12 @@ extends:
11698
- script: npx gulp prePublishBundle
11799
displayName: Build
118100

119-
- checkout: python-environment-tools
101+
- script: nox --session azure_pet_checkout
120102
displayName: Checkout python-environment-tools
121-
path: ./s/python-env-tools
103+
env:
104+
PYTHON_ENV_TOOLS_DEST: $(Build.SourcesDirectory)
105+
PYTHON_ENV_TOOLS_REF: main
106+
PYTHON_ENV_TOOLS_TEMP: $(Agent.TempDirectory)
122107

123108
- script: nox --session azure_pet_build_before
124109
displayName: Enable cargo config for azure

build/azure-pipeline.stable.yml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ resources:
1414
ref: main
1515
endpoint: Monaco
1616

17-
- repository: python-environment-tools
18-
type: github
19-
name: microsoft/python-environment-tools
20-
ref: release/latest
21-
endpoint: Monaco
22-
2317
parameters:
2418
- name: publishExtension
2519
displayName: 🚀 Publish Extension
@@ -31,11 +25,7 @@ extends:
3125
parameters:
3226
publishExtension: ${{ parameters.publishExtension }}
3327
l10nSourcePaths: ./src/client
34-
sourceRepositoriesToScan:
35-
include:
36-
- repository: python-environment-tools
37-
exclude:
38-
- repository: translations
28+
needsTools: true
3929

4030
buildPlatforms:
4131
- name: Linux
@@ -69,10 +59,6 @@ extends:
6959
vsceTarget: win32-x64
7060

7161
buildSteps:
72-
- checkout: self
73-
displayName: Checkout Python Extension
74-
path: ./s
75-
7662
- task: NodeTool@0
7763
inputs:
7864
versionSpec: '18.17.1'
@@ -106,9 +92,12 @@ extends:
10692
- script: npx gulp prePublishBundle
10793
displayName: Build
10894

109-
- checkout: python-environment-tools
95+
- script: nox --session azure_pet_checkout
11096
displayName: Checkout python-environment-tools
111-
path: ./s/python-env-tools
97+
env:
98+
PYTHON_ENV_TOOLS_DEST: $(Build.SourcesDirectory)
99+
PYTHON_ENV_TOOLS_REF: release/2024.12
100+
PYTHON_ENV_TOOLS_TEMP: $(Agent.TempDirectory)
112101

113102
- script: nox --session azure_pet_build_before
114103
displayName: Enable cargo config for azure

noxfile.py

Lines changed: 65 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
EXT_ROOT = pathlib.Path(__file__).parent
1313

1414

15+
def delete_dir(path: pathlib.Path, ignore_errors=None):
16+
attempt = 0
17+
known = []
18+
while attempt < 5:
19+
try:
20+
shutil.rmtree(os.fspath(path), ignore_errors=ignore_errors)
21+
return
22+
except PermissionError as pe:
23+
if os.fspath(pe.filename) in known:
24+
break
25+
print(f"Changing permissions on {pe.filename}")
26+
os.chmod(pe.filename, 0o666)
27+
28+
shutil.rmtree(os.fspath(path))
29+
1530
@nox.session()
1631
def install_python_libs(session: nox.Session):
1732
requirements = [
@@ -48,6 +63,45 @@ def install_python_libs(session: nox.Session):
4863
if pathlib.Path("./python_files/lib/temp").exists():
4964
shutil.rmtree("./python_files/lib/temp")
5065

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+
51105

52106
@nox.session()
53107
def azure_pet_build_before(session: nox.Session):
@@ -132,37 +186,19 @@ def native_build(session: nox.Session):
132186
vscode_ignore.write_text("\n".join(filtered_lines) + "\n", encoding="utf-8")
133187

134188

135-
def delete_dir(path: pathlib.Path, ignore_errors=None):
136-
attempt = 0
137-
known = []
138-
while attempt < 5:
139-
try:
140-
shutil.rmtree(os.fspath(path), ignore_errors=ignore_errors)
141-
return
142-
except PermissionError as pe:
143-
if os.fspath(pe.filename) in known:
144-
break
145-
print(f"Changing permissions on {pe.filename}")
146-
os.chmod(pe.filename, 0o666)
147-
148-
shutil.rmtree(os.fspath(path))
149-
150-
151189
@nox.session()
152190
def checkout_native(session: nox.Session):
153191
dest = (pathlib.Path.cwd() / "python-env-tools").resolve()
154192
if dest.exists():
155193
shutil.rmtree(os.fspath(dest))
156194

157-
tempdir = os.getenv("TEMP") or os.getenv("TMP") or "/tmp"
158-
tempdir = pathlib.Path(tempdir) / str(uuid.uuid4()) / "python-env-tools"
159-
tempdir.mkdir(0o666, parents=True)
160-
161-
session.log(f"Temp dir: {tempdir}")
195+
temp_dir = os.getenv("TEMP") or os.getenv("TMP") or "/tmp"
196+
temp_dir = pathlib.Path(temp_dir) / str(uuid.uuid4()) / "python-env-tools"
197+
temp_dir.mkdir(0o766, parents=True)
162198

163-
session.log(f"Cloning python-environment-tools to {tempdir}")
199+
session.log(f"Cloning python-environment-tools to {temp_dir}")
164200
try:
165-
with session.cd(tempdir):
201+
with session.cd(temp_dir):
166202
session.run("git", "init", external=True)
167203
session.run(
168204
"git",
@@ -176,17 +212,17 @@ def checkout_native(session: nox.Session):
176212
session.run(
177213
"git", "checkout", "--force", "-B", "main", "origin/main", external=True
178214
)
179-
delete_dir(tempdir / ".git")
180-
delete_dir(tempdir / ".github")
181-
delete_dir(tempdir / ".vscode")
182-
(tempdir / "CODE_OF_CONDUCT.md").unlink()
183-
shutil.move(os.fspath(tempdir), os.fspath(dest))
215+
delete_dir(temp_dir / ".git")
216+
delete_dir(temp_dir / ".github")
217+
delete_dir(temp_dir / ".vscode")
218+
(temp_dir / "CODE_OF_CONDUCT.md").unlink()
219+
shutil.move(os.fspath(temp_dir), os.fspath(dest))
184220
except PermissionError as e:
185221
print(f"Permission error: {e}")
186222
if not dest.exists():
187223
raise
188224
finally:
189-
delete_dir(tempdir.parent, ignore_errors=True)
225+
delete_dir(temp_dir.parent, ignore_errors=True)
190226

191227

192228
@nox.session()

0 commit comments

Comments
 (0)