Skip to content

Commit

Permalink
Fix issues with localization and signing (#23931)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Aug 8, 2024
1 parent e90b95d commit 20e186f
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 67 deletions.
27 changes: 6 additions & 21 deletions build/azure-pipeline.pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ resources:
ref: main
endpoint: Monaco

- repository: python-environment-tools
type: github
name: microsoft/python-environment-tools
ref: main
endpoint: Monaco


parameters:
- name: publishExtension
displayName: 🚀 Publish Extension
Expand All @@ -38,11 +31,7 @@ extends:
ghCreateTag: false
standardizedVersioning: true
l10nSourcePaths: ./src/client
sourceRepositoriesToScan:
include:
- repository: python-environment-tools
exclude:
- repository: translations
needsTools: true

buildPlatforms:
- name: Linux
Expand Down Expand Up @@ -76,10 +65,6 @@ extends:
vsceTarget: win32-x64

buildSteps:
- checkout: self
displayName: Checkout Python Extension
path: ./s

- task: NodeTool@0
inputs:
versionSpec: '18.17.1'
Expand All @@ -104,9 +89,6 @@ extends:
- script: nox --session install_python_libs
displayName: Install Jedi, get-pip, etc

# - script: python ./build/update_ext_version.py --for-publishing
# displayName: Update build number

- script: python ./build/update_package_file.py
displayName: Update telemetry in package.json

Expand All @@ -116,9 +98,12 @@ extends:
- script: npx gulp prePublishBundle
displayName: Build

- checkout: python-environment-tools
- script: nox --session azure_pet_checkout
displayName: Checkout python-environment-tools
path: ./s/python-env-tools
env:
PYTHON_ENV_TOOLS_DEST: $(Build.SourcesDirectory)
PYTHON_ENV_TOOLS_REF: main
PYTHON_ENV_TOOLS_TEMP: $(Agent.TempDirectory)

- script: nox --session azure_pet_build_before
displayName: Enable cargo config for azure
Expand Down
23 changes: 6 additions & 17 deletions build/azure-pipeline.stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ resources:
ref: main
endpoint: Monaco

- repository: python-environment-tools
type: github
name: microsoft/python-environment-tools
ref: release/2024.12
endpoint: Monaco

parameters:
- name: publishExtension
displayName: 🚀 Publish Extension
Expand All @@ -31,11 +25,7 @@ extends:
parameters:
publishExtension: ${{ parameters.publishExtension }}
l10nSourcePaths: ./src/client
sourceRepositoriesToScan:
include:
- repository: python-environment-tools
exclude:
- repository: translations
needsTools: true

buildPlatforms:
- name: Linux
Expand Down Expand Up @@ -69,10 +59,6 @@ extends:
vsceTarget: win32-x64

buildSteps:
- checkout: self
displayName: Checkout Python Extension
path: ./s

- task: NodeTool@0
inputs:
versionSpec: '18.17.1'
Expand Down Expand Up @@ -106,9 +92,12 @@ extends:
- script: npx gulp prePublishBundle
displayName: Build

- checkout: python-environment-tools
- script: nox --session azure_pet_checkout
displayName: Checkout python-environment-tools
path: ./s/python-env-tools
env:
PYTHON_ENV_TOOLS_DEST: $(Build.SourcesDirectory)
PYTHON_ENV_TOOLS_REF: release/2024.12
PYTHON_ENV_TOOLS_TEMP: $(Agent.TempDirectory)

- script: nox --session azure_pet_build_before
displayName: Enable cargo config for azure
Expand Down
94 changes: 65 additions & 29 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
EXT_ROOT = pathlib.Path(__file__).parent


def delete_dir(path: pathlib.Path, ignore_errors=None):
attempt = 0
known = []
while attempt < 5:
try:
shutil.rmtree(os.fspath(path), ignore_errors=ignore_errors)
return
except PermissionError as pe:
if os.fspath(pe.filename) in known:
break
print(f"Changing permissions on {pe.filename}")
os.chmod(pe.filename, 0o666)

shutil.rmtree(os.fspath(path))

@nox.session()
def install_python_libs(session: nox.Session):
requirements = [
Expand Down Expand Up @@ -48,6 +63,45 @@ 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):
Expand Down Expand Up @@ -132,37 +186,19 @@ def native_build(session: nox.Session):
vscode_ignore.write_text("\n".join(filtered_lines) + "\n", encoding="utf-8")


def delete_dir(path: pathlib.Path, ignore_errors=None):
attempt = 0
known = []
while attempt < 5:
try:
shutil.rmtree(os.fspath(path), ignore_errors=ignore_errors)
return
except PermissionError as pe:
if os.fspath(pe.filename) in known:
break
print(f"Changing permissions on {pe.filename}")
os.chmod(pe.filename, 0o666)

shutil.rmtree(os.fspath(path))


@nox.session()
def checkout_native(session: nox.Session):
dest = (pathlib.Path.cwd() / "python-env-tools").resolve()
if dest.exists():
shutil.rmtree(os.fspath(dest))

tempdir = os.getenv("TEMP") or os.getenv("TMP") or "/tmp"
tempdir = pathlib.Path(tempdir) / str(uuid.uuid4()) / "python-env-tools"
tempdir.mkdir(0o666, parents=True)

session.log(f"Temp dir: {tempdir}")
temp_dir = os.getenv("TEMP") or os.getenv("TMP") or "/tmp"
temp_dir = pathlib.Path(temp_dir) / str(uuid.uuid4()) / "python-env-tools"
temp_dir.mkdir(0o766, parents=True)

session.log(f"Cloning python-environment-tools to {tempdir}")
session.log(f"Cloning python-environment-tools to {temp_dir}")
try:
with session.cd(tempdir):
with session.cd(temp_dir):
session.run("git", "init", external=True)
session.run(
"git",
Expand All @@ -176,17 +212,17 @@ def checkout_native(session: nox.Session):
session.run(
"git", "checkout", "--force", "-B", "main", "origin/main", external=True
)
delete_dir(tempdir / ".git")
delete_dir(tempdir / ".github")
delete_dir(tempdir / ".vscode")
(tempdir / "CODE_OF_CONDUCT.md").unlink()
shutil.move(os.fspath(tempdir), os.fspath(dest))
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))
except PermissionError as e:
print(f"Permission error: {e}")
if not dest.exists():
raise
finally:
delete_dir(tempdir.parent, ignore_errors=True)
delete_dir(temp_dir.parent, ignore_errors=True)


@nox.session()
Expand Down

0 comments on commit 20e186f

Please sign in to comment.