Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Jun 23, 2022
1 parent 350a5fc commit 0f3b8dc
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-pypy.yml
Expand Up @@ -84,7 +84,7 @@ jobs:
uses: ./
with:
python-version: ${{ matrix.pypy }}
no-environment-update: true
update-environment: false

- name: PyPy and Python version
run: ${{ steps.setup-python.outputs.python-path }} --version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-python.yml
Expand Up @@ -165,7 +165,7 @@ jobs:
uses: ./
with:
python-version: ${{ matrix.python }}
no-environment-update: true
update-environment: false

- name: Python version
run: ${{ steps.setup-python.outputs.python-path }} --version
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -320,12 +320,12 @@ steps:
- run: pipenv install
```

# No environment update
# Environment variables

The `no-environment-update` flag defaults to `false`.
The `update-environment` flag defaults to `true`.
With this setting, the action will add/update environment variables (e.g. `PATH`, `PKG_CONFIG_PATH`, `pythonLocation`) for `python` to just work out of the box.

If `no-environment-update` is set to `true`, the action will not add/update environment variables.
If `update-environment` is set to `false`, the action will not add/update environment variables.
This can prove useful if you want the only side-effect to be to ensure python is installed and rely on the `python-path` output to run python.
Such a requirement on side-effect could be because you don't want your composite action messing with your user's workflows.

Expand All @@ -336,7 +336,7 @@ steps:
id: cp310
with:
python-version: '3.10'
no-environment-update: true
update-environment: false
- run: ${{ steps.cp310.outputs.python-path }} my_script.py
```

Expand Down
6 changes: 3 additions & 3 deletions action.yml
Expand Up @@ -17,9 +17,9 @@ inputs:
default: ${{ github.token }}
cache-dependency-path:
description: 'Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies.'
no-environment-update:
description: 'Set this option if you want the action not to update environment variables.'
default: false
update-environment:
description: 'Set this option if you want the action to update environment variables.'
default: true
outputs:
python-version:
description: "The installed python version. Useful when given a version range as input."
Expand Down
14 changes: 7 additions & 7 deletions dist/setup/index.js
Expand Up @@ -63865,7 +63865,7 @@ const utils_1 = __nccwpck_require__(1314);
const semver = __importStar(__nccwpck_require__(1383));
const core = __importStar(__nccwpck_require__(2186));
const tc = __importStar(__nccwpck_require__(7784));
function findPyPyVersion(versionSpec, architecture, envUpdate) {
function findPyPyVersion(versionSpec, architecture, updateEnvironment) {
return __awaiter(this, void 0, void 0, function* () {
let resolvedPyPyVersion = '';
let resolvedPythonVersion = '';
Expand All @@ -63884,7 +63884,7 @@ function findPyPyVersion(versionSpec, architecture, envUpdate) {
const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`);
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
if (envUpdate) {
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
core.addPath(pythonLocation);
Expand Down Expand Up @@ -64021,7 +64021,7 @@ function binDir(installDir) {
return path.join(installDir, 'bin');
}
}
function useCpythonVersion(version, architecture, envUpdate) {
function useCpythonVersion(version, architecture, updateEnvironment) {
return __awaiter(this, void 0, void 0, function* () {
const desugaredVersionSpec = desugarDevVersion(version);
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
Expand All @@ -64045,7 +64045,7 @@ function useCpythonVersion(version, architecture, envUpdate) {
const _binDir = binDir(installDir);
const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : '';
const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`);
if (envUpdate) {
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
if (utils_1.IS_LINUX) {
Expand Down Expand Up @@ -64471,14 +64471,14 @@ function run() {
if (version) {
let pythonVersion;
const arch = core.getInput('architecture') || os.arch();
const updateEnv = !core.getBooleanInput('no-environment-update');
const updateEnvironment = core.getBooleanInput('update-environment');
if (isPyPyVersion(version)) {
const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnv);
const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
}
else {
const installed = yield finder.useCpythonVersion(version, arch, updateEnv);
const installed = yield finder.useCpythonVersion(version, arch, updateEnvironment);
pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/find-pypy.ts
Expand Up @@ -21,7 +21,7 @@ interface IPyPyVersionSpec {
export async function findPyPyVersion(
versionSpec: string,
architecture: string,
envUpdate: boolean
updateEnvironment: boolean
): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> {
let resolvedPyPyVersion = '';
let resolvedPythonVersion = '';
Expand Down Expand Up @@ -55,7 +55,7 @@ export async function findPyPyVersion(
`python${binaryExtension}`
);
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
if (envUpdate) {
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
core.addPath(pythonLocation);
Expand Down
4 changes: 2 additions & 2 deletions src/find-python.ts
Expand Up @@ -33,7 +33,7 @@ function binDir(installDir: string): string {
export async function useCpythonVersion(
version: string,
architecture: string,
envUpdate: boolean
updateEnvironment: boolean
): Promise<InstalledVersion> {
const desugaredVersionSpec = desugarDevVersion(version);
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function useCpythonVersion(
IS_WINDOWS ? installDir : _binDir,
`python${binaryExtension}`
);
if (envUpdate) {
if (updateEnvironment) {
core.exportVariable('pythonLocation', installDir);
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');

Expand Down
6 changes: 3 additions & 3 deletions src/setup-python.ts
Expand Up @@ -64,12 +64,12 @@ async function run() {
if (version) {
let pythonVersion: string;
const arch: string = core.getInput('architecture') || os.arch();
const updateEnv = !core.getBooleanInput('no-environment-update');
const updateEnvironment = core.getBooleanInput('update-environment');
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(
version,
arch,
updateEnv
updateEnvironment
);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(
Expand All @@ -79,7 +79,7 @@ async function run() {
const installed = await finder.useCpythonVersion(
version,
arch,
updateEnv
updateEnvironment
);
pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
Expand Down

0 comments on commit 0f3b8dc

Please sign in to comment.