mirror of
https://gitea.com/actions/setup-python.git
synced 2024-11-23 02:29:35 +01:00
Remove legacy PyPy input (#342)
This commit is contained in:
parent
665cd78205
commit
0ebf233433
6 changed files with 11 additions and 146 deletions
20
.github/workflows/test-python.yml
vendored
20
.github/workflows/test-python.yml
vendored
|
@ -91,23 +91,3 @@ jobs:
|
||||||
- name: Run simple code
|
- name: Run simple code
|
||||||
run: python -c 'import math; print(math.factorial(5))'
|
run: python -c 'import math; print(math.factorial(5))'
|
||||||
|
|
||||||
setup-pypy-legacy:
|
|
||||||
name: Setup PyPy ${{ matrix.os }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-10.15, windows-2019, ubuntu-18.04, ubuntu-20.04]
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: setup-python pypy3
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
python-version: 'pypy3'
|
|
||||||
|
|
||||||
- name: setup-python pypy2
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
python-version: 'pypy2'
|
|
||||||
|
|
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
|
@ -24,8 +24,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
|
|
||||||
- name: npm install
|
- name: npm ci
|
||||||
run: npm install
|
run: npm ci
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: npm run format-check
|
run: npm run format-check
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe('Finder tests', () => {
|
||||||
await io.mkdirP(pythonDir);
|
await io.mkdirP(pythonDir);
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
await finder.findPythonVersion('3.x', 'x64');
|
await finder.useCpythonVersion('3.x', 'x64');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
||||||
|
@ -52,7 +52,7 @@ describe('Finder tests', () => {
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
});
|
});
|
||||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
await finder.findPythonVersion('1.2.3', 'x64');
|
await finder.useCpythonVersion('1.2.3', 'x64');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds pre-release Python version in the manifest', async () => {
|
it('Finds pre-release Python version in the manifest', async () => {
|
||||||
|
@ -74,25 +74,17 @@ describe('Finder tests', () => {
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
});
|
});
|
||||||
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
||||||
await finder.findPythonVersion('1.2.3-beta.2', 'x64');
|
await finder.useCpythonVersion('1.2.3-beta.2', 'x64');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Errors if Python is not installed', async () => {
|
it('Errors if Python is not installed', async () => {
|
||||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
try {
|
try {
|
||||||
await finder.findPythonVersion('3.300000', 'x64');
|
await finder.useCpythonVersion('3.300000', 'x64');
|
||||||
} catch {
|
} catch {
|
||||||
thrown = true;
|
thrown = true;
|
||||||
}
|
}
|
||||||
expect(thrown).toBeTruthy();
|
expect(thrown).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds PyPy if it is installed', async () => {
|
|
||||||
const pythonDir: string = path.join(toolDir, 'PyPy', '2.0.0', 'x64');
|
|
||||||
await io.mkdirP(pythonDir);
|
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
|
||||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
|
||||||
await finder.findPythonVersion('pypy2', 'x64');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
53
dist/setup/index.js
vendored
53
dist/setup/index.js
vendored
|
@ -6694,7 +6694,7 @@ function run() {
|
||||||
core.info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
|
core.info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const installed = yield finder.findPythonVersion(version, arch);
|
const installed = yield finder.useCpythonVersion(version, arch);
|
||||||
pythonVersion = installed.version;
|
pythonVersion = installed.version;
|
||||||
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
|
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
|
||||||
}
|
}
|
||||||
|
@ -57111,7 +57111,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.findPythonVersion = exports.pythonVersionToSemantic = void 0;
|
exports.pythonVersionToSemantic = exports.useCpythonVersion = void 0;
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const utils_1 = __webpack_require__(163);
|
const utils_1 = __webpack_require__(163);
|
||||||
|
@ -57139,40 +57139,6 @@ function binDir(installDir) {
|
||||||
return path.join(installDir, 'bin');
|
return path.join(installDir, 'bin');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Note on the tool cache layout for PyPy:
|
|
||||||
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
|
|
||||||
// A particular version of PyPy may contain one or more versions of the Python interpreter.
|
|
||||||
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
|
|
||||||
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
|
|
||||||
function usePyPy(majorVersion, architecture) {
|
|
||||||
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion);
|
|
||||||
let installDir = findPyPy(architecture);
|
|
||||||
if (!installDir && utils_1.IS_WINDOWS) {
|
|
||||||
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
|
|
||||||
// On our Windows virtual environments, we only install an x86 version.
|
|
||||||
// Fall back to x86.
|
|
||||||
installDir = findPyPy('x86');
|
|
||||||
}
|
|
||||||
if (!installDir) {
|
|
||||||
// PyPy not installed in $(Agent.ToolsDirectory)
|
|
||||||
throw new Error(`PyPy ${majorVersion} not found`);
|
|
||||||
}
|
|
||||||
// For PyPy, Windows uses 'bin', not 'Scripts'.
|
|
||||||
const _binDir = path.join(installDir, 'bin');
|
|
||||||
// On Linux and macOS, the Python interpreter is in 'bin'.
|
|
||||||
// On Windows, it is in the installation root.
|
|
||||||
const pythonLocation = utils_1.IS_WINDOWS ? installDir : _binDir;
|
|
||||||
core.exportVariable('pythonLocation', pythonLocation);
|
|
||||||
core.addPath(installDir);
|
|
||||||
core.addPath(_binDir);
|
|
||||||
// Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows.
|
|
||||||
if (utils_1.IS_WINDOWS) {
|
|
||||||
core.addPath(path.join(installDir, 'Scripts'));
|
|
||||||
}
|
|
||||||
const impl = 'pypy' + majorVersion.toString();
|
|
||||||
core.setOutput('python-version', impl);
|
|
||||||
return { impl: impl, version: versionFromPath(installDir) };
|
|
||||||
}
|
|
||||||
function useCpythonVersion(version, architecture) {
|
function useCpythonVersion(version, architecture) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const desugaredVersionSpec = desugarDevVersion(version);
|
const desugaredVersionSpec = desugarDevVersion(version);
|
||||||
|
@ -57222,6 +57188,7 @@ function useCpythonVersion(version, architecture) {
|
||||||
return { impl: 'CPython', version: installed };
|
return { impl: 'CPython', version: installed };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
exports.useCpythonVersion = useCpythonVersion;
|
||||||
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
|
||||||
function desugarDevVersion(versionSpec) {
|
function desugarDevVersion(versionSpec) {
|
||||||
if (versionSpec.endsWith('-dev')) {
|
if (versionSpec.endsWith('-dev')) {
|
||||||
|
@ -57248,20 +57215,6 @@ function pythonVersionToSemantic(versionSpec) {
|
||||||
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
||||||
}
|
}
|
||||||
exports.pythonVersionToSemantic = pythonVersionToSemantic;
|
exports.pythonVersionToSemantic = pythonVersionToSemantic;
|
||||||
function findPythonVersion(version, architecture) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
switch (version.toUpperCase()) {
|
|
||||||
case 'PYPY2':
|
|
||||||
return usePyPy('2', architecture);
|
|
||||||
case 'PYPY3':
|
|
||||||
// keep pypy3 pointing to 3.6 for backward compatibility
|
|
||||||
return usePyPy('3.6', architecture);
|
|
||||||
default:
|
|
||||||
return yield useCpythonVersion(version, architecture);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.findPythonVersion = findPythonVersion;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -30,52 +30,7 @@ function binDir(installDir: string): string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note on the tool cache layout for PyPy:
|
export async function useCpythonVersion(
|
||||||
// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
|
|
||||||
// A particular version of PyPy may contain one or more versions of the Python interpreter.
|
|
||||||
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
|
|
||||||
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
|
|
||||||
function usePyPy(
|
|
||||||
majorVersion: '2' | '3.6',
|
|
||||||
architecture: string
|
|
||||||
): InstalledVersion {
|
|
||||||
const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion);
|
|
||||||
let installDir: string | null = findPyPy(architecture);
|
|
||||||
|
|
||||||
if (!installDir && IS_WINDOWS) {
|
|
||||||
// PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
|
|
||||||
// On our Windows virtual environments, we only install an x86 version.
|
|
||||||
// Fall back to x86.
|
|
||||||
installDir = findPyPy('x86');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!installDir) {
|
|
||||||
// PyPy not installed in $(Agent.ToolsDirectory)
|
|
||||||
throw new Error(`PyPy ${majorVersion} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For PyPy, Windows uses 'bin', not 'Scripts'.
|
|
||||||
const _binDir = path.join(installDir, 'bin');
|
|
||||||
|
|
||||||
// On Linux and macOS, the Python interpreter is in 'bin'.
|
|
||||||
// On Windows, it is in the installation root.
|
|
||||||
const pythonLocation = IS_WINDOWS ? installDir : _binDir;
|
|
||||||
core.exportVariable('pythonLocation', pythonLocation);
|
|
||||||
|
|
||||||
core.addPath(installDir);
|
|
||||||
core.addPath(_binDir);
|
|
||||||
// Starting from PyPy 7.3.1, the folder that is used for pip and anything that pip installs should be "Scripts" on Windows.
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
core.addPath(path.join(installDir, 'Scripts'));
|
|
||||||
}
|
|
||||||
|
|
||||||
const impl = 'pypy' + majorVersion.toString();
|
|
||||||
core.setOutput('python-version', impl);
|
|
||||||
|
|
||||||
return {impl: impl, version: versionFromPath(installDir)};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function useCpythonVersion(
|
|
||||||
version: string,
|
version: string,
|
||||||
architecture: string
|
architecture: string
|
||||||
): Promise<InstalledVersion> {
|
): Promise<InstalledVersion> {
|
||||||
|
@ -186,18 +141,3 @@ export function pythonVersionToSemantic(versionSpec: string) {
|
||||||
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
|
const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
|
||||||
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
return versionSpec.replace(prereleaseVersion, '$1-$2');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findPythonVersion(
|
|
||||||
version: string,
|
|
||||||
architecture: string
|
|
||||||
): Promise<InstalledVersion> {
|
|
||||||
switch (version.toUpperCase()) {
|
|
||||||
case 'PYPY2':
|
|
||||||
return usePyPy('2', architecture);
|
|
||||||
case 'PYPY3':
|
|
||||||
// keep pypy3 pointing to 3.6 for backward compatibility
|
|
||||||
return usePyPy('3.6', architecture);
|
|
||||||
default:
|
|
||||||
return await useCpythonVersion(version, architecture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ async function run() {
|
||||||
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const installed = await finder.findPythonVersion(version, arch);
|
const installed = await finder.useCpythonVersion(version, arch);
|
||||||
pythonVersion = installed.version;
|
pythonVersion = installed.version;
|
||||||
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
|
core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue