Skip to content

Commit

Permalink
[py] BUILD_ROOT environment var to minimise pollution in the source repo
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Apr 8, 2024
1 parent 90f3ada commit fcaeb40
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: ./.github/workflows/common.yml
with:
workdir: py
format-pkgs: python3.11-venv black
format-pkgs: python3.11-venv
build-pkgs: python3.11-venv
cache-paths: |
py/venv
Expand Down
10 changes: 8 additions & 2 deletions py/build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/usr/bin/env bash
set -eu
cd $(dirname $0)
source py_env.sh

BUILDDIR=${BUILD_ROOT:-$(realpath $(dirname $0))/build}/$(basename $(pwd))-$(echo $(basename $0) | sed 's/build_*\(.*\).sh/\1/')-$(uname)-$(uname -m)-venv
if [ ! -d $BUILDDIR ] ; then
python3 -m venv $BUILDDIR
$BUILDDIR/bin/pip install pysdl2 pysdl2-dll
fi
source $BUILDDIR/bin/activate

cat >rosettaboy-release <<EOD
#!/usr/bin/env bash
set -eu
source "\$(dirname \$0)/py_env.sh"
source $BUILDDIR/bin/activate
PYTHONPATH="\$(dirname \$0)" exec python3 -c "from src.main import main ; import sys ; sys.exit(main(sys.argv))" \$*
EOD
chmod +x rosettaboy-release
11 changes: 9 additions & 2 deletions py/build_mypyc.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env bash
set -eu
cd $(dirname $0)
source py_env.sh

BUILDDIR=${BUILD_ROOT:-$(realpath $(dirname $0))/build}/$(basename $(pwd))-$(echo $(basename $0) | sed 's/build_*\(.*\).sh/\1/')-$(uname)-$(uname -m)-venv
if [ ! -d $BUILDDIR ] ; then
python3 -m venv $BUILDDIR
$BUILDDIR/bin/pip install pysdl2 pysdl2-dll 'mypy>=1.0.0'
fi
source $BUILDDIR/bin/activate

rm -rf rbmp
cp -r src rbmp
sed -i.bak 's/from src./from rbmp./' rbmp/*.py
Expand All @@ -11,7 +18,7 @@ mypyc rbmp
cat >rosettaboy-mypyc <<EOD
#!/usr/bin/env bash
set -eu
source "\$(dirname \$0)/py_env.sh"
source $BUILDDIR/bin/activate
PYTHONPATH="\$(dirname \$0)" exec python3 -c "from rbmp.main import main ; import sys ; sys.exit(main(sys.argv))" \$*
EOD
chmod +x rosettaboy-mypyc
10 changes: 7 additions & 3 deletions py/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ set -eu

cd $(dirname $0)

source py_env.sh
BUILDDIR=${BUILD_ROOT:-build}/$(basename $(pwd))-$(uname)-$(uname -m)-black
if [ ! -d $BUILDDIR ] ; then
python3 -m venv $BUILDDIR
$BUILDDIR/bin/pip install pysdl2 pysdl2-dll 'mypy>=1.0.0' black
fi

black src/*.py
mypy src/*.py
$BUILDDIR/bin/black src/*.py
$BUILDDIR/bin/mypy src/*.py
17 changes: 0 additions & 17 deletions py/py_env.sh

This file was deleted.

0 comments on commit fcaeb40

Please sign in to comment.