1
0
Fork 0
mirror of https://github.com/actions/setup-python.git synced 2024-11-22 14:48:36 +00:00

Inject LD_LIBRARY_PATH library path into Python manifest install and setup (#144)

* Adding LD_LIBRARY_PATH env var to both setup and install tasks

* Rebuild dist/index.js

* Fixed some typos in contributors.md Markdown
This commit is contained in:
Peter Mescalchin 2020-10-05 23:51:21 +11:00 committed by GitHub
parent c181ffa198
commit 878156f1de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

11
dist/index.js vendored
View file

@ -6422,6 +6422,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(__webpack_require__(622));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
const exec = __importStar(__webpack_require__(986)); const exec = __importStar(__webpack_require__(986));
@ -6432,6 +6433,7 @@ const MANIFEST_REPO_NAME = 'python-versions';
const MANIFEST_REPO_BRANCH = 'main'; const MANIFEST_REPO_BRANCH = 'main';
exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const IS_LINUX = process.platform === 'linux';
function findReleaseFromManifest(semanticVersionSpec, architecture) { function findReleaseFromManifest(semanticVersionSpec, architecture) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH); const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
@ -6443,6 +6445,7 @@ function installPython(workingDirectory) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const options = { const options = {
cwd: workingDirectory, cwd: workingDirectory,
env: Object.assign(Object.assign({}, process.env), IS_LINUX && { 'LD_LIBRARY_PATH': path.join(workingDirectory, 'lib') }),
silent: true, silent: true,
listeners: { listeners: {
stdout: (data) => { stdout: (data) => {
@ -6688,6 +6691,7 @@ const installer = __importStar(__webpack_require__(824));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const IS_LINUX = process.platform === 'linux';
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed. // Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
// This is where pip is, along with anything that pip installs. // This is where pip is, along with anything that pip installs.
// There is a seperate directory for `pip install --user`. // There is a seperate directory for `pip install --user`.
@ -6760,6 +6764,13 @@ function useCpythonVersion(version, architecture) {
].join(os.EOL)); ].join(os.EOL));
} }
core.exportVariable('pythonLocation', installDir); core.exportVariable('pythonLocation', installDir);
if (IS_LINUX) {
const libPath = (process.env.LD_LIBRARY_PATH) ? `:${process.env.LD_LIBRARY_PATH}` : '';
const pyLibPath = path.join(installDir, 'lib');
if (!libPath.split(':').includes(pyLibPath)) {
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
}
}
core.addPath(installDir); core.addPath(installDir);
core.addPath(binDir(installDir)); core.addPath(binDir(installDir));
if (IS_WINDOWS) { if (IS_WINDOWS) {

View file

@ -13,12 +13,14 @@ In order to avoid uploading `node_modules/` to the repository, we use [vercel/nc
### Developing ### Developing
If you're developing locally, you can run If you're developing locally, you can run
```
```sh
npm install npm install
tsc tsc
ncc build src/setup-python.ts ncc build src/setup-python.ts
``` ```
Any files generated using `tsc` will be added to `lib/`, however those files also are not uploaded to the repository and are exluded using `.gitignore`.
Any files generated using `tsc` will be added to `lib/`, however those files also are not uploaded to the repository and are excluded using `.gitignore`.
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) (to run manually, use `npm run format`). During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) (to run manually, use `npm run format`).

View file

@ -9,6 +9,7 @@ import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const IS_LINUX = process.platform === 'linux';
// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed. // Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
// This is where pip is, along with anything that pip installs. // This is where pip is, along with anything that pip installs.
@ -109,6 +110,18 @@ async function useCpythonVersion(
} }
core.exportVariable('pythonLocation', installDir); core.exportVariable('pythonLocation', installDir);
if (IS_LINUX) {
const libPath = process.env.LD_LIBRARY_PATH
? `:${process.env.LD_LIBRARY_PATH}`
: '';
const pyLibPath = path.join(installDir, 'lib');
if (!libPath.split(':').includes(pyLibPath)) {
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
}
}
core.addPath(installDir); core.addPath(installDir);
core.addPath(binDir(installDir)); core.addPath(binDir(installDir));

View file

@ -13,6 +13,7 @@ const MANIFEST_REPO_BRANCH = 'main';
export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`; export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
const IS_WINDOWS = process.platform === 'win32'; const IS_WINDOWS = process.platform === 'win32';
const IS_LINUX = process.platform === 'linux';
export async function findReleaseFromManifest( export async function findReleaseFromManifest(
semanticVersionSpec: string, semanticVersionSpec: string,
@ -35,6 +36,10 @@ export async function findReleaseFromManifest(
async function installPython(workingDirectory: string) { async function installPython(workingDirectory: string) {
const options: ExecOptions = { const options: ExecOptions = {
cwd: workingDirectory, cwd: workingDirectory,
env: {
...process.env,
...(IS_LINUX && {LD_LIBRARY_PATH: path.join(workingDirectory, 'lib')})
},
silent: true, silent: true,
listeners: { listeners: {
stdout: (data: Buffer) => { stdout: (data: Buffer) => {