Skip to content

Commit 286afcb

Browse files
committed
fix: fix library installation via pip + fix conan
1 parent 65c4b0f commit 286afcb

File tree

9 files changed

+50
-35
lines changed

9 files changed

+50
-35
lines changed

dist/actions/setup-cpp.js

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/conan/conan.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { setupPipPack } from "../utils/setup/setupPipPack"
22

33
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4-
export async function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
5-
await setupPipPack("setuptools", "")
4+
export function setupConan(version: string | undefined, _setupDir: string, _arch: string) {
65
return setupPipPack("conan", version)
76
}

src/python/python.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function setupPipx(foundPython: string) {
4545
try {
4646
if (!(await hasPipx(foundPython))) {
4747
try {
48-
await setupPipPackWithPython(foundPython, "pipx", undefined, true)
48+
await setupPipPackWithPython(foundPython, "pipx", undefined, { upgrade: true, usePipx: false })
4949
} catch (err) {
5050
if (isUbuntu()) {
5151
await setupAptPack([{ name: "python3-pipx" }])
@@ -67,8 +67,8 @@ async function setupPipx(foundPython: string) {
6767
/** Setup wheel and setuptools */
6868
async function setupWheel(foundPython: string) {
6969
try {
70-
await setupPipPackWithPython(foundPython, "setuptools", undefined, true)
71-
await setupPipPackWithPython(foundPython, "wheel", undefined, true)
70+
await setupPipPackWithPython(foundPython, "setuptools", undefined, { upgrade: true, isLibrary: true, usePipx: false })
71+
await setupPipPackWithPython(foundPython, "wheel", undefined, { upgrade: true, isLibrary: true, usePipx: false })
7272
} catch (err) {
7373
warning(`Failed to install setuptools or wheel: ${(err as Error).toString()}. Ignoring...`)
7474
}

src/utils/setup/setupPipPack.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,35 @@ import { getVersion } from "../../versions/versions"
1010
import { ubuntuVersion } from "../env/ubuntu_version"
1111
import memoize from "micro-memoize"
1212

13+
export type SetupPipPackOptions = {
14+
/** Whether to use pipx instead of pip */
15+
usePipx?: boolean
16+
/** Whether to install the package as a user */
17+
user?: boolean
18+
/** Whether to upgrade the package */
19+
upgrade?: boolean
20+
/** Whether the package is a library */
21+
isLibrary?: boolean
22+
}
23+
1324
/** A function that installs a package using pip */
14-
export async function setupPipPack(name: string, version?: string, upgrade = false): Promise<InstallationInfo> {
15-
return setupPipPackWithPython(await getPython(), name, version, upgrade)
25+
export async function setupPipPack(
26+
name: string,
27+
version?: string,
28+
options: SetupPipPackOptions = {},
29+
): Promise<InstallationInfo> {
30+
return setupPipPackWithPython(await getPython(), name, version, options)
1631
}
1732

1833
export async function setupPipPackWithPython(
1934
givenPython: string,
2035
name: string,
2136
version?: string,
22-
upgrade = false,
23-
user = true,
37+
options: SetupPipPackOptions = {},
2438
): Promise<InstallationInfo> {
25-
const isPipx = await hasPipx(givenPython)
39+
const { usePipx = true, user = true, upgrade = false, isLibrary = false } = options
40+
41+
const isPipx = usePipx && !isLibrary && (await hasPipx(givenPython))
2642
const pip = isPipx ? "pipx" : "pip"
2743

2844
info(`Installing ${name} ${version ?? ""} via ${pip}`)

0 commit comments

Comments
 (0)