Skip to content

Commit

Permalink
Add asciinema package (#127)
Browse files Browse the repository at this point in the history
* Add `python.pythonVenv()` to return an empty venv

* Add `asciinema` package

* Update `asciinema` to not use `pythonVenv()`

* Remove `python.pythonVenv()`
  • Loading branch information
kylewlacy authored Oct 16, 2024
1 parent 3bc187d commit 938b9b1
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/asciinema/brioche.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions packages/asciinema/project.bri
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as std from "std";
import { gitCheckout } from "git";
import python from "python";

export const project = {
name: "asciinema",
version: "2.4.0",
};

const source = gitCheckout(
Brioche.gitRef({
repository: "https://github.com/asciinema/asciinema.git",
ref: `v${project.version}`,
}),
);

const pipDependencies = std.directory({
"setuptools-75.1.0-py3-none-any.whl": Brioche.download(
`https://files.pythonhosted.org/packages/ff/ae/f19306b5a221f6a436d8f2238d5b80925004093fa3edea59835b514d9057/setuptools-75.1.0-py3-none-any.whl`,
),
"wheel-0.44.0-py3-none-any.whl": Brioche.download(
"https://files.pythonhosted.org/packages/1b/d1/9babe2ccaecff775992753d8686970b1e2755d21c8a63be73aba7a4e7d77/wheel-0.44.0-py3-none-any.whl",
),
});

export default function (): std.Recipe<std.Directory> {
// Create a venv for asciinema
let venv = std.recipe(python());

// Install setuptools from the archive we downloaded. Setuptools is the
// only dependency we need installed in the venv, the rest will be installed
// by setuptools itself
venv = std.runBash`
pip install setuptools
`
.env({
PATH: std.tpl`${std.outputPath}/bin`,
PIP_FIND_LINKS: pipDependencies,
PIP_NO_INDEX: "1",
})
.outputScaffold(venv)
.toDirectory();

// Install asciinema into the venv
venv = std.runBash`
pip install .
`
.workDir(source)
.env({
PATH: std.tpl`${std.outputPath}/bin`,
PIP_FIND_LINKS: pipDependencies,
PIP_NO_INDEX: "1",
})
.outputScaffold(venv)
.toDirectory();

// Create the final recipe with the venv under `venv`
let recipe = std.directory({
venv,
});

// Add `bin/asciinema` to run the main script
recipe = std.addRunnable(recipe, "bin/asciinema", {
command: { relativePath: "venv/bin/python" },
args: [{ relativePath: "venv/bin/asciinema" }],
});
return std.withRunnableLink(recipe, "bin/asciinema");
}
3 changes: 3 additions & 0 deletions packages/python/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ async function wrapShebangs(
recipe: std.Recipe<std.Directory>,
): Promise<std.Recipe<std.Directory>> {
// Get all the files under `/bin` that are shebang scripts
// NOTE: These scripts can use `#!/bin/sh` when paths are long, so won't
// necessarily have a shebang to call Python directly. See this function:
// https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_vendor/distlib/scripts.py#L154
const shebangPathList = await std.runBash`
cd "$recipe"
find bin -type f -executable \\
Expand Down

0 comments on commit 938b9b1

Please sign in to comment.