Skip to content

Commit

Permalink
Merge pull request #53 from opensafely-core/windows-just-support
Browse files Browse the repository at this point in the history
Windows just support
  • Loading branch information
ghickman authored Mar 29, 2022
2 parents 20296e0 + 7ab8eab commit af24a14
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
# so we shell out, as we need VIRTUAL_ENV in the justfile environment
export VIRTUAL_ENV := `echo ${VIRTUAL_ENV:-.venv}`

# TODO: make it /scripts on windows?
export BIN := VIRTUAL_ENV + "/bin"
export PIP := BIN + "/python -m pip"
export BIN := VIRTUAL_ENV + if os_family() == "unix" { "/bin" } else { "/Scripts" }
export PIP := BIN + if os_family() == "unix" { "/python -m pip" } else { "/python.exe -m pip" }
# enforce our chosen pip compile flags
export COMPILE := BIN + "/pip-compile --allow-unsafe --generate-hashes"

export DEFAULT_PYTHON := if os_family() == "unix" { "python3.10" } else { "python" }


# list available commands
default:
@{{ just_executable() }} --list
@"{{ just_executable() }}" --list


# clean up temporary files
Expand All @@ -23,7 +24,7 @@ clean:
virtualenv:
#!/usr/bin/env bash
# allow users to specify python version in .env
PYTHON_VERSION=${PYTHON_VERSION:-python3.10}
PYTHON_VERSION=${PYTHON_VERSION:-$DEFAULT_PYTHON}
# create venv and upgrade pip
test -d $VIRTUAL_ENV || { $PYTHON_VERSION -m venv $VIRTUAL_ENV && $PIP install --upgrade pip; }
Expand All @@ -41,12 +42,12 @@ _compile src dst *args: virtualenv

# update requirements.prod.txt if requirements.prod.in has changed
requirements-prod *args:
{{ just_executable() }} _compile requirements.prod.in requirements.prod.txt {{ args }}
"{{ just_executable() }}" _compile requirements.prod.in requirements.prod.txt {{ args }}


# update requirements.dev.txt if requirements.dev.in has changed
requirements-dev *args: requirements-prod
{{ just_executable() }} _compile requirements.dev.in requirements.dev.txt {{ args }}
"{{ just_executable() }}" _compile requirements.dev.in requirements.dev.txt {{ args }}


# ensure prod requirements installed and up to date
Expand Down Expand Up @@ -84,7 +85,7 @@ upgrade env package="": virtualenv
#!/usr/bin/env bash
opts="--upgrade"
test -z "{{ package }}" || opts="--upgrade-package {{ package }}"
FORCE=true {{ just_executable() }} requirements-{{ env }} $opts
FORCE=true "{{ just_executable() }}" requirements-{{ env }} $opts

# *ARGS is variadic, 0 or more. This allows us to do `just test -k match`, for example.
Expand Down

0 comments on commit af24a14

Please sign in to comment.