-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
pixi run install-as
(#2153)
- Loading branch information
1 parent
db08ac8
commit 60f899a
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |