Skip to content

Commit

Permalink
Revert "[UsePythonV0] Download python from registry (#15820)" (#16014)
Browse files Browse the repository at this point in the history
This reverts commit 983849e.
  • Loading branch information
DaniilShmelev authored Mar 10, 2022
1 parent 7eb8528 commit 01337b4
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 718 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"loc.group.displayName.advanced": "Advanced",
"loc.input.label.versionSpec": "Version spec",
"loc.input.help.versionSpec": "Version range or exact version of a Python version to use, using semver's version range syntax. [More information](https://go.microsoft.com/fwlink/?LinkID=2006180)",
"loc.input.label.allowUnstable": "Allow downloading unstable releases",
"loc.input.help.allowUnstable": "Allow downloading unstable python versions from [Github Actions python versions registry](https://github.com/actions/python-versions).",
"loc.input.label.addToPath": "Add to PATH",
"loc.input.help.addToPath": "Whether to prepend the retrieved Python version to the PATH environment variable to make it available in subsequent tasks or scripts without using the output variable.",
"loc.input.label.architecture": "Architecture",
Expand All @@ -18,8 +16,7 @@
"loc.messages.PyPyNotFound": "Could not find an installation of PyPy%d in Agent.ToolsDirectory.",
"loc.messages.ToolNotFoundMicrosoftHosted": "If this is a Microsoft-hosted agent, check that this image supports side-by-side versions of %s at %s.",
"loc.messages.ToolNotFoundSelfHosted": "If this is a self-hosted agent, see how to configure side-by-side %s versions at %s.",
"loc.messages.VersionNotFound": "Version spec %s for architecture %s did not match any version in Agent.ToolsDirectory or in Github Actions python versions registry (https://github.com/actions/python-versions).",
"loc.messages.PythonVersionRetirement": "Python 3.5 has reached its end of life and will be removed from the ms-hosted images on January, 24. Please update Python version if you use ms-hosted agents. For more information about this - https://github.com/actions/virtual-environments",
"loc.messages.DownloadNotFound": "Could not find Python matching spec %s in the python-versions registry. Beware that only systems listed in the Github Actions python versions manifest (https://github.com/actions/python-versions/blob/main/versions-manifest.json) are fit for downloading python on-flight. Also, proxy is not supported.",
"loc.messages.DownloadFailed": "Failed to download Python from the Github Actions python registry (https://github.com/actions/python-versions). Error: %s"
"loc.messages.VersionNotFound": "Version spec %s for architecture %s did not match any version in Agent.ToolsDirectory.",
"loc.messages.ExactVersionNotRecommended": "Specifying an exact version is not recommended on Microsoft-Hosted agents. Patch versions of Python can be replaced by new ones on Hosted agents without notice, which will cause builds to fail unexpectedly. It is recommended to specify only major or major and minor version (Example: `3` or `3.6`)",
"loc.messages.PythonVersionRetirement": "Python 3.5 has reached its end of life and will be removed from the ms-hosted images on January, 24. Please update Python version if you use ms-hosted agents. For more information about this - https://github.com/actions/virtual-environments"
}
56 changes: 2 additions & 54 deletions Tasks/UsePythonVersionV0/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,74 +42,22 @@ describe('UsePythonVersion L0 Suite', function () {
assert(testRunner.succeeded, 'task should have succeeded');
});

it('downloads python from registry on Windows', function () {
const testFile = path.join(__dirname, 'L0DownloadsFromRegistryWindows.js');
const testRunner = new MockTestRunner(testFile);

testRunner.run();

const pythonDir = path.join('C', 'tools', 'Python', '3.10.1', 'x64');
const pythonBinDir = path.join(pythonDir, 'Scripts');
const pythonAppdataDir = path.join('testappdata', 'Python', 'Python310', 'Scripts');

assert(didSetVariable(testRunner, 'pythonLocation', pythonDir));
assert(didPrependPath(testRunner, pythonDir));
assert(didPrependPath(testRunner, pythonBinDir));
assert(didPrependPath(testRunner, pythonAppdataDir));
assert.strictEqual(testRunner.stderr.length, 0, 'should not have written to stderr');
assert(testRunner.succeeded, 'task should have succeeded');
});

it('downloads python from registry on Ubuntu', function () {
const testFile = path.join(__dirname, 'L0DownloadsFromRegistryUbuntu.js');
const testRunner = new MockTestRunner(testFile);

testRunner.run();

const pythonDir = path.join('opt', 'hostedtoolcache', 'Python', '3.10.1', 'x64');
const pythonBinDir = path.join(pythonDir, 'bin');

assert(didSetVariable(testRunner, 'pythonLocation', pythonDir));
assert(didPrependPath(testRunner, pythonDir));
assert(didPrependPath(testRunner, pythonBinDir));
assert.strictEqual(testRunner.stderr.length, 0, 'should not have written to stderr');
assert(testRunner.succeeded, 'task should have succeeded');
});

it('downloads unstable python from registry', function () {
const testFile = path.join(__dirname, 'L0DownloadsUnstable.js');
const testRunner = new MockTestRunner(testFile);

testRunner.run();

const pythonDir = path.join('opt', 'hostedtoolcache', 'Python', '3.11.1', 'x64');
const pythonBinDir = path.join(pythonDir, 'bin');

assert(didSetVariable(testRunner, 'pythonLocation', pythonDir));
assert(didPrependPath(testRunner, pythonDir));
assert(didPrependPath(testRunner, pythonBinDir));
assert.strictEqual(testRunner.stderr.length, 0, 'should not have written to stderr');
assert(testRunner.succeeded, 'task should have succeeded');
});

it('fails when version is not found', function () {
const testFile = path.join(__dirname, 'L0FailsWhenVersionIsMissing.js');
const testRunner = new MockTestRunner(testFile);

testRunner.run();

assert(testRunner.createdErrorIssue('loc_mock_DownloadFailed Error: loc_mock_DownloadNotFound 3.11.x'));

const errorMessage = [
'loc_mock_VersionNotFound 3.11.x x64',
'loc_mock_VersionNotFound 3.x x64',
'loc_mock_ListAvailableVersions $(Agent.ToolsDirectory)',
'2.6.0 (x86)',
'2.7.13 (x86)',
'2.6.0 (x64)',
'2.7.13 (x64)',
'loc_mock_ToolNotFoundMicrosoftHosted Python https://aka.ms/hosted-agent-software',
'loc_mock_ToolNotFoundSelfHosted Python https://go.microsoft.com/fwlink/?linkid=871498',
].join('\r\n');
].join(os.EOL);

assert(testRunner.createdErrorIssue(errorMessage));
assert(testRunner.failed, 'task should have failed');
Expand Down
104 changes: 0 additions & 104 deletions Tasks/UsePythonVersionV0/Tests/L0DownloadsFromRegistryUbuntu.ts

This file was deleted.

86 changes: 0 additions & 86 deletions Tasks/UsePythonVersionV0/Tests/L0DownloadsFromRegistryWindows.ts

This file was deleted.

105 changes: 0 additions & 105 deletions Tasks/UsePythonVersionV0/Tests/L0DownloadsUnstable.ts

This file was deleted.

Loading

0 comments on commit 01337b4

Please sign in to comment.