diff --git a/.gitignore b/.gitignore index 9da6040c..5438adae 100644 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,10 @@ __pycache__/ *.c # Distribution / packaging +/build/ .Python env/ venv/ -build/ develop-eggs/ dist/ downloads/ diff --git a/dev/build.sh b/dev/build.sh index 0cbd4336..c5bff15a 100755 --- a/dev/build.sh +++ b/dev/build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e # exit if an error occurs -BUILD_PATH="build/`dev/abi.py`" +BUILD_PATH="build/`dev/build/abi.py`" echo Rebuilding $BUILD_PATH... meson compile -C $BUILD_PATH diff --git a/dev/abi.py b/dev/build/abi.py similarity index 100% rename from dev/abi.py rename to dev/build/abi.py diff --git a/dev/build/add_version_file_to_dist.sh b/dev/build/add_version_file_to_dist.sh new file mode 100755 index 00000000..dd95ae3b --- /dev/null +++ b/dev/build/add_version_file_to_dist.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e # exit if an error occurs + +if [[ -z "$MESON_SOURCE_ROOT" ]]; then + echo "ERROR: Must be run inside a meson build environment where the variable MESON_SOURCE_ROOT is set." 1>&2 + exit 1 +fi + +if [[ -z "$MESON_DIST_ROOT" ]]; then + echo "ERROR: Must be run inside a meson build environment where the variable MESON_DIST_ROOT is set." 1>&2 + exit 1 +fi + +VERSION_PATH="raysect/_version.py" +SRC_PATH="$MESON_SOURCE_ROOT/$VERSION_PATH" +DIST_PATH="$MESON_DIST_ROOT/$VERSION_PATH" + +echo "Copying $VERSION_PATH to distribution path $DIST_PATH" +cp $SRC_PATH $DIST_PATH diff --git a/dev/update_version.sh b/dev/build/update_version.sh similarity index 100% rename from dev/update_version.sh rename to dev/build/update_version.sh diff --git a/dev/build_docs.sh b/dev/build_docs.sh index a104fba8..115dd101 100755 --- a/dev/build_docs.sh +++ b/dev/build_docs.sh @@ -1,13 +1,10 @@ #!/bin/bash echo Building code... - dev/build.sh echo Building docs... - export PYTHONPATH=../:$PYTHONPATH cd docs - make html diff --git a/dev/clean.sh b/dev/clean.sh index a6a5ca57..10e86408 100755 --- a/dev/clean.sh +++ b/dev/clean.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e # exit if an error occurs -BUILD_PATH="build/`dev/abi.py`" +BUILD_PATH="build/`dev/build/abi.py`" echo Cleaning $BUILD_PATH... meson compile -C $BUILD_PATH --clean diff --git a/dev/root-meson.build b/dev/root-meson.build index f77fa44a..a3034a21 100644 --- a/dev/root-meson.build +++ b/dev/root-meson.build @@ -1,8 +1,11 @@ project('raysect', 'cython', default_options: ['python.install-env=auto'], - version: run_command(['dev/update_version.sh'], check: true).stdout().strip() + version: run_command(['dev/build/update_version.sh'], check: true).stdout().strip() ) +# when building a distribution, copy the dynamically generated _version.py to the distribution folder +meson.add_dist_script('dev/build/add_version_file_to_dist.sh') + py = import('python').find_installation(pure: false) numpy = dependency('numpy', method: 'config-tool') fs = import('fs') diff --git a/meson.build b/meson.build index 7c309e19..62bcf36f 100644 --- a/meson.build +++ b/meson.build @@ -3,9 +3,12 @@ project('raysect', 'cython', default_options: ['python.install-env=auto'], - version: run_command(['dev/update_version.sh'], check: true).stdout().strip() + version: run_command(['dev/build/update_version.sh'], check: true).stdout().strip() ) +# when building a distribution, copy the dynamically generated _version.py to the distribution folder +meson.add_dist_script('dev/build/add_version_file_to_dist.sh') + py = import('python').find_installation(pure: false) numpy = dependency('numpy', method: 'config-tool') fs = import('fs')