Skip to content

Commit

Permalink
feat: add pixi run install-as (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian authored Sep 30, 2024
1 parent db08ac8 commit 60f899a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ python = "3.12.*"
build = "cargo build --release"
bump = "tbump --only-patch $RELEASE_VERSION"
install = "cargo install --path . --locked"
install-as = { cmd = "python scripts/install.py", depends-on = ["build"] }
pypi-proxy = "python ./tests/pypi_proxy.py"
release = "python scripts/release.py"
run-all-examples = { cmd = "python ./tests/run_all_examples.py --pixi-exec $CARGO_TARGET_DIR/release/pixi", depends-on = [
Expand Down
35 changes: 35 additions & 0 deletions scripts/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import argparse
from pathlib import Path
import shutil
import platform
import os


def executable_extension(name: str) -> str:
if platform.system() == "Windows":
return name + ".exe"
else:
return name


def main() -> None:
parser = argparse.ArgumentParser(
description="Build pixi and copy the executable to ~/.pixi/bin/"
)
parser.add_argument("name", type=str, help="Name of the executable (e.g. pixid)")

args = parser.parse_args()

built_executable_path = Path(os.environ["CARGO_TARGET_DIR"]).joinpath(
"release", executable_extension("pixi")
)
destination_path = Path.home().joinpath(".pixi", "bin", executable_extension(args.name))

print(f"Copying the executable to {destination_path}")
shutil.copy(built_executable_path, destination_path)

print("Done!")


if __name__ == "__main__":
main()

0 comments on commit 60f899a

Please sign in to comment.