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

Fix installer.sh to only require /bin/sh. #141

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Changes from 5 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
147 changes: 30 additions & 117 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -39,28 +39,28 @@ jobs:
include:
- os: ubuntu-24.04
name: Linux x86-64 (musl)
docker-image: python:3.12-alpine
docker-platform: linux/amd64
image: alpine
arch: amd64
- os: ubuntu-24.04
name: Linux x86-64 (glibc)
docker-image: python:3.12-bookworm
docker-platform: linux/amd64
image: debian
arch: amd64
- os: ubuntu-24.04
name: Linux aarch64
docker-image: python:3.12-bookworm
docker-platform: linux/arm64
image: debian
arch: arm64
- os: ubuntu-24.04
name: Linux armv7l
docker-image: python:3.12-bookworm
docker-platform: linux/arm/v7
image: debian
arch: arm/v7
- os: ubuntu-24.04
name: Linux s390x
docker-image: python:3.12-bookworm
docker-platform: linux/s390x
image: debian
arch: s390x
- os: ubuntu-24.04
name: Linux powerpc64le
docker-image: python:3.12-bookworm
docker-platform: linux/ppc64le
image: debian
arch: ppc64le
- os: macos-13
name: macOS x86-64
- os: macos-14
@@ -74,10 +74,10 @@ jobs:
SCIENCE_AUTH_API_GITHUB_COM_BEARER: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Install the latest version of uv
if: matrix.docker-image == '' && matrix.os != 'windows-arm64'
if: matrix.os != 'windows-arm64'
uses: astral-sh/setup-uv@v5
- name: Setup uv
if: matrix.docker-image == '' && matrix.os != 'windows-arm64'
if: matrix.os != 'windows-arm64'
run: |
export UV="$(which uv)"
"${UV}" -V
@@ -106,9 +106,6 @@ jobs:
UV_PYTHON_VERSION=cpython-3.12.9-windows-x86_64-none
"${UV}" python install ${UV_PYTHON_VERSION}
echo UV_PYTHON="${UV_PYTHON_VERSION}" >> ${GITHUB_ENV}
- name: Installing emulators
if: matrix.docker-image != ''
run: docker run --privileged --rm tonistiigi/binfmt --install all
- name: Checkout Lift
uses: actions/checkout@v4
- name: Restore MyPy Cache
@@ -121,32 +118,14 @@ jobs:
key: ${{ matrix.docker-platform || format('{0}-{1}', matrix.os, runner.arch) }}-a-scie-lift-mypy-v1-${{ github.run_id }}
restore-keys: ${{ matrix.docker-platform || format('{0}-{1}', matrix.os, runner.arch) }}-a-scie-lift-mypy-v1
- name: Check Formatting & Lints
if: matrix.docker-image == ''
if: matrix.image == ''
run: |
"${UV}" run dev-cmd ci --skip test
- name: Check Formatting & Lints
if: matrix.docker-image != ''
if: matrix.image != ''
run: |
cat << EOF > _fmt_lint_check.sh
pip install --root-user-action ignore uv
addgroup --gid $(id -g) build
if [ "${{ matrix.docker-image }}" = "python:3.12-alpine" ]; then
adduser -D -g '' -G build -u $(id -u) build
apk add gcc git linux-headers musl-dev python3-dev
else
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build
fi

su build -c 'uv run dev-cmd ci --skip test'
EOF

docker run --rm \
-e FORCE_COLOR \
-e SCIENCE_AUTH_API_GITHUB_COM_BEARER \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
${{ matrix.docker-image }} sh -eu _fmt_lint_check.sh
"${UV}" run dev-cmd docker -- --image ${{ matrix.image }} --arch ${{ matrix.arch }} \
ci --skip test
- name: Cache MyPy
uses: actions/cache/save@v4
if: github.ref == 'refs/heads/main'
@@ -160,98 +139,32 @@ jobs:
echo PYTEST_ADDOPTS="--basetemp C:/tmp/gha/pytest" >> ${GITHUB_ENV}
echo SCIE_BASE=C:/tmp/gha/nce >> ${GITHUB_ENV}
- name: Unit Tests
if: matrix.docker-image == ''
if: matrix.image == ''
run: |
"${UV}" run dev-cmd test -- -vvs
- name: Unit Tests
if: matrix.docker-image != ''
if: matrix.image != ''
run: |
cat << EOF > _test.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this yaml-thrash and the paired intro of scripts/docker/uv.py was just so I could test the install.sh changes locally via uvrc docker -- --image alpine test -- -vvsk test_installer (where uvrc is my alias for uv run dev-cmd). The upshot of streamlined yaml / an easy way to repro CI locally is, of course, generally good.

if [ "${{ matrix.docker-platform }}" = "linux/s390x" ]; then
# This hack gets the PyPy provider tests working on this image. The old PyPy s390x
# distributions dynamically link libffi at an older version than I've been able to
# find a multi-platform image with s390x support for.
ln -s /usr/lib/s390x-linux-gnu/libffi.so.8 /usr/lib/s390x-linux-gnu/libffi.so.6
elif [ "${{ matrix.docker-platform }}" = "linux/ppc64le" ]; then
echo "Skipping tests on ppc64le."
exit 0
fi

pip install --root-user-action ignore uv
addgroup --gid $(id -g) build
if [ "${{ matrix.docker-image }}" = "python:3.12-alpine" ]; then
adduser -D -g '' -G build -u $(id -u) build
# N.B.: The bash and curl packages are additional needs for tests. The rest just
# supports building the psutil wheel needed for the science Python distribution.
apk add bash curl gcc git linux-headers musl-dev python3-dev
else
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build
fi

su build -c "uv run dev-cmd test -- -vvs"
EOF

docker run --rm \
-e FORCE_COLOR \
-e SCIENCE_AUTH_API_GITHUB_COM_BEARER \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
${{ matrix.docker-image }} sh -eu _test.sh
"${UV}" run dev-cmd docker -- --image ${{ matrix.image }} --arch ${{ matrix.arch }} \
test -- -vvs
- name: Build & Package
if: matrix.docker-image == ''
if: matrix.image == ''
run: |
"${UV}" run dev-cmd package
- name: Build & Package
if: matrix.docker-image != ''
if: matrix.image != ''
run: |
cat << EOF > _package.sh
pip install --root-user-action ignore uv
addgroup --gid $(id -g) build
if [ "${{ matrix.docker-image }}" = "python:3.12-alpine" ]; then
adduser -D -g '' -G build -u $(id -u) build
apk add gcc git linux-headers musl-dev python3-dev
else
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build
fi

su build -c 'uv run dev-cmd package'
EOF

docker run --rm \
-e FORCE_COLOR \
-e SCIENCE_AUTH_API_GITHUB_COM_BEARER \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
${{ matrix.docker-image }} sh -eu _package.sh
"${UV}" run dev-cmd docker -- --image ${{ matrix.image }} --arch ${{ matrix.arch }} \
package
- name: Generate Doc Site
if: matrix.docker-image == ''
if: matrix.image == ''
run: |
"${UV}" run dev-cmd doc linkcheck
- name: Generate Doc Site
if: matrix.docker-image != ''
if: matrix.image != ''
run: |
cat << EOF > _doc_linkcheck.sh
pip install --root-user-action ignore uv
addgroup --gid $(id -g) build
if [ "${{ matrix.docker-image }}" = "python:3.12-alpine" ]; then
adduser -D -g '' -G build -u $(id -u) build
apk add gcc git linux-headers musl-dev python3-dev
else
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build
fi

su build -c 'uv run dev-cmd doc linkcheck'
EOF

docker run --rm \
-e FORCE_COLOR \
-e SCIENCE_AUTH_API_GITHUB_COM_BEARER \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
${{ matrix.docker-image }} sh -eu _doc_linkcheck.sh
"${UV}" run dev-cmd docker -- --image ${{ matrix.image }} --arch ${{ matrix.arch }} \
doc linkcheck
- name: Cleanup
if: always()
run: |
56 changes: 19 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -56,28 +56,28 @@ jobs:
include:
- os: ubuntu-24.04
name: Linux x86-64 (musl)
docker-image: python:3.12-alpine
docker-platform: linux/amd64
image: alpine
arch: amd64
- os: ubuntu-24.04
name: Linux x86-64 (glibc)
docker-image: python:3.12-bookworm
docker-platform: linux/amd64
image: debian
arch: amd64
- os: ubuntu-24.04
name: Linux aarch64
docker-image: python:3.12-bookworm
docker-platform: linux/arm64
image: debian
arch: arm64
- os: ubuntu-24.04
name: Linux armv7l
docker-image: python:3.12-bookworm
docker-platform: linux/arm/v7
image: debian
arch: arm/v7
- os: ubuntu-24.04
name: Linux s390x
docker-image: python:3.12-bookworm
docker-platform: linux/s390x
image: debian
arch: s390x
- os: ubuntu-24.04
name: Linux powerpc64le
docker-image: python:3.12-bookworm
docker-platform: linux/ppc64le
image: debian
arch: ppc64le
- os: macos-13
name: macOS x86-64
- os: macos-14
@@ -97,10 +97,10 @@ jobs:
discussions: write
steps:
- name: Install the latest version of uv
if: matrix.docker-image == '' && matrix.os != 'windows-arm64'
if: matrix.os != 'windows-arm64'
uses: astral-sh/setup-uv@v5
- name: Setup uv
if: matrix.docker-image == '' && matrix.os != 'windows-arm64'
if: matrix.os != 'windows-arm64'
run: |
export UV="$(which uv)"
"${UV}" -V
@@ -130,39 +130,21 @@ jobs:
"${UV}" python install ${UV_PYTHON_VERSION}
echo UV_PYTHON_ARGS="--python ${UV_PYTHON_VERSION}" >> ${GITHUB_ENV}
- name: Installing emulators
if: matrix.docker-image != ''
if: matrix.image != ''
run: docker run --privileged --rm tonistiigi/binfmt --install all
- name: Checkout lift ${{ needs.determine-tag.outputs.release-tag }}
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-tag.outputs.release-tag }}
- name: Package science ${{ needs.determine-tag.outputs.release-tag }} binary
if: matrix.docker-image == ''
if: matrix.image == ''
run: |
"${UV}" run ${UV_PYTHON_ARGS} dev-cmd package
- name: Package science ${{ needs.determine-tag.outputs.release-tag }} binary
if: matrix.docker-image != ''
if: matrix.image != ''
run: |
cat << EOF > _package.sh
pip install --root-user-action ignore uv
addgroup --gid $(id -g) build
if [ "${{ matrix.docker-image }}" = "python:3.12-alpine" ]; then
adduser -D -g '' -G build -u $(id -u) build
apk add gcc git linux-headers musl-dev python3-dev
else
adduser --disabled-password --gecos '' --gid $(id -g) --uid $(id -u) build
fi

su build -c 'uv run dev-cmd package'
EOF

docker run --rm \
-e FORCE_COLOR \
-e SCIENCE_AUTH_API_GITHUB_COM_BEARER \
-v $PWD:/code \
-w /code \
--platform ${{ matrix.docker-platform }} \
${{ matrix.docker-image }} sh -eu _package.sh
"${UV}" run dev-cmd docker -- --image ${{ matrix.image }} --arch ${{ matrix.arch }} \
package
- name: Generate science ${{ needs.determine-tag.outputs.release-tag }} artifact attestations
uses: actions/attest-build-provenance@v1
with:
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,3 +13,6 @@ __pycache__/
# Our Sphinx extension (see: docs/_ext/) dynamically generates doc sources here.
/docs/_/

# Various files are copied from the project root to here for building docker images.
/scripts/docker/ephemeral-build-context/

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ like so:

+ Linux and macOS:
```
curl --proto '=https' --tlsv1.2 -LSsf https://raw.githubusercontent.com/a-scie/lift/main/install.sh | bash
curl --proto '=https' --tlsv1.2 -LSsf https://raw.githubusercontent.com/a-scie/lift/main/install.sh | sh
```
+ Windows PowerShell:
```
79 changes: 44 additions & 35 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
#!/usr/bin/env bash
#!/bin/sh
# Copyright 2024 Science project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

set -euo pipefail
set -eu

COLOR_RED="\x1b[31m"
COLOR_GREEN="\x1b[32m"
COLOR_YELLOW="\x1b[33m"
COLOR_RESET="\x1b[0m"

function log() {
echo -e "$@" 1>&2
log() {
echo -e "$@" >&2
}

function die() {
(($# > 0)) && log "${COLOR_RED}$*${COLOR_RESET}"
die() {
[ "$#" -gt 0 ] && log "${COLOR_RED}$*${COLOR_RESET}"
exit 1
}

function green() {
(($# > 0)) && log "${COLOR_GREEN}$*${COLOR_RESET}"
green() {
[ "$#" -gt 0 ] && log "${COLOR_GREEN}$*${COLOR_RESET}"
}

function warn() {
(($# > 0)) && log "${COLOR_YELLOW}$*${COLOR_RESET}"
warn() {
[ "$#" -gt 0 ] && log "${COLOR_YELLOW}$*${COLOR_RESET}"
}

function ensure_cmd() {
ensure_cmd() {
local cmd="$1"
command -v "$cmd" > /dev/null || die "This script requires the ${cmd} binary to be on \$PATH."
}

ISSUES_URL="https://github.com/a-scie/lift/issues"
_GC=()
_GC=""

ensure_cmd rm
function gc() {
if (($# > 0)); then
_GC+=("$@")
gc() {
if [ "$#" -gt 0 ]; then
_GC=" $@"
else
# Check if $_GC has members to avoid "unbound variable" warnings if gc w/ arguments is never
# called.
if ! [ ${#_GC[@]} -eq 0 ]; then
rm -rf "${_GC[@]}"
if [ -n "${_GC}" ]; then
rm -rf "${_GC}"
fi
fi
}

trap gc EXIT

ensure_cmd uname
function determine_os() {
determine_os() {
local os

os="$(uname -s)"
if [[ "${os}" =~ [Ll]inux ]]; then
if echo "${os}" | grep -E "[Ll]inux" >/dev/null; then
echo linux
elif [[ "${os}" =~ [Dd]arwin ]]; then
elif echo "${os}" | grep -E "[Dd]arwin" >/dev/null; then
echo macos
elif [[ "${os}" =~ [Ww]indow|[Mm][Ii][Nn][Gg] ]]; then
elif echo "${os}" | grep -E "[Ww]indow|[Mm][Ii][Nn][Gg]" >/dev/null; then
# Powershell reports something like: Windows_NT
# Git bash reports something like: MINGW64_NT-10.0-22621
echo windows
@@ -69,7 +69,15 @@ function determine_os() {

OS="$(determine_os)"

function determine_arch() {
determine_variant() {
if [ "${OS}" = "linux" ] && ldd /bin/sh 2>/dev/null | grep musl >/dev/null; then
echo "musl-"
else
echo ""
fi
}

determine_arch() {
# Map platform architecture to released binary architecture.
read_arch="$(uname -m)"
case "$read_arch" in
@@ -87,7 +95,7 @@ function determine_arch() {

ensure_cmd basename
ensure_cmd curl
function fetch() {
fetch() {
local url="$1"
local dest_dir="$2"

@@ -99,8 +107,8 @@ function fetch() {
curl --proto '=https' --tlsv1.2 -SfL --progress-bar -o "${dest}" "${url}"
}

ensure_cmd $([[ "${OS}" == "macos" ]] && echo "shasum" || echo "sha256sum")
function sha256() {
ensure_cmd $([ "${OS}" == "macos" ] && echo "shasum" || echo "sha256sum")
sha256() {
if [[ "${OS}" == "macos" ]]; then
shasum --algorithm 256 "$@"
else
@@ -113,7 +121,7 @@ ensure_cmd mktemp
ensure_cmd install
ensure_cmd tr
ensure_cmd mv
function install_from_url() {
install_from_url() {
local url="$1"
local dest="$2"

@@ -126,19 +134,19 @@ function install_from_url() {
(
cd "${workdir}"

if [[ "${OS}" == "windows" ]]; then
if [ "${OS}" = "windows" ]; then
# N.B. Windows sha256sum is sensitive to trailing \r in files.
cat *.sha256 | tr -d "\r" > out.sanitized
mv -f out.sanitized *.sha256
fi

sha256 -c --status ./*.sha256 &&
sha256 -c ./*.sha256 >/dev/null &&
green "Download matched it's expected sha256 fingerprint, proceeding" ||
die "Download from ${url} did not match the fingerprint at ${url}.sha256"
)
rm "${workdir}/"*.sha256

if [[ "${OS}" == "macos" ]]; then
if [ "${OS}" = "macos" ]; then
mkdir -p "$(dirname "${dest}")"
install -m 755 "${workdir}/"* "${dest}"
else
@@ -149,7 +157,7 @@ function install_from_url() {
}

ensure_cmd cat
function usage() {
usage() {
cat << __EOF__
Usage: $0
@@ -172,7 +180,7 @@ INSTALL_PREFIX="${HOME}/.local/bin"
VERSION="latest/download"

# Parse arguments.
while (($# > 0)); do
while [ "$#" -gt 0 ]; do
case "$1" in
--help | -h)
usage
@@ -195,17 +203,18 @@ while (($# > 0)); do
done

ARCH="$(determine_arch)"
DIRSEP=$([[ "${OS}" == "windows" ]] && echo "\\" || echo "/")
EXE_EXT=$([[ "${OS}" == "windows" ]] && echo ".exe" || echo "")
VARIANT="$(determine_variant)"
DIRSEP=$([ "${OS}" == "windows" ] && echo "\\" || echo "/")
EXE_EXT=$([ "${OS}" = "windows" ] && echo ".exe" || echo "")

INSTALL_DEST="${INSTALL_PREFIX}${DIRSEP}science${EXE_EXT}"
DL_URL="https://github.com/a-scie/lift/releases/${VERSION}/science-fat-${OS}-${ARCH}${EXE_EXT}"
DL_URL="https://github.com/a-scie/lift/releases/${VERSION}/science-fat-${VARIANT}${OS}-${ARCH}${EXE_EXT}"

green "Download URL is: ${DL_URL}"
install_from_url "${DL_URL}" "${INSTALL_DEST}"

# Warn if the install prefix is not on $PATH.
if ! [[ ":$PATH:" == *":${INSTALL_PREFIX}:"* ]]; then
if ! echo ":$PATH:" | grep ":${INSTALL_PREFIX}:" >/dev/null; then
warn "WARNING: ${INSTALL_PREFIX} is not detected on \$PATH"
warn "You'll either need to invoke ${INSTALL_DEST} explicitly or else add ${INSTALL_PREFIX} \
to your shell's PATH."
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -101,6 +101,11 @@ check-lint = ["ruff", "check"]

type-check = ["mypy", "docs/_ext", "science", "scripts", "setup.py", "tests", "test-support"]

[tool.dev-cmd.commands.docker]
args = ["scripts/docker/uv.py"]
accepts-extra-args = true
hidden = true

[tool.dev-cmd.commands.create-zipapp]
args = ["scripts/create-zipapp.py"]
hidden = true
16 changes: 16 additions & 0 deletions scripts/docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.12-alpine

ARG UID
ARG GID

RUN pip install --root-user-action ignore uv && \
addgroup --gid $GID build && \
adduser -D -g '' -G build -u $UID build && \
apk add \
bash \
curl \
gcc \
git \
linux-headers \
musl-dev \
python3-dev
11 changes: 11 additions & 0 deletions scripts/docker/debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.12-bookworm

ARG UID
ARG GID

RUN pip install --root-user-action ignore uv && \
addgroup --gid ${GID} build && \
adduser --disabled-password --gecos '' --gid ${GID} --uid ${UID} build

COPY post-install.sh /post-install.sh
RUN /post-install.sh && rm /post-install.sh
10 changes: 10 additions & 0 deletions scripts/docker/debian/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh

set -eu

if [ "$(uname -m)" = "s390x" ]; then
# This hack gets the PyPy provider working on this image. The old PyPy s390x distributions
# dynamically link libffi at an older version than I've been able to find a multi-platform
# image with s390x support for.
ln -s /usr/lib/s390x-linux-gnu/libffi.so.8 /usr/lib/s390x-linux-gnu/libffi.so.6
fi
124 changes: 124 additions & 0 deletions scripts/docker/uv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Copyright 2025 Science project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import os
import shutil
import subprocess
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import Any

from science.platform import CURRENT_OS, Os


def main() -> Any:
if CURRENT_OS is Os.Windows:
return "This script does not work on Windows yet."

parser = ArgumentParser()
parser.add_argument("--image", default="debian", choices=["alpine", "debian"])
parser.add_argument(
"--arch",
default="amd64",
choices=[
"amd64",
"arm64",
"riscv64",
"ppc64le",
"s390x",
"386",
"mips64le",
"mips64",
"arm/v7",
"arm/v6",
],
)
options, args = parser.parse_known_args()

platform = f"linux/{options.arch}"
subprocess.run(
args=[
"docker",
"run",
"--privileged",
"--rm",
"tonistiigi/binfmt",
"--install",
platform,
],
check=True,
)

parent_dir = Path(__file__).parent
arch_tag = options.arch.replace("/", "-")
base_image = f"a-scie/lift/base:{arch_tag}"

# The type-ignores for os.get{uid,gid} cover Windows which we explicitly fail-fast for above.
subprocess.run(
args=[
"docker",
"buildx",
"build",
"--build-arg",
f"UID={os.getuid()}", # type:ignore[attr-defined]
"--build-arg",
f"GID={os.getgid()}", # type:ignore[attr-defined]
"--platform",
platform,
"--tag",
base_image,
str(parent_dir / options.image),
],
check=True,
)

dev_image = f"a-scie/lift/dev:{arch_tag}"

ephemeral_build_context = parent_dir / "ephemeral-build-context"
ephemeral_build_context.mkdir(parents=True, exist_ok=True)
shutil.copy(Path("pyproject.toml"), ephemeral_build_context)
shutil.copy(Path("uv.lock"), ephemeral_build_context)

subprocess.run(
args=[
"docker",
"buildx",
"build",
"--build-arg",
f"BASE_IMAGE={base_image}",
"--build-context",
f"ephemeral={ephemeral_build_context}",
"--platform",
platform,
"--tag",
dev_image,
str(parent_dir / "uv"),
],
check=True,
)

subprocess.run(
args=[
"docker",
"run",
"-e",
"FORCE_COLOR",
"-e",
"SCIENCE_AUTH_API_GITHUB_COM_BEARER",
"-v",
f"{Path().absolute()}:/code",
"--platform",
platform,
dev_image,
*args,
],
check=True,
)


if __name__ == "__main__":
try:
sys.exit(main())
except subprocess.CalledProcessError as e:
sys.exit(str(e))
15 changes: 15 additions & 0 deletions scripts/docker/uv/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG BASE_IMAGE=scratch
FROM ${BASE_IMAGE}

VOLUME /code
WORKDIR /code

COPY --from=ephemeral pyproject.toml .
COPY --from=ephemeral uv.lock .
RUN chown -R build:build /code

USER build
ENV UV_LINK_MODE=copy
RUN uv sync --frozen --no-install-project && rm pyproject.toml uv.lock

ENTRYPOINT ["uv", "run", "dev-cmd"]
13 changes: 1 addition & 12 deletions tests/test_installer.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
from _pytest.tmpdir import TempPathFactory

from science.os import IS_WINDOWS
from science.platform import CURRENT_PLATFORM_SPEC, LibC, Platform, PlatformSpec


@pytest.fixture(scope="module")
@@ -31,15 +30,6 @@ def test_installer_help(installer: list):
assert long_help in result.stdout, f"Expected '{long_help}' in tool output"


# TODO(John Sirois): Remove this skip once science is released with 64 bit musl Linux support.
# https://github.com/a-scie/lift/issues/139
skip_64bit_musl_linux = pytest.mark.skipif(
CURRENT_PLATFORM_SPEC == PlatformSpec(Platform.Linux_x86_64, LibC.MUSL),
reason="No science executable has been released yet for 64 bit musl Linux.",
)


@skip_64bit_musl_linux
def test_installer_fetch_latest(tmp_path_factory: TempPathFactory, installer: list):
"""Invokes install.sh to fetch the latest science release binary, then invokes it."""
test_dir = tmp_path_factory.mktemp("install-test-default")
@@ -54,11 +44,10 @@ def test_installer_fetch_latest(tmp_path_factory: TempPathFactory, installer: li
assert result.stdout.strip(), "Expected version output in tool stdout"


@skip_64bit_musl_linux
def test_installer_fetch_argtest(tmp_path_factory: TempPathFactory, installer: list):
"""Exercises all the options in the installer."""
test_dir = tmp_path_factory.mktemp("install-test")
test_ver = "0.10.0"
test_ver = "0.12.0"
bin_dir = test_dir / "bin"

assert (result := run_captured(installer + ["-V", test_ver, "-d", bin_dir])).returncode == 0
6 changes: 3 additions & 3 deletions uv.lock