prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
3.33k stars 187 forks source link

Simplify exposing local binaries globally #2406

Open certik opened 1 week ago

certik commented 1 week ago

Goal

I want to build a 3rd party project locally and expose the binary into my ~/bin directory. I am on Windows (but I think the issue applies to all platforms).

Workarounds

Here is what I do today, which works, but is too manual, I would like pixi to automate many of these steps.

Let's take ledger (https://github.com/ledger/ledger). I add manual pixi.toml: https://github.com/certik/ledger/blob/9e9d599eb63935129056399c2e524448ac38785c/pixi.toml:

[project]
authors = ["Ondřej Čertík <ondrej@certik.us>"]
channels = ["conda-forge"]
description = "Add a short description here"
name = "ledger"
platforms = ["win-64"]
version = "0.1.0"

[tasks]
build = "cmake -GNinja -B build -DBoost_USE_STATIC_LIBS=OFF -DBUILD_LIBRARY=off . && cmake --build build -j 8"
run = "build/ledger.exe"
install = "cp build/ledger.exe .pixi/envs/default/Library/bin/"

[dependencies]
cmake = ">=3.30.5,<4"
boost = "1.72.*"
gmp = ">=6.3.0,<7"
mpfr = ">=4.2.1,<5"

I build it, which creates a binary in build/ledger.exe:

$ pixi r build

If I do pixi r run then the binary works, however there are two issues:

Now when I start a new shell, I can just type ledger and everything just works (I have ~/bin in my $PATH).

Feature Requests

  1. I would like pixi to automate the install = "cp build/ledger.exe .pixi/envs/default/Library/bin/" part. For example, I can just cmake install into some prefix as part of some task. However modifying the default environment manually is probably not the right approach?
  2. I would like pixi to automatically create the "symlink" (.bat file) above to expose the binary.

Pixi can almost do this with pixi global, it puts these binaries as .bat files into ~/.pixi/bin which I have in my path. However it seems to only work with existing conda packages, not my current project. So if the global feature could be extended to just work for a local project, as well as ensuring the binary lives with the .dll libraries in the same directory, then that would fix everything.

Hofer-Julian commented 1 week ago

Yes, as soon as pixi build is out we plan to add this functionality

ruben-arts commented 1 week ago

Hey @certik,

I didn't figure out how to pass arguments to it (is there a way?)

All words after pixi run will be forwarded to the run shell. So pixi run YOUR_TASK this-is-appended-to-your-task. We don't have a way yet to do this between depending tasks.