Skip to content

Commit

Permalink
Introduce options.pythonVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Oct 13, 2023
1 parent 3a7d08a commit 87c5276
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
10 changes: 6 additions & 4 deletions extensions-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"type": "number",
"description": "Timeout to build the extension vsix from sources."
},
"pythonVersion": {
"type": "string",
"description": "Python version to use with this build."
},
"msMarketplaceIdOverride": {
"type": "string",
"description": "A property to set a different lookup ID when querying the Microsoft Marketplace. Please do not ever use if not absolutely necessary."
Expand All @@ -43,9 +47,7 @@
"minItems": 1
}
},
"required": [
"repository"
],
"required": ["repository"],
"additionalProperties": false
}
}
}
8 changes: 4 additions & 4 deletions extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,15 +808,14 @@
},
"ms-python.isort": {
"repository": "https://github.com/microsoft/vscode-isort",
"pythonVersion": "3.7",
"custom": [
"pyenv install -s 3.7 && pyenv global 3.7",
"python -m pip install -U pip",
"python -m pip install wheel",
"python -m pip install nox",
"npm ci --prefer-offline",
"python -m nox --session install_bundled_libs",
"npm run vsce-package",
"pyenv global 3.8"
"npm run vsce-package"
],
"extensionFile": "isort.vsix"
},
Expand Down Expand Up @@ -846,8 +845,9 @@
},
"ms-python.python": {
"repository": "https://github.com/microsoft/vscode-python",
"prepublish": "npx gulp installPythonLibs && python3 ./pythonFiles/install_debugpy.py && python3 ./build/update_ext_version.py --release --for-publishing && npm run addExtensionPackDependencies && DISABLE_TRANSLATIONS=true npm run package",
"prepublish": "npx gulp installPythonLibs && python3 -m pip --disable-pip-version-check install packaging && python3 ./pythonFiles/install_debugpy.py && python3 ./pythonFiles/download_get_pip.py && python3 ./build/update_ext_version.py --release --for-publishing && npm run addExtensionPackDependencies && DISABLE_TRANSLATIONS=true npm run package",
"extensionFile": "ms-python-insiders.vsix",
"pythonVersion": "3.8",
"timeout": 30
},
"ms-toolsai.jupyter": {
Expand Down
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
artifactDirectory: "/tmp/artifacts",
registryHost: "open-vsx.org",
repoPath: "/tmp/repository/main"
repoPath: "/tmp/repository/main",
defaultPythonVersion: "3.8"
}
14 changes: 12 additions & 2 deletions publish-extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2022 TypeFox and others
* Copyright (c) 2023 TypeFox and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -23,7 +23,7 @@ const { cannotPublish } = require('./lib/reportStat');

const { PublicGalleryAPI } = require('@vscode/vsce/out/publicgalleryapi');
const { PublishedExtension } = require('azure-devops-node-api/interfaces/GalleryInterfaces');
const { artifactDirectory, registryHost } = require('./lib/constants');
const { artifactDirectory, registryHost, defaultPythonVersion } = require('./lib/constants');

const vscodeBuiltinExtensionsNamespace = "vscode";
const isBuiltIn = (id) => id.split(".")[0] === vscodeBuiltinExtensionsNamespace;
Expand Down Expand Up @@ -71,6 +71,11 @@ openGalleryApi.post = (url, data, additionalHeaders) =>
// If the project has a preferred Node version, use it
await exec("source ~/.nvm/nvm.sh && nvm install", { cwd: path.join(context.repo, extension.location ?? '.'), quiet: true });
}

if (extension.pythonVersion) {
console.debug("Installing appropriate Python version...")
await exec(`pyenv install -s ${extension.pythonVersion} && pyenv global ${extension.pythonVersion}`, { cwd: path.join(context.repo, extension.location ?? '.'), quiet: false })
}
} catch { }

if (extension.custom) {
Expand Down Expand Up @@ -231,5 +236,10 @@ openGalleryApi.post = (url, data, additionalHeaders) =>
console.error(error);
process.exitCode = 1;
}
} finally {
// Clean up
if (extension.pythonVersion) {
await exec(`pyenv global ${defaultPythonVersion}`)
}
}
})();
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface Extension {
timeout?: number
target?: string[]
msMarketplaceIdOverride?: string
pythonVersion?: string;
}

export interface ExtensionResolution {
Expand Down

0 comments on commit 87c5276

Please sign in to comment.