@@ -51,7 +51,7 @@ function binDir(installDir: string): string {
51
51
// A particular version of PyPy may contain one or more versions of the Python interpreter.
52
52
// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
53
53
// We only care about the Python version, so we don't use the PyPy version for the tool cache.
54
- function usePyPy ( majorVersion : 2 | 3 , architecture : string ) : string {
54
+ function usePyPy ( majorVersion : 2 | 3 , architecture : string ) : InstalledVersion {
55
55
const findPyPy = tc . find . bind ( undefined , 'PyPy' , majorVersion . toString ( ) ) ;
56
56
let installDir : string | null = findPyPy ( architecture ) ;
57
57
@@ -78,13 +78,16 @@ function usePyPy(majorVersion: 2 | 3, architecture: string): string {
78
78
core . addPath ( installDir ) ;
79
79
core . addPath ( _binDir ) ;
80
80
81
- return versionFromPath ( installDir ) ;
81
+ const impl = 'pypy' + majorVersion . toString ( ) ;
82
+ core . setOutput ( 'python-version' , impl ) ;
83
+
84
+ return { impl : impl , version : versionFromPath ( installDir ) } ;
82
85
}
83
86
84
87
async function useCpythonVersion (
85
88
version : string ,
86
89
architecture : string
87
- ) : Promise < string > {
90
+ ) : Promise < InstalledVersion > {
88
91
const desugaredVersionSpec = desugarDevVersion ( version ) ;
89
92
const semanticVersionSpec = pythonVersionToSemantic ( desugaredVersionSpec ) ;
90
93
core . debug ( `Semantic version spec of ${ version } is ${ semanticVersionSpec } ` ) ;
@@ -138,7 +141,10 @@ async function useCpythonVersion(
138
141
}
139
142
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
140
143
141
- return versionFromPath ( installDir ) ;
144
+ const installed = versionFromPath ( installDir ) ;
145
+ core . setOutput ( 'python-version' , installed ) ;
146
+
147
+ return { impl : 'CPython' , version : installed } ;
142
148
}
143
149
144
150
/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
@@ -153,10 +159,15 @@ function desugarDevVersion(versionSpec: string) {
153
159
154
160
/** Extracts python version from install path from hosted tool cache as described in README.md */
155
161
function versionFromPath ( installDir : string ) {
156
- let parts = installDir . split ( path . sep ) ;
157
- let idx = parts . findIndex ( part => part === 'PyPy' || part === 'Python' ) ;
162
+ const parts = installDir . split ( path . sep ) ;
163
+ const idx = parts . findIndex ( part => part === 'PyPy' || part === 'Python' ) ;
164
+
165
+ return parts [ idx + 1 ] || '' ;
166
+ }
158
167
159
- return parts . slice ( idx , idx + 2 ) . join ( ' ' ) ;
168
+ interface InstalledVersion {
169
+ impl : string ;
170
+ version : string ;
160
171
}
161
172
162
173
/**
@@ -172,7 +183,7 @@ export function pythonVersionToSemantic(versionSpec: string) {
172
183
export async function findPythonVersion (
173
184
version : string ,
174
185
architecture : string
175
- ) : Promise < string > {
186
+ ) : Promise < InstalledVersion > {
176
187
switch ( version . toUpperCase ( ) ) {
177
188
case 'PYPY2' :
178
189
return usePyPy ( 2 , architecture ) ;
0 commit comments