Skip to content

Commit

Permalink
Make sure we have a recent enough rustc to build packages
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed May 10, 2024
1 parent 605947d commit bd99bb0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build-packages.yml
Expand Up @@ -183,6 +183,19 @@ jobs:
# Checkout here so we can easily use custom actions
- uses: actions/checkout@v4

# We need a more recent rustc
- name: Install a more recent `rustc`
if: ${{ inputs.source == 'src' }}
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Set rust environment variables
if: ${{ inputs.source == 'src' }}
run: |
CARGO_HOME=${CARGO_HOME:-${HOME}/.cargo}
export CARGO_HOME
echo "CARGO_HOME=${CARGO_HOME}" | tee -a "${GITHUB_ENV}"
echo "${CARGO_HOME}/bin" | tee -a "${GITHUB_PATH}"
# Checkout here for the build process
- name: Checkout in build directory
uses: actions/checkout@v4
Expand Down
15 changes: 15 additions & 0 deletions tools/pkg/build.py
Expand Up @@ -8,6 +8,7 @@
import json
import logging
import os
import os.path
import pathlib
import shutil
import tarfile
Expand Down Expand Up @@ -90,6 +91,20 @@ def debian(
os.environ[key] = value
env_args.extend(["-e", key])

cargo_home = os.environ.get("CARGO_HOME")
user_cargo_bin = os.path.expanduser("~/.cargo/bin")
if os.path.exists(user_cargo_bin):
ctx.info(
f"The path '{user_cargo_bin}' exists so adding --prepend-path={user_cargo_bin}"
)
env_args.append(f"--prepend-path={user_cargo_bin}")
elif cargo_home is not None:
cargo_home_bin = os.path.join(cargo_home, "bin")
ctx.info(
f"The 'CARGO_HOME' environment variable is set, so adding --prepend-path={cargo_home_bin}"
)
env_args.append(f"--prepend-path={cargo_home_bin}")

env = os.environ.copy()
env["PIP_CONSTRAINT"] = str(
tools.utils.REPO_ROOT / "requirements" / "constraints.txt"
Expand Down

0 comments on commit bd99bb0

Please sign in to comment.