mirror of https://github.com/aminya/setup-cpp
feat: add python installation
ci: enable submodules in the ci Update setup-python
This commit is contained in:
parent
3defe39318
commit
79e1c66874
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"extends": "eslint-config-atomic",
|
"extends": "eslint-config-atomic",
|
||||||
"ignorePatterns": ["dist/", "node_modules/"]
|
"ignorePatterns": ["dist/", "node_modules/", "src/python/setup-python/"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ jobs:
|
||||||
- 6
|
- 6
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
- name: Cache
|
- name: Cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
[submodule "src/python/setup-python"]
|
||||||
|
path = src/python/setup-python
|
||||||
|
url = https://github.com/actions/setup-python
|
||||||
|
branch = main
|
|
@ -4,3 +4,4 @@ package-lock.json
|
||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
dist
|
dist
|
||||||
stats.html
|
stats.html
|
||||||
|
src/python/setup-python/
|
|
@ -4,6 +4,7 @@ setup-cpp reused some code from the following projects:
|
||||||
- [install-cmake](https://github.com/Symbitic/install-cmake/blob/master/LICENSE.md): MIT
|
- [install-cmake](https://github.com/Symbitic/install-cmake/blob/master/LICENSE.md): MIT
|
||||||
- [get-cmake](https://github.com/lukka/get-cmake/blob/main/LICENSE.txt): MIT
|
- [get-cmake](https://github.com/lukka/get-cmake/blob/main/LICENSE.txt): MIT
|
||||||
- [gha-setup-ninja](https://github.com/seanmiddleditch/gha-setup-ninja): MIT
|
- [gha-setup-ninja](https://github.com/seanmiddleditch/gha-setup-ninja): MIT
|
||||||
|
- [setup-python](https://github.com/actions/setup-python): MIT
|
||||||
|
|
||||||
This package also uses the depedencies listed in package.json. You can get the list of their licenses using the following command:
|
This package also uses the depedencies listed in package.json. You can get the list of their licenses using the following command:
|
||||||
```
|
```
|
||||||
|
|
|
@ -19,6 +19,7 @@ The package will be usable from any environment (locally, GitHub Actions, etc).
|
||||||
- [x] setup conan
|
- [x] setup conan
|
||||||
- [x] setup meson
|
- [x] setup meson
|
||||||
- [x] setup gcovr
|
- [x] setup gcovr
|
||||||
|
- [x] setup python
|
||||||
- [ ] setup msvc
|
- [ ] setup msvc
|
||||||
- [ ] setup gcc/mingw
|
- [ ] setup gcc/mingw
|
||||||
- [ ] setup vcpkg
|
- [ ] setup vcpkg
|
||||||
|
|
|
@ -26,6 +26,10 @@ inputs:
|
||||||
gcovr:
|
gcovr:
|
||||||
description: "The gcovr version to install."
|
description: "The gcovr version to install."
|
||||||
required: false
|
required: false
|
||||||
|
python:
|
||||||
|
description: "The pyhon version to install."
|
||||||
|
default: "3.x"
|
||||||
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node12"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"clean": "shx rm -rf dist",
|
"clean": "shx rm -rf dist",
|
||||||
"dev": "cross-env NODE_ENV=development parcel watch",
|
"dev": "cross-env NODE_ENV=development parcel watch",
|
||||||
"build": "cross-env NODE_ENV=production parcel build --detailed-report",
|
"build": "cross-env NODE_ENV=production parcel build --detailed-report",
|
||||||
"prepare": "npm run build",
|
"prepare": "git submodule update --init --recursive && npm run build",
|
||||||
"test.format": "prettier . --check",
|
"test.format": "prettier . --check",
|
||||||
"test.lint": "eslint .",
|
"test.lint": "eslint .",
|
||||||
"test.tsc": "tsc --noEmit",
|
"test.tsc": "tsc --noEmit",
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { setupGcovr } from "./gcovr/gcovr"
|
||||||
import { setupLLVM } from "./llvm/llvm"
|
import { setupLLVM } from "./llvm/llvm"
|
||||||
import { setupMeson } from "./meson/meson"
|
import { setupMeson } from "./meson/meson"
|
||||||
import { setupNinja } from "./ninja/ninja"
|
import { setupNinja } from "./ninja/ninja"
|
||||||
|
import { setupPython } from "./python/python"
|
||||||
|
|
||||||
function maybeGetInput(key: string) {
|
function maybeGetInput(key: string) {
|
||||||
const value = core.getInput(key)
|
const value = core.getInput(key)
|
||||||
|
@ -15,6 +16,7 @@ function maybeGetInput(key: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function main(): Promise<number> {
|
export async function main(): Promise<number> {
|
||||||
|
const arch = core.getInput("architecture") || process.arch
|
||||||
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
|
const setupCppDir = process.env.SETUP_CPP_DIR ?? "~/setup_cpp"
|
||||||
try {
|
try {
|
||||||
// setup cmake
|
// setup cmake
|
||||||
|
@ -29,6 +31,12 @@ export async function main(): Promise<number> {
|
||||||
await setupNinja(ninjaVersion, setupCppDir)
|
await setupNinja(ninjaVersion, setupCppDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup python (required for conan, meson, gcovr, etc.)
|
||||||
|
const pythonVersion = maybeGetInput("python")
|
||||||
|
if (pythonVersion !== undefined) {
|
||||||
|
await setupPython(pythonVersion, arch)
|
||||||
|
}
|
||||||
|
|
||||||
// setup conan
|
// setup conan
|
||||||
const conanVersion = maybeGetInput("conan")
|
const conanVersion = maybeGetInput("conan")
|
||||||
if (conanVersion !== undefined) {
|
if (conanVersion !== undefined) {
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import * as core from "@actions/core"
|
||||||
|
import * as finder from "./setup-python/src/find-python"
|
||||||
|
import * as finderPyPy from "./setup-python/src/find-pypy"
|
||||||
|
import * as path from "path"
|
||||||
|
import * as os from "os"
|
||||||
|
|
||||||
|
function isPyPyVersion(versionSpec: string) {
|
||||||
|
return versionSpec.startsWith("pypy-")
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setupPython(version?: string, arch: string = os.arch()) {
|
||||||
|
try {
|
||||||
|
if (version !== undefined && version !== "") {
|
||||||
|
if (isPyPyVersion(version)) {
|
||||||
|
const installed = await finderPyPy.findPyPyVersion(version, arch)
|
||||||
|
core.info(
|
||||||
|
`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
const installed = await finder.findPythonVersion(version, arch)
|
||||||
|
core.info(`Successfully setup ${installed.impl} (${installed.version})`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const matchersPath = path.join(__dirname, "..", ".github")
|
||||||
|
core.info(`##[add-matcher]${path.join(matchersPath, "python.json")}`)
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed((err as Error).message)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 2d803e7feaf26323835f529f28efa6400f18ad01
|
|
@ -27,5 +27,6 @@
|
||||||
"outDir": "./dist"
|
"outDir": "./dist"
|
||||||
},
|
},
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"include": ["./src"]
|
"include": ["./src"],
|
||||||
|
"exclude": ["./src/python/setup-python"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue