Stable extension builds using `pet` from Azure Feed (#24063)

This commit is contained in:
Karthik Nadig 2024-09-06 10:48:39 -07:00 коммит произвёл GitHub
Родитель 223eca9194
Коммит 34dac5c874
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 23 добавлений и 92 удалений

Просмотреть файл

@ -92,27 +92,30 @@ extends:
- script: npx gulp prePublishBundle
displayName: Build
- script: nox --session azure_pet_checkout
displayName: Checkout python-environment-tools
env:
PYTHON_ENV_TOOLS_DEST: $(Build.SourcesDirectory)
PYTHON_ENV_TOOLS_REF: release/2024.14
PYTHON_ENV_TOOLS_TEMP: $(Agent.TempDirectory)
- bash: |
mkdir -p $(Build.SourcesDirectory)/python-env-tools/bin
chmod +x $(Build.SourcesDirectory)/python-env-tools/bin
displayName: Make Directory for python-env-tool binary
- script: nox --session azure_pet_build_before
displayName: Enable cargo config for azure
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'specific'
project: 'Monaco'
definition: 593
buildVersionToDownload: 'latestFromBranch'
branchName: 'refs/heads/release/2024.14'
targetPath: '$(Build.SourcesDirectory)/python-env-tools/bin'
artifactName: 'bin-$(vsceTarget)'
itemPattern: |
pet.exe
pet
ThirdPartyNotices.txt
- template: azure-pipelines/extension/templates/steps/build-extension-rust-package.yml@templates
parameters:
vsceTarget: $(vsceTarget)
binaryName: pet
signing: true
workingDirectory: $(Build.SourcesDirectory)/python-env-tools
buildWasm: false
runTest: false
- script: nox --session azure_pet_build_after
displayName: Move bin to final location
- bash: |
ls -lf ./python-env-tools/bin
chmod +x ./python-env-tools/bin/pet*
ls -lf ./python-env-tools/bin
displayName: Set chmod for pet binary
- script: python -c "import shutil; shutil.rmtree('.nox', ignore_errors=True)"
displayName: Clean up Nox

Просмотреть файл

@ -27,6 +27,7 @@ def delete_dir(path: pathlib.Path, ignore_errors=None):
shutil.rmtree(os.fspath(path))
@nox.session()
def install_python_libs(session: nox.Session):
requirements = [
@ -63,79 +64,6 @@ def install_python_libs(session: nox.Session):
if pathlib.Path("./python_files/lib/temp").exists():
shutil.rmtree("./python_files/lib/temp")
@nox.session()
def azure_pet_checkout(session: nox.Session):
branch = os.getenv("PYTHON_ENV_TOOLS_REF", "main")
# dest dir should be <vscode-python repo root>/python-env-tools
dest_dir = (pathlib.Path(os.getenv("PYTHON_ENV_TOOLS_DEST")) / "python-env-tools").resolve()
# temp dir should be <agent temp dir>
temp_dir = (pathlib.Path(os.getenv("PYTHON_ENV_TOOLS_TEMP")) / "python-env-tools").resolve()
session.log(f"Cloning python-environment-tools to {temp_dir}")
temp_dir.mkdir(0o766, parents=True, exist_ok=True)
try:
with session.cd(temp_dir):
session.run("git", "init", external=True)
session.run(
"git",
"remote",
"add",
"origin",
"https://github.com/microsoft/python-environment-tools",
external=True,
)
session.run("git", "fetch", "origin", branch, external=True)
session.run(
"git", "checkout", "--force", "-B", branch, f"origin/{branch}", external=True
)
delete_dir(temp_dir / ".git")
delete_dir(temp_dir / ".github")
delete_dir(temp_dir / ".vscode")
(temp_dir / "CODE_OF_CONDUCT.md").unlink()
shutil.move(os.fspath(temp_dir), os.fspath(dest_dir))
except PermissionError as e:
print(f"Permission error: {e}")
if not dest_dir.exists():
raise
finally:
delete_dir(temp_dir, ignore_errors=True)
@nox.session()
def azure_pet_build_before(session: nox.Session):
source_dir = pathlib.Path(pathlib.Path.cwd() / "python-env-tools").resolve()
config_toml_disabled = source_dir / ".cargo" / "config.toml.disabled"
config_toml = source_dir / ".cargo" / "config.toml"
if config_toml_disabled.exists() and not config_toml.exists():
config_toml.write_bytes(config_toml_disabled.read_bytes())
@nox.session()
def azure_pet_build_after(session: nox.Session):
source_dir = pathlib.Path(pathlib.Path.cwd() / "python-env-tools").resolve()
ext = sysconfig.get_config_var("EXE") or ""
bin_name = f"pet{ext}"
abs_bin_path = None
for root, _, files in os.walk(os.fspath(source_dir / "target")):
bin_path = pathlib.Path(root) / "release" / bin_name
if bin_path.exists():
abs_bin_path = bin_path.absolute()
break
assert abs_bin_path
dest_dir = pathlib.Path(pathlib.Path.cwd() / "python-env-tools").resolve()
if not pathlib.Path(dest_dir / "bin").exists():
pathlib.Path(dest_dir / "bin").mkdir()
bin_dest = dest_dir / "bin" / bin_name
shutil.copyfile(abs_bin_path, bin_dest)
if sys.platform != "win32":
os.chmod(os.fspath(bin_dest), 0o755)
@nox.session()
def native_build(session: nox.Session):