Skip to content

Commit 34dac5c

Browse files
authored
Stable extension builds using pet from Azure Feed (#24063)
1 parent 223eca9 commit 34dac5c

File tree

2 files changed

+25
-94
lines changed

2 files changed

+25
-94
lines changed

build/azure-pipeline.stable.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,30 @@ extends:
9292
- script: npx gulp prePublishBundle
9393
displayName: Build
9494

95-
- script: nox --session azure_pet_checkout
96-
displayName: Checkout python-environment-tools
97-
env:
98-
PYTHON_ENV_TOOLS_DEST: $(Build.SourcesDirectory)
99-
PYTHON_ENV_TOOLS_REF: release/2024.14
100-
PYTHON_ENV_TOOLS_TEMP: $(Agent.TempDirectory)
101-
102-
- script: nox --session azure_pet_build_before
103-
displayName: Enable cargo config for azure
104-
105-
- template: azure-pipelines/extension/templates/steps/build-extension-rust-package.yml@templates
106-
parameters:
107-
vsceTarget: $(vsceTarget)
108-
binaryName: pet
109-
signing: true
110-
workingDirectory: $(Build.SourcesDirectory)/python-env-tools
111-
buildWasm: false
112-
runTest: false
113-
114-
- script: nox --session azure_pet_build_after
115-
displayName: Move bin to final location
95+
- bash: |
96+
mkdir -p $(Build.SourcesDirectory)/python-env-tools/bin
97+
chmod +x $(Build.SourcesDirectory)/python-env-tools/bin
98+
displayName: Make Directory for python-env-tool binary
99+
100+
- task: DownloadPipelineArtifact@2
101+
inputs:
102+
buildType: 'specific'
103+
project: 'Monaco'
104+
definition: 593
105+
buildVersionToDownload: 'latestFromBranch'
106+
branchName: 'refs/heads/release/2024.14'
107+
targetPath: '$(Build.SourcesDirectory)/python-env-tools/bin'
108+
artifactName: 'bin-$(vsceTarget)'
109+
itemPattern: |
110+
pet.exe
111+
pet
112+
ThirdPartyNotices.txt
113+
114+
- bash: |
115+
ls -lf ./python-env-tools/bin
116+
chmod +x ./python-env-tools/bin/pet*
117+
ls -lf ./python-env-tools/bin
118+
displayName: Set chmod for pet binary
116119
117120
- script: python -c "import shutil; shutil.rmtree('.nox', ignore_errors=True)"
118121
displayName: Clean up Nox

noxfile.py

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -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()
3132
def 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()
14169
def native_build(session: nox.Session):

0 commit comments

Comments
 (0)