Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49d58d7

Browse filesBrowse files
committed
Use pypyX.Y for PyPy python-version input
This versioning scheme is consistent with other tools in the python ecosystem so it feels more natural and allows better interaction with other tools. fixes #346
1 parent 8a76f22 commit 49d58d7
Copy full SHA for 49d58d7

File tree

Expand file treeCollapse file tree

6 files changed

+74
-35
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+74
-35
lines changed

‎.github/workflows/test-pypy.yml

Copy file name to clipboardExpand all lines: .github/workflows/test-pypy.yml
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ jobs:
2222
pypy:
2323
- 'pypy-2.7'
2424
- 'pypy-3.7'
25+
- 'pypy3.9'
2526
- 'pypy-2.7-v7.3.4'
2627
- 'pypy-3.7-v7.3.5'
2728
- 'pypy-3.7-v7.3.4'
2829
- 'pypy-3.7-v7.3.x'
2930
- 'pypy-3.7-v7.x'
3031
- 'pypy-2.7-v7.3.4rc1'
3132
- 'pypy-3.7-nightly'
33+
- 'pypy3.8-v7.3.7'
3234

3335
steps:
3436
- name: Checkout
@@ -54,7 +56,7 @@ jobs:
5456
- name: Assert expected binaries (or symlinks) are present
5557
run: |
5658
EXECUTABLE=${{ matrix.pypy }}
57-
EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
59+
EXECUTABLE=${EXECUTABLE/pypy-/pypy} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
5860
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
5961
${EXECUTABLE} --version
6062
shell: bash

‎README.md

Copy file name to clipboardExpand all lines: README.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
runs-on: ubuntu-latest
4444
strategy:
4545
matrix:
46-
python-version: [ '2.x', '3.x', 'pypy-2.7', 'pypy-3.7', 'pypy-3.8' ]
46+
python-version: [ '2.x', '3.x', 'pypy2.7', 'pypy3.7', 'pypy3.8' ]
4747
name: Python ${{ matrix.python-version }} sample
4848
steps:
4949
- uses: actions/checkout@v3
@@ -63,7 +63,7 @@ jobs:
6363
strategy:
6464
matrix:
6565
os: [ubuntu-latest, macos-latest, windows-latest]
66-
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy-2.7', 'pypy-3.8']
66+
python-version: ['2.7', '3.7', '3.8', '3.9', '3.10', 'pypy2.7', 'pypy3.8']
6767
exclude:
6868
- os: macos-latest
6969
python-version: '3.8'
@@ -125,9 +125,9 @@ jobs:
125125
strategy:
126126
matrix:
127127
python-version:
128-
- 'pypy-3.7' # the latest available version of PyPy that supports Python 3.7
129-
- 'pypy-3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3
130-
- 'pypy-3.8' # the latest available version of PyPy that supports Python 3.8
128+
- 'pypy3.7' # the latest available version of PyPy that supports Python 3.7
129+
- 'pypy3.7-v7.3.3' # Python 3.7 and PyPy 7.3.3
130+
- 'pypy3.8' # the latest available version of PyPy that supports Python 3.8
131131
steps:
132132
- uses: actions/checkout@v3
133133
- uses: actions/setup-python@v3
@@ -161,7 +161,7 @@ Check out our detailed guide on using [Python with GitHub Actions](https://help.
161161
- Preinstalled versions of PyPy in the tools cache on GitHub-hosted runners
162162
- For detailed information regarding the available versions of PyPy that are installed, see [Supported software](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-software).
163163
- For the latest PyPy release, all versions of Python are cached.
164-
- Cache is updated with a 1-2 week delay. If you specify the PyPy version as `pypy-3.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy-3.7-v7.3.3`.
164+
- Cache is updated with a 1-2 week delay. If you specify the PyPy version as `pypy3.7`, the cached version will be used although a newer version is available. If you need to start using the recently released version right after release, you should specify the exact PyPy version using `pypy3.7-v7.3.3`.
165165

166166
- Downloadable PyPy versions from the [official PyPy site](https://downloads.python.org/pypy/).
167167
- All available versions that we can download are listed in [versions.json](https://downloads.python.org/pypy/versions.json) file.
@@ -194,17 +194,17 @@ You should specify only a major and minor version if you are okay with the most
194194
- Using the most recent patch version will result in a very quick setup since no downloads will be required since a locally installed version Python on the runner will be used.
195195

196196
# Specifying a PyPy version
197-
The version of PyPy should be specified in the format `pypy-<python_version>[-v<pypy_version>]`.
197+
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
198198
The `<pypy_version>` parameter is optional and can be skipped. The latest version will be used in this case.
199199

200200
```
201-
pypy-3.7 # the latest available version of PyPy that supports Python 3.7
202-
pypy-3.8 # the latest available version of PyPy that supports Python 3.8
203-
pypy-2.7 # the latest available version of PyPy that supports Python 2.7
204-
pypy-3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
205-
pypy-3.7-v7.x # Python 3.7 and the latest available PyPy 7.x
206-
pypy-3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy
207-
pypy-3.7-nightly # Python 3.7 and nightly PyPy
201+
pypy3.7 # the latest available version of PyPy that supports Python 3.7
202+
pypy3.8 # the latest available version of PyPy that supports Python 3.8
203+
pypy2.7 # the latest available version of PyPy that supports Python 2.7
204+
pypy3.7-v7.3.3 # Python 3.7 and PyPy 7.3.3
205+
pypy3.7-v7.x # Python 3.7 and the latest available PyPy 7.x
206+
pypy3.7-v7.3.3rc1 # Python 3.7 and preview version of PyPy
207+
pypy3.7-nightly # Python 3.7 and nightly PyPy
208208
```
209209
210210
# Caching packages dependencies

‎__tests__/find-pypy.test.ts

Copy file name to clipboardExpand all lines: __tests__/find-pypy.test.ts
+24-6Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,34 @@ describe('parsePyPyVersion', () => {
3737
['pypy-3.6-v7.x', {pythonVersion: '3.6', pypyVersion: 'v7.x'}],
3838
['pypy-3.6', {pythonVersion: '3.6', pypyVersion: 'x'}],
3939
['pypy-3.6-nightly', {pythonVersion: '3.6', pypyVersion: 'nightly'}],
40-
['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}]
40+
['pypy-3.6-v7.3.3rc1', {pythonVersion: '3.6', pypyVersion: 'v7.3.3-rc.1'}],
41+
['pypy3.8-v7.3.7', {pythonVersion: '3.8', pypyVersion: 'v7.3.7'}],
42+
['pypy3.8-v7.3.x', {pythonVersion: '3.8', pypyVersion: 'v7.3.x'}],
43+
['pypy3.8-v7.x', {pythonVersion: '3.8', pypyVersion: 'v7.x'}],
44+
['pypy3.8', {pythonVersion: '3.8', pypyVersion: 'x'}],
45+
['pypy3.9-nightly', {pythonVersion: '3.9', pypyVersion: 'nightly'}],
46+
['pypy3.9-v7.3.8rc1', {pythonVersion: '3.9', pypyVersion: 'v7.3.8-rc.1'}]
4147
])('%s -> %s', (input, expected) => {
4248
expect(finder.parsePyPyVersion(input)).toEqual(expected);
4349
});
4450

45-
it('throw on invalid input', () => {
46-
expect(() => finder.parsePyPyVersion('pypy-')).toThrowError(
47-
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
48-
);
49-
});
51+
it.each(['', 'pypy-', 'pypy', 'p', 'notpypy-'])(
52+
'throw on invalid input "%s"',
53+
input => {
54+
expect(() => finder.parsePyPyVersion(input)).toThrowError(
55+
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy<python-version>' or 'pypy-<python-version>'. See README for examples and documentation."
56+
);
57+
}
58+
);
59+
60+
it.each(['pypy-2', 'pypy-3', 'pypy2', 'pypy3', 'pypy3.x', 'pypy3.8.10'])(
61+
'throw on invalid input "%s"',
62+
input => {
63+
expect(() => finder.parsePyPyVersion(input)).toThrowError(
64+
"Invalid format of Python version for PyPy. Python version should be specified in format 'x.y'. See README for examples and documentation."
65+
);
66+
}
67+
);
5068
});
5169

5270
describe('getPyPyVersionFromPath', () => {

‎dist/setup/index.js

Copy file name to clipboardExpand all lines: dist/setup/index.js
+17-7Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6073,7 +6073,7 @@ const os = __importStar(__webpack_require__(87));
60736073
const cache_factory_1 = __webpack_require__(633);
60746074
const utils_1 = __webpack_require__(163);
60756075
function isPyPyVersion(versionSpec) {
6076-
return versionSpec.startsWith('pypy-');
6076+
return versionSpec.startsWith('pypy');
60776077
}
60786078
function cacheDependencies(cache, pythonVersion) {
60796079
return __awaiter(this, void 0, void 0, function* () {
@@ -52406,14 +52406,24 @@ function findPyPyToolCache(pythonVersion, pypyVersion, architecture) {
5240652406
}
5240752407
exports.findPyPyToolCache = findPyPyToolCache;
5240852408
function parsePyPyVersion(versionSpec) {
52409-
const versions = versionSpec.split('-').filter(item => !!item);
52410-
if (versions.length < 2 || versions[0] != 'pypy') {
52411-
throw new Error("Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation.");
52409+
let versionsString;
52410+
if (versionSpec.length > 4 && versionSpec[4] == '-') {
52411+
versionsString = versionSpec.slice(5);
5241252412
}
52413-
const pythonVersion = versions[1];
52413+
else if (versionSpec.length > 3) {
52414+
versionsString = versionSpec.slice(4);
52415+
}
52416+
else {
52417+
versionsString = '';
52418+
}
52419+
const versions = versionsString.split('-').filter(item => !!item);
52420+
if (!versionSpec.startsWith('pypy') || versions.length == 0) {
52421+
throw new Error("Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy<python-version>' or 'pypy-<python-version>'. See README for examples and documentation.");
52422+
}
52423+
const pythonVersion = versions[0];
5241452424
let pypyVersion;
52415-
if (versions.length > 2) {
52416-
pypyVersion = pypyInstall.pypyVersionToSemantic(versions[2]);
52425+
if (versions.length > 1) {
52426+
pypyVersion = pypyInstall.pypyVersionToSemantic(versions[1]);
5241752427
}
5241852428
else {
5241952429
pypyVersion = 'x';

‎src/find-pypy.ts

Copy file name to clipboardExpand all lines: src/find-pypy.ts
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,27 @@ export function findPyPyToolCache(
9595
}
9696

9797
export function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec {
98-
const versions = versionSpec.split('-').filter(item => !!item);
98+
let versionsString: string;
99+
if (versionSpec.length > 4 && versionSpec[4] == '-') {
100+
versionsString = versionSpec.slice(5);
101+
} else if (versionSpec.length > 3) {
102+
versionsString = versionSpec.slice(4);
103+
} else {
104+
versionsString = '';
105+
}
106+
107+
const versions = versionsString.split('-').filter(item => !!item);
99108

100-
if (versions.length < 2 || versions[0] != 'pypy') {
109+
if (!versionSpec.startsWith('pypy') || versions.length == 0) {
101110
throw new Error(
102-
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
111+
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy<python-version>' or 'pypy-<python-version>'. See README for examples and documentation."
103112
);
104113
}
105114

106-
const pythonVersion = versions[1];
115+
const pythonVersion = versions[0];
107116
let pypyVersion: string;
108-
if (versions.length > 2) {
109-
pypyVersion = pypyInstall.pypyVersionToSemantic(versions[2]);
117+
if (versions.length > 1) {
118+
pypyVersion = pypyInstall.pypyVersionToSemantic(versions[1]);
110119
} else {
111120
pypyVersion = 'x';
112121
}

‎src/setup-python.ts

Copy file name to clipboardExpand all lines: src/setup-python.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {getCacheDistributor} from './cache-distributions/cache-factory';
77
import {isCacheFeatureAvailable} from './utils';
88

99
function isPyPyVersion(versionSpec: string) {
10-
return versionSpec.startsWith('pypy-');
10+
return versionSpec.startsWith('pypy');
1111
}
1212

1313
async function cacheDependencies(cache: string, pythonVersion: string) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.