Skip to content

Commit

Permalink
fix(python): use pkg-config on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
deciduously committed Feb 4, 2025
1 parent f82daa8 commit 4cbaa48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/python/requirements.tg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { $ } from "std" with { path: "../std" };
import { versionString, wrapScripts } from "./tangram.ts";
export type Arg = tg.File;

export const install = tg.command(async (pythonArtifact: tg.Directory, requirements: Arg) => {
export const install = tg.command(
async (pythonArtifact: tg.Directory, requirements: Arg) => {
// Construct an env with the standard C/C++ sdks, the Rust toolchain, and Python.
const toolchains = std.env.arg(std.sdk(), rust.self(), pythonArtifact);

Expand Down Expand Up @@ -88,7 +89,8 @@ export const install = tg.command(async (pythonArtifact: tg.Directory, requireme
await tg`${installed}/lib/python3/site-packages`,
installed,
);
});
},
);

/** Detect any potentially conflicting installations in a site-packages directory and merge if necessary. */
const mergeSitePackages = async (output: tg.Directory, input: tg.Directory) => {
Expand Down
15 changes: 10 additions & 5 deletions packages/python/tangram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as mpdecimal from "mpdecimal" with { path: "../mpdecimal" };
import * as ncurses from "ncurses" with { path: "../ncurses" };
import * as openssl from "openssl" with { path: "../openssl" };
import * as pkgConf from "pkgconf" with { path: "../pkgconf" };
import * as pkgConfig from "pkg-config" with { path: "../pkg-config" };
import * as readline from "readline" with { path: "../readline" };
import * as sqlite from "sqlite" with { path: "../sqlite" };
import * as zlib from "zlib" with { path: "../zlib" };
Expand Down Expand Up @@ -113,14 +114,18 @@ export const self = tg.command(async (...args: std.Args<Arg>) => {
) => std.env.envArgFromDependency(build, env_, host, sdk, dep);

const dependencies = [
std.env.buildDependency(bison.build, dependencyArgs.bison),
std.env.buildDependency(m4.build, dependencyArgs.m4),
std.env.buildDependency(pkgConf.build, dependencyArgs.pkgConf),
std.env.buildDependency(bison.build),
std.env.buildDependency(m4.build),
std.env.runtimeDependency(bzip2.build, dependencyArgs.bzip2),
std.env.runtimeDependency(libxcrypt.build, dependencyArgs.libxcrypt),
std.env.runtimeDependency(ncurses.build, dependencyArgs.ncurses),
std.env.runtimeDependency(readline.build, dependencyArgs.readline),
].map(processDependency);
];
if (os === "darwin") {
dependencies.push(std.env.buildDependency(pkgConf.build));
} else if (os === "linux") {
dependencies.push(std.env.buildDependency(pkgConfig.build));
}

// Set up additional runtime dependencies that will end up in the wrapper.
const libffiForHost = await processDependency(
Expand All @@ -138,7 +143,7 @@ export const self = tg.command(async (...args: std.Args<Arg>) => {

// Resolve env.
const envs: Array<tg.Unresolved<std.env.Arg>> = [
...dependencies,
...dependencies.map(processDependency),
libffiForHost,
mpdecimalForHost,
opensslForHost,
Expand Down

0 comments on commit 4cbaa48

Please sign in to comment.