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

add binary install commandos #71

Merged
merged 9 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ jobs:
shell: bash
run: |
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }}
PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-${{ matrix.job.target }}
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT

Expand Down
45 changes: 40 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ with package managers like `cargo` or `yarn` but for any language.
* ⚙️ [Examples](../examples)
* 📚 [Documentation](./getting_started.md)
* 😍 [Contributing](#contributing)

# Status

This project is currently in _alpha stage_.
There are many features that we want to add.
The file formats are still in flux.
Expect breaking changes while we work towards a v1.0.
This project is currently in _alpha stage_.
There are many features that we want to add.
The file formats are still in flux.
Expect breaking changes while we work towards a v1.0.

Some notable features that we have in the pipeline are:

Expand All @@ -59,6 +59,26 @@ Some notable features that we have in the pipeline are:
* Improve docs, examples and user experience

# Installation
You can install `pixi` as a binary from the releases.
`pixi` can be installed on macOS, Linux, and Windows.
The provided scripts will automatically download the latest version of `pixi`, extract it, and move the `pixi` binary to `~/.pixi/bin`.
If this directory does not already exist, the script will create it.

## macOS and Linux
To install Pixi on macOS and Linux, open a terminal and run the following command:
```bash
curl -fsSL https://raw.githubusercontent.com/prefix-dev/pixi/main/scripts/install.sh | bash
```
The script will also update your ~/.bash_profile to include ~/.pixi/bin in your PATH, allowing you to invoke the pixi command from anywhere.
You might need to restart your terminal or source your shell for the changes to take effect.

## Windows
To install Pixi on Windows, open a PowerShell terminal (you may need to run it as an administrator) and run the following command:

```powershell
iwr -useb https://raw.githubusercontent.com/prefix-dev/pixi/main/scripts/install.ps1 | iex
```
The script will inform you once the installation is successful and add the ~/.pixi/bin directory to your PATH, which will allow you to run the pixi command from any location.

## Install from source

Expand All @@ -80,6 +100,21 @@ cargo test
If you have any issues building because of the dependency on `rattler` checkout
it's [compile steps](https://github.com/mamba-org/rattler/tree/main#give-it-a-try)

## Uninstall
To uninstall the pixi binary should be removed.
Delete `pixi` from the `$PIXI_DIR` which is default to `~/.pixi/bin/pixi`

So on linux its:
```shell
rm ~/.pixi/bin/pixi
```
and on windows:
```shell
$PIXI_BIN = "$Env:LocalAppData\pixi\bin\pixi"; Remove-Item -Path $PIXI_BIN
```
After this command you can still use the tools you installed with `pixi`.
To remove these as well just remove the whole `~/.pixi` directory and remove the directory from your path.

### Autocompletion

To get autocompletion run:
Expand Down
49 changes: 49 additions & 0 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
param (
[string]$PIXI_VERSION = "latest",
[string]$PIXI_DIR = "$Env:LocalAppData\pixi\bin"
)

# Repository name
$REPO = "prefix-dev/pixi"
$ARCH = "x86_64"
$PLATFORM = "pc-windows-msvc"

$BINARY = "pixi-$ARCH-$PLATFORM"

if ($PIXI_VERSION -eq "latest") {
$DOWNLOAD_URL = "https://github.com/$REPO/releases/latest/download/$BINARY.zip"
} else {
$DOWNLOAD_URL = "https://github.com/$REPO/releases/download/$PIXI_VERSION/$BINARY.zip"
}

Write-Host "This script will automatically download and install Pixi ($PIXI_VERSION) for you."
Write-Host "Getting it from this url: $DOWNLOAD_URL"
Write-Host "The binary will be installed into '$PIXI_DIR'"

$TEMP_FILE = [System.IO.Path]::GetTempFileName()

try {
Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile $TEMP_FILE

# Create the install dir if it doesn't exist
if (!(Test-Path -Path $PIXI_DIR )) {
New-Item -ItemType directory -Path $PIXI_DIR
}

# Extract pixi from the downloaded zip file
Expand-Archive -Path $TEMP_FILE -DestinationPath $PIXI_DIR -Force

# Add pixi to PATH if the folder is not already in the PATH variable
$PATH = [Environment]::GetEnvironmentVariable("Path", "User")
if ($PATH -notlike "*$PIXI_DIR*") {
Write-Output "Adding $PIXI_DIR to PATH`n"
[Environment]::SetEnvironmentVariable("Path", "$PIXI_DIR;" + [Environment]::GetEnvironmentVariable("Path", "User"), "User")
} else {
Write-Output "$PIXI_DIR is already in PATH`n"
}
} catch {
Write-Host "Error: '$DOWNLOAD_URL' is not available or failed to download"
exit 1
} finally {
Remove-Item -Path $TEMP_FILE
}
73 changes: 73 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
set -euo pipefail

__wrap__() {

VERSION=${PIXI_VERSION:-latest}
INSTALL_DIR=${PIXI_DIR:-"$HOME/.pixi/bin"}

REPO=prefix-dev/pixi
PLATFORM=$(uname -s)
ARCH=$(uname -m)

if [[ $PLATFORM == "Darwin" ]]; then
PLATFORM="apple-darwin"
elif [[ $PLATFORM == "Linux" ]]; then
PLATFORM="unknown-linux-musl"
fi

if [[ $ARCH == "arm64" ]] || [[ $ARCH == "aarch64" ]]; then
ARCH="aarch64"
fi



BINARY="pixi-${ARCH}-${PLATFORM}"

if [[ $VERSION == "latest" ]]; then
DOWNLOAD_URL=https://github.com/${REPO}/releases/latest/download/${BINARY}.tar.gz
else
DOWNLOAD_URL=https://github.com/${REPO}/releases/download/${VERSION}/${BINARY}.tar.gz
fi

printf "This script will automatically download and install Pixi (${VERSION}) for you.\nGetting it from this url: $DOWNLOAD_URL\nThe binary will be installed into '$INSTALL_DIR'\n"

if ! hash curl 2> /dev/null; then
echo "error: you do not have 'curl' installed which is required for this script."
exit 1
fi

if ! hash tar 2> /dev/null; then
echo "error: you do not have 'tar' installed which is required for this script."
exit 1
fi

TEMP_FILE=$(mktemp "${TMPDIR:-/tmp}/.pixi_install.XXXXXXXX")

cleanup() {
rm -f "$TEMP_FILE"
}

trap cleanup EXIT

HTTP_CODE=$(curl -SL --progress-bar "$DOWNLOAD_URL" --output "$TEMP_FILE" --write-out "%{http_code}")
if [[ ${HTTP_CODE} -lt 200 || ${HTTP_CODE} -gt 299 ]]; then
echo "error: '${DOWNLOAD_URL}' is not available"
exit 1
fi

# Extract pixi from the downloaded tar file
mkdir -p "$INSTALL_DIR"
tar -xzf "$TEMP_FILE" -C "$INSTALL_DIR"

# Make it executable and add it to the path.
LINE="export PATH=\$PATH:${INSTALL_DIR}"
if ! grep -Fxq "$LINE" ~/.bash_profile
then
echo "$LINE" >> ~/.bash_profile
fi
chmod +x "$INSTALL_DIR/pixi"

echo "Please restart or source your shell."

}; __wrap__