Skip to content

Commit 0ebf233

Browse files
Remove legacy PyPy input (#342)
1 parent 665cd78 commit 0ebf233

File tree

6 files changed

+11
-146
lines changed

6 files changed

+11
-146
lines changed

.github/workflows/test-python.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,3 @@ jobs:
9191
- name: Run simple code
9292
run: python -c 'import math; print(math.factorial(5))'
9393

94-
setup-pypy-legacy:
95-
name: Setup PyPy ${{ matrix.os }}
96-
runs-on: ${{ matrix.os }}
97-
strategy:
98-
fail-fast: false
99-
matrix:
100-
os: [macos-10.15, windows-2019, ubuntu-18.04, ubuntu-20.04]
101-
steps:
102-
- name: Checkout
103-
uses: actions/checkout@v2
104-
105-
- name: setup-python pypy3
106-
uses: ./
107-
with:
108-
python-version: 'pypy3'
109-
110-
- name: setup-python pypy2
111-
uses: ./
112-
with:
113-
python-version: 'pypy2'

.github/workflows/workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
with:
2525
node-version: 16.x
2626

27-
- name: npm install
28-
run: npm install
27+
- name: npm ci
28+
run: npm ci
2929

3030
- name: Lint
3131
run: npm run format-check

__tests__/finder.test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('Finder tests', () => {
3535
await io.mkdirP(pythonDir);
3636
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
3737
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
38-
await finder.findPythonVersion('3.x', 'x64');
38+
await finder.useCpythonVersion('3.x', 'x64');
3939
});
4040

4141
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
@@ -52,7 +52,7 @@ describe('Finder tests', () => {
5252
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
5353
});
5454
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
55-
await finder.findPythonVersion('1.2.3', 'x64');
55+
await finder.useCpythonVersion('1.2.3', 'x64');
5656
});
5757

5858
it('Finds pre-release Python version in the manifest', async () => {
@@ -74,25 +74,17 @@ describe('Finder tests', () => {
7474
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
7575
});
7676
// This will throw if it doesn't find it in the manifest (because no such version exists)
77-
await finder.findPythonVersion('1.2.3-beta.2', 'x64');
77+
await finder.useCpythonVersion('1.2.3-beta.2', 'x64');
7878
});
7979

8080
it('Errors if Python is not installed', async () => {
8181
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
8282
let thrown = false;
8383
try {
84-
await finder.findPythonVersion('3.300000', 'x64');
84+
await finder.useCpythonVersion('3.300000', 'x64');
8585
} catch {
8686
thrown = true;
8787
}
8888
expect(thrown).toBeTruthy();
8989
});
90-
91-
it('Finds PyPy if it is installed', async () => {
92-
const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64');
93-
await io.mkdirP(pythonDir);
94-
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
95-
// This will throw if it doesn't find it in the cache (because no such version exists)
96-
await finder.findPythonVersion('pypy2', 'x64');
97-
});
9890
});

dist/setup/index.js

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6694,7 +6694,7 @@ function run() {
66946694
core.info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
66956695
}
66966696
else {
6697-
const installed = yield finder.findPythonVersion(version, arch);
6697+
const installed = yield finder.useCpythonVersion(version, arch);
66986698
pythonVersion = installed.version;
66996699
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
67006700
}
@@ -57111,7 +57111,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
5711157111
});
5711257112
};
5711357113
Object.defineProperty(exports, "__esModule", { value: true });
57114-
exports.findPythonVersion = exports.pythonVersionToSemantic = void 0;
57114+
exports.pythonVersionToSemantic = exports.useCpythonVersion = void 0;
5711557115
const os = __importStar(__webpack_require__(87));
5711657116
const path = __importStar(__webpack_require__(622));
5711757117
const utils_1 = __webpack_require__(163);
@@ -57139,40 +57139,6 @@ function binDir(installDir) {
5713957139
return path.join(installDir, 'bin');
5714057140
}
5714157141
}
57142-
// Note on the tool cache layout for PyPy:
57143-
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
57144-
// A particular version of PyPy may contain one or more versions of the Python interpreter.
57145-
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
57146-
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
57147-
function usePyPy(majorVersion, architecture) {
57148-
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion);
57149-
let installDir = findPyPy(architecture);
57150-
if (!installDir && utils_1.IS_WINDOWS) {
57151-
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
57152-
// On our Windows virtual environments, we only install an x86 version.
57153-
// Fall back to x86.
57154-
installDir = findPyPy('x86');
57155-
}
57156-
if (!installDir) {
57157-
// PyPy not installed in $(Agent.ToolsDirectory)
57158-
throw new Error(`PyPy ${majorVersion} not found`);
57159-
}
57160-
// For PyPy, Windows uses 'bin', not 'Scripts'.
57161-
const _binDir = path.join(installDir, 'bin');
57162-
// On Linux and macOS, the Python interpreter is in 'bin'.
57163-
// On Windows, it is in the installation root.
57164-
const pythonLocation = utils_1.IS_WINDOWS ? installDir : _binDir;
57165-
core.exportVariable('pythonLocation', pythonLocation);
57166-
core.addPath(installDir);
57167-
core.addPath(_binDir);
57168-
// Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows.
57169-
if (utils_1.IS_WINDOWS) {
57170-
core.addPath(path.join(installDir, 'Scripts'));
57171-
}
57172-
const impl = 'pypy' + majorVersion.toString();
57173-
core.setOutput('python-version', impl);
57174-
return { impl: impl, version: versionFromPath(installDir) };
57175-
}
5717657142
function useCpythonVersion(version, architecture) {
5717757143
return __awaiter(this, void 0, void 0, function* () {
5717857144
const desugaredVersionSpec = desugarDevVersion(version);
@@ -57222,6 +57188,7 @@ function useCpythonVersion(version, architecture) {
5722257188
return { impl: 'CPython', version: installed };
5722357189
});
5722457190
}
57191+
exports.useCpythonVersion = useCpythonVersion;
5722557192
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
5722657193
function desugarDevVersion(versionSpec) {
5722757194
if (versionSpec.endsWith('-dev')) {
@@ -57248,20 +57215,6 @@ function pythonVersionToSemantic(versionSpec) {
5724857215
return versionSpec.replace(prereleaseVersion, '$1-$2');
5724957216
}
5725057217
exports.pythonVersionToSemantic = pythonVersionToSemantic;
57251-
function findPythonVersion(version, architecture) {
57252-
return __awaiter(this, void 0, void 0, function* () {
57253-
switch (version.toUpperCase()) {
57254-
case 'PYPY2':
57255-
return usePyPy('2', architecture);
57256-
case 'PYPY3':
57257-
// keep pypy3 pointing to 3.6 for backward compatibility
57258-
return usePyPy('3.6', architecture);
57259-
default:
57260-
return yield useCpythonVersion(version, architecture);
57261-
}
57262-
});
57263-
}
57264-
exports.findPythonVersion = findPythonVersion;
5726557218

5726657219

5726757220
/***/ }),

src/find-python.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,7 @@ function binDir(installDir: string): string {
3030
}
3131
}
3232

33-
// Note on the tool cache layout for PyPy:
34-
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
35-
// A particular version of PyPy may contain one or more versions of the Python interpreter.
36-
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
37-
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
38-
function usePyPy(
39-
majorVersion: '2' | '3.6',
40-
architecture: string
41-
): InstalledVersion {
42-
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion);
43-
let installDir: string | null = findPyPy(architecture);
44-
45-
if (!installDir && IS_WINDOWS) {
46-
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
47-
// On our Windows virtual environments, we only install an x86 version.
48-
// Fall back to x86.
49-
installDir = findPyPy('x86');
50-
}
51-
52-
if (!installDir) {
53-
// PyPy not installed in $(Agent.ToolsDirectory)
54-
throw new Error(`PyPy ${majorVersion} not found`);
55-
}
56-
57-
// For PyPy, Windows uses 'bin', not 'Scripts'.
58-
const _binDir = path.join(installDir, 'bin');
59-
60-
// On Linux and macOS, the Python interpreter is in 'bin'.
61-
// On Windows, it is in the installation root.
62-
const pythonLocation = IS_WINDOWS ? installDir : _binDir;
63-
core.exportVariable('pythonLocation', pythonLocation);
64-
65-
core.addPath(installDir);
66-
core.addPath(_binDir);
67-
// Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows.
68-
if (IS_WINDOWS) {
69-
core.addPath(path.join(installDir, 'Scripts'));
70-
}
71-
72-
const impl = 'pypy' + majorVersion.toString();
73-
core.setOutput('python-version', impl);
74-
75-
return {impl: impl, version: versionFromPath(installDir)};
76-
}
77-
78-
async function useCpythonVersion(
33+
export async function useCpythonVersion(
7934
version: string,
8035
architecture: string
8136
): Promise<InstalledVersion> {
@@ -186,18 +141,3 @@ export function pythonVersionToSemantic(versionSpec: string) {
186141
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
187142
return versionSpec.replace(prereleaseVersion, '$1-$2');
188143
}
189-
190-
export async function findPythonVersion(
191-
version: string,
192-
architecture: string
193-
): Promise<InstalledVersion> {
194-
switch (version.toUpperCase()) {
195-
case 'PYPY2':
196-
return usePyPy('2', architecture);
197-
case 'PYPY3':
198-
// keep pypy3 pointing to 3.6 for backward compatibility
199-
return usePyPy('3.6', architecture);
200-
default:
201-
return await useCpythonVersion(version, architecture);
202-
}
203-
}

src/setup-python.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function run() {
3737
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
3838
);
3939
} else {
40-
const installed = await finder.findPythonVersion(version, arch);
40+
const installed = await finder.useCpythonVersion(version, arch);
4141
pythonVersion = installed.version;
4242
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
4343
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy