-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lenskit/feature/build-update
Update build logic & metadata
- Loading branch information
Showing
15 changed files
with
206 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: lkboot | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python>=3.8 | ||
- flit=3 | ||
- invoke=1 | ||
- requests=2 | ||
- pip | ||
- conda-lock | ||
- mamba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
# Script to bootstrap an environment for running the infra code. | ||
# The resulting environment can be used to run 'invoke' and get a | ||
# Conda lock for a full development environment. | ||
# | ||
# This script is intended to be sourced, but can be run on its own. | ||
|
||
msg() | ||
{ | ||
echo "$@" >&2 | ||
} | ||
|
||
err() | ||
{ | ||
echo "ERR:" "$@" >&2 | ||
exit 3 | ||
} | ||
|
||
vr() | ||
{ | ||
local ec | ||
echo + "$@" >&2 | ||
"$@" | ||
ec="$?" | ||
if [ $ec -ne 0 ]; then | ||
echo "command $1 terminated with code $ec" >&2 | ||
exit 2 | ||
fi | ||
} | ||
|
||
setup_micromamba() | ||
{ | ||
msg "Installing Micromamba" | ||
CONDA_PLATFORM=$(python3 lkbuild/env.py) | ||
test "$?" -eq 0 || exit 2 | ||
mkdir -p build/mmboot | ||
vr wget -qO build/micromamba.tar.bz2 https://micromamba.snakepit.net/api/micromamba/$CONDA_PLATFORM/latest | ||
vr tar -C build/mmboot -xvjf build/micromamba.tar.bz2 | ||
MM=build/mmboot/bin/micromamba | ||
if [ ! -e "$MM" ]; then | ||
# this should only happen on Windows | ||
MM=build/mmboot/Library/bin/micromamba.exe | ||
fi | ||
eval "$($MM shell hook -p $HOME/micromamba -s bash)" | ||
} | ||
|
||
setup_boot_env() | ||
{ | ||
msg "Installing bootstrap environment" | ||
vr micromamba env create -qy -n lkboot -f lkbuild/boot-env.yml | ||
msg "Activating bootstrap environment" | ||
micromamba activate lkboot | ||
} | ||
|
||
setup_micromamba | ||
setup_boot_env | ||
|
||
msg "Inspecting environment" | ||
CONDA_PLATFORM=$(invoke conda-platform) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sysconfig | ||
import re | ||
|
||
|
||
def conda_platform(): | ||
plat = sysconfig.get_platform() | ||
if re.match(r'^macosx-.*-x86_64', plat): | ||
return 'osx-64' | ||
if re.match(r'^macosx-.*-arm64', plat): | ||
return 'osx-arm64' | ||
if re.match(r'^[Ll]inux.*-x86_64', plat): | ||
return 'linux-64' | ||
if re.match(r'^[Ll]inux.*-aarch64', plat): | ||
return 'linux-aarch64' | ||
if plat == 'win-amd64': | ||
return 'win-64' | ||
|
||
raise ValueError('unrecognized platform ' + plat) | ||
|
||
|
||
if __name__ == '__main__': | ||
print(conda_platform()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
# Create a lock file for CI builds, and register with GitHub outputs. | ||
|
||
SDIR=$(dirname $0) | ||
|
||
. "$SDIR/bootstrap-env.sh" | ||
|
||
vr invoke dev-lock "$@" | ||
echo "::set-output name=environment-file::conda-$CONDA_PLATFORM.lock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# environment mini-spec for ensuring MKL | ||
dependencies: | ||
- libblas=*=*mkl | ||
- mkl=2020 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# environment mini-spec for ensuring OpenBLAS | ||
dependencies: | ||
- libblas=*=*openblas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# environment mini-spec for ensuring Python 3.10 | ||
dependencies: | ||
- python=3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# environment mini-spec for ensuring Python 3.7 | ||
dependencies: | ||
- python=3.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# environment mini-spec for ensuring Python 3.8 | ||
dependencies: | ||
- python=3.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# environment mini-spec for ensuring Python 3.9 | ||
dependencies: | ||
- python=3.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Support tasks shared across LensKit packages. | ||
""" | ||
|
||
import sys | ||
from invoke import task | ||
from . import env | ||
|
||
__ALL__ = [ | ||
'dev_lock', | ||
'conda_platform' | ||
] | ||
|
||
|
||
@task(iterable=['extras']) | ||
def dev_lock(c, platform=None, extras=None, version=None, blas=None, env_file=False): | ||
"Create a development lockfile" | ||
plat = env.conda_platform() | ||
|
||
if platform == 'all': | ||
plat_opt = '' | ||
elif platform: | ||
plat_opt = f'-p {platform}' | ||
else: | ||
plat_opt = f'-p {plat}' | ||
|
||
cmd = f'conda-lock lock --mamba {plat_opt} -f pyproject.toml' | ||
if env_file: | ||
cmd += ' -k env' | ||
|
||
if version: | ||
cmd += f' -f lkbuild/python-{version}-spec.yml' | ||
if blas: | ||
cmd += f' -f lkbuild/{blas}-spec.yml' | ||
for e in extras: | ||
cmd += f' -e {e}' | ||
|
||
print('running', cmd, file=sys.stderr) | ||
c.run(cmd) | ||
|
||
|
||
@task | ||
def conda_platform(c, gh_output=False): | ||
plat = env.conda_platform() | ||
if gh_output: | ||
print('::set-output name=conda-platform::' + plat) | ||
else: | ||
print(plat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from lkbuild.tasks import * |