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 cross-platform example #1152

Merged
merged 2 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ $ just system-info
This is an x86_64 machine
```

`os_family()` can be used to create cross-platform `justfile` if the project has contributors using various operating systems. For example see [cross-platform.just](examples/cross-platform.just) file.
casey marked this conversation as resolved.
Show resolved Hide resolved

#### Environment Variables

- `env_var(key)` — Retrieves the environment variable with name `key`, aborting if it is not present.
Expand Down
26 changes: 26 additions & 0 deletions examples/cross-platform.just
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# use with https://github.com/casey/just
#
# Example cross-platform Python project
#

python_dir := if os_family() == "windows" { "./.venv/Scripts" } else { "./.venv/bin" }
python := python_dir + if os_family() == "windows" { "/python.exe" } else { "/python3" }
system_python := if os_family() == "windows" { "py.exe -3.9" } else { "python3.9" }

# Set up development environment
bootstrap:
if test ! -e .venv; then {{ system_python }} -m venv .venv; fi
{{ python }} -m pip install --upgrade pip wheel pip-tools
{{ python_dir }}/pip-sync

# Upgrade Python dependencies
upgrade-deps: && bootstrap
{{ python_dir }}/pip-compile --upgrade

# Sample project script 1
script1:
{{ python }} script1.py

# Sample project script 2
script2 *ARGS:
{{ python }} script2.py {{ ARGS }}