Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add trampoline for pixi global #2381

Merged
merged 9 commits into from
Nov 5, 2024
Merged

Conversation

Hofer-Julian
Copy link
Contributor

@Hofer-Julian Hofer-Julian commented Oct 30, 2024

TODO:

  • Implement hardlinked trampoline to reuse the binary.

nichmor and others added 5 commits October 21, 2024 18:23
I took a few shortcuts but this is a prototype of the trampoline.

upd @nichmor : no more a prototype :D

things on how to test this:

- [ ] verify that it correctly migrates a global installed binary from
.sh/.bat to trampoline.
 this can be done by following:
 using previous `pixi`:
`pixi global install python` and then ` cargo run -- global install
python`.
`python` should be in a working state, and by looking into `cat
/Users/graf/.pixi/bin/python` you should see that is a binary code , not
a script anymore
- [ ] using following code, and when running it with global installed
python and pressing CTRL-C you should see
`CTRL-C caught! Successful termination.`
<details>

```
import signal
import time

def signal_handler(sig, frame):
    print("\nCTRL-C caught! Successful termination.")
    exit(0)

# Register the signal handler for SIGINT (CTRL-C)
signal.signal(signal.SIGINT, signal_handler)

print("Press CTRL-C to stop the script.")

# Simulating some work with an infinite loop
try:
    while True:
        time.sleep(1)  # Keeps the script running
except KeyboardInterrupt:
    # You can also handle it here, but we already have the signal handler
    pass
```
</details>

- [ ] test if `pixi global install` behave correctly in different shells

---------

Co-authored-by: nichmor <nmorkotilo@gmail.com>
Co-authored-by: Julian Hofer <julianhofer@gnome.org>
Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com>
Co-authored-by: Ruben Arts <ruben.arts@hotmail.com>
@nichmor
Copy link
Contributor

nichmor commented Nov 4, 2024

to reiterate missing things:

  • making hard links of trampoline when installing rather than duplicating them
  • compressing trampoline binary itself to include a smaller sized thing in pixi
  • testing

@Hofer-Julian
Copy link
Contributor Author

Testing:

Preparation

  • cp -r ~/.pixi ~/.pixi-backup

Things we should test:

  • Migration with pixi global sync
  • Is everything there? Does pixi global list work? Are the binaries working?
  • pixi global install $your_favorite_binaries
  • pixi global add $something
  • pixi global remove $something
  • pixi global edit and pixi global sync
  • rm -rf ~/.pixi
  • cp -r ~/.pixi-backup ~/.pixi
  • Delete some files in ~/.pixi/bin and/or ~/.pixi/envs
  • Run pixi global sync
  • Is the result expected?

nichmor and others added 2 commits November 5, 2024 14:28
@wolfv
Copy link
Member

wolfv commented Nov 5, 2024

Here are a few things I tried:

  1. Launch Python and check that it has no parent process other than zsh: Looks good!
$ pstree -s python
-+= 00001 root /sbin/launchd
 |-+= 02808 wolfv /Applications/iTerm.app/Contents/MacOS/iTerm2
 | \-+- 02810 wolfv /Users/wolfv/Library/Application Support/iTerm2/iTermServer-3.5.5 /Users/wolfv/Library/Application Support/iTerm2/iterm2-daemon-1.socket
 |   |-+= 67889 root /usr/bin/login -fpl wolfv /Applications/iTerm.app/Contents/MacOS/ShellLauncher --launch_shell
 |   | \-+= 67891 wolfv -zsh
 |   |   \--= 76396 wolfv /Users/wolfv/.pixi/envs/python/bin/python
  1. Launch Python and press CTRL+C and CTRL+D, both work as expected
  2. Check that we get the correct exit code: while this looks wrong, it's the same without the trampoline. We might want to double check on Linux and Win.
╰─$ ~/.pixi/envs/python/bin/python
Python 3.13.0 | packaged by conda-forge | (main, Oct 17 2024, 12:32:35) [Clang 17.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(123)
╭─wolfv@pixi ~/Programs/pixi ‹feat/global-trampoline●›
╰─$ echo $?                                                                                                                                                                                                                                                               

1
  1. Installed and started Spyder: GUI program works as well!

@ruben-arts ruben-arts enabled auto-merge (squash) November 5, 2024 15:42
@ruben-arts ruben-arts disabled auto-merge November 5, 2024 15:42
@ruben-arts ruben-arts merged commit 019c102 into main Nov 5, 2024
50 checks passed
@ruben-arts ruben-arts deleted the feat/global-trampoline branch November 5, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants