mirror of https://github.com/aminya/setup-cpp
fix: fix library installation via pip + fix conan
This commit is contained in:
parent
65c4b0f5dc
commit
0916dc5cfb
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,6 @@
|
||||||
import { setupPipPack } from "../utils/setup/setupPipPack"
|
import { setupPipPack } from "../utils/setup/setupPipPack"
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export async function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
|
export function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
|
||||||
await setupPipPack("setuptools", "")
|
|
||||||
return setupPipPack("conan", version)
|
return setupPipPack("conan", version)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ async function setupPipx(foundPython: string) {
|
||||||
try {
|
try {
|
||||||
if (!(await hasPipx(foundPython))) {
|
if (!(await hasPipx(foundPython))) {
|
||||||
try {
|
try {
|
||||||
await setupPipPackWithPython(foundPython, "pipx", undefined, true)
|
await setupPipPackWithPython(foundPython, "pipx", undefined, { upgrade: true, usePipx: false })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (isUbuntu()) {
|
if (isUbuntu()) {
|
||||||
await setupAptPack([{ name: "python3-pipx" }])
|
await setupAptPack([{ name: "python3-pipx" }])
|
||||||
|
@ -67,8 +67,12 @@ async function setupPipx(foundPython: string) {
|
||||||
/** Setup wheel and setuptools */
|
/** Setup wheel and setuptools */
|
||||||
async function setupWheel(foundPython: string) {
|
async function setupWheel(foundPython: string) {
|
||||||
try {
|
try {
|
||||||
await setupPipPackWithPython(foundPython, "setuptools", undefined, true)
|
await setupPipPackWithPython(foundPython, "setuptools", undefined, {
|
||||||
await setupPipPackWithPython(foundPython, "wheel", undefined, true)
|
upgrade: true,
|
||||||
|
isLibrary: true,
|
||||||
|
usePipx: false,
|
||||||
|
})
|
||||||
|
await setupPipPackWithPython(foundPython, "wheel", undefined, { upgrade: true, isLibrary: true, usePipx: false })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
warning(`Failed to install setuptools or wheel: ${(err as Error).toString()}. Ignoring...`)
|
warning(`Failed to install setuptools or wheel: ${(err as Error).toString()}. Ignoring...`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,19 +10,35 @@ import { getVersion } from "../../versions/versions"
|
||||||
import { ubuntuVersion } from "../env/ubuntu_version"
|
import { ubuntuVersion } from "../env/ubuntu_version"
|
||||||
import memoize from "micro-memoize"
|
import memoize from "micro-memoize"
|
||||||
|
|
||||||
|
export type SetupPipPackOptions = {
|
||||||
|
/** Whether to use pipx instead of pip */
|
||||||
|
usePipx?: boolean
|
||||||
|
/** Whether to install the package as a user */
|
||||||
|
user?: boolean
|
||||||
|
/** Whether to upgrade the package */
|
||||||
|
upgrade?: boolean
|
||||||
|
/** Whether the package is a library */
|
||||||
|
isLibrary?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/** A function that installs a package using pip */
|
/** A function that installs a package using pip */
|
||||||
export async function setupPipPack(name: string, version?: string, upgrade = false): Promise<InstallationInfo> {
|
export async function setupPipPack(
|
||||||
return setupPipPackWithPython(await getPython(), name, version, upgrade)
|
name: string,
|
||||||
|
version?: string,
|
||||||
|
options: SetupPipPackOptions = {},
|
||||||
|
): Promise<InstallationInfo> {
|
||||||
|
return setupPipPackWithPython(await getPython(), name, version, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setupPipPackWithPython(
|
export async function setupPipPackWithPython(
|
||||||
givenPython: string,
|
givenPython: string,
|
||||||
name: string,
|
name: string,
|
||||||
version?: string,
|
version?: string,
|
||||||
upgrade = false,
|
options: SetupPipPackOptions = {},
|
||||||
user = true,
|
|
||||||
): Promise<InstallationInfo> {
|
): Promise<InstallationInfo> {
|
||||||
const isPipx = await hasPipx(givenPython)
|
const { usePipx = true, user = true, upgrade = false, isLibrary = false } = options
|
||||||
|
|
||||||
|
const isPipx = usePipx && !isLibrary && (await hasPipx(givenPython))
|
||||||
const pip = isPipx ? "pipx" : "pip"
|
const pip = isPipx ? "pipx" : "pip"
|
||||||
|
|
||||||
info(`Installing ${name} ${version ?? ""} via ${pip}`)
|
info(`Installing ${name} ${version ?? ""} via ${pip}`)
|
||||||
|
|
Loading…
Reference in New Issue