-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial changes for issue 59 refactor of build system
* Remove hardcoded version (which will be replaced dynamically) * Add specific lines to init * Add scripts directory, which contains a few helpers
- Loading branch information
1 parent
a335c7d
commit 2c21d34
Showing
8 changed files
with
136 additions
and
1 deletion.
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
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2022, Brookhaven Science Associates, LLC, Brookhaven National Laboratory | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,7 @@ | ||
# Scripts | ||
|
||
This directory contains helper scripts for GPax. | ||
|
||
- Build scripts for building the project | ||
- Testing script for the notebook smoke tests | ||
- `LICENSE` file, attributing code in this directory only to Brookhaven Science Associates (location from which the code was sourced) |
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,25 @@ | ||
#!/bin/bash | ||
|
||
build_docs () { | ||
|
||
if [[ "${GITHUB_ACTION_IS_RUNNING}" = 1 ]]; then | ||
bash scripts/install.sh doc | ||
fi | ||
|
||
make -C docs/ html | ||
|
||
# Helper when running on local. If not running in a GitHub Actions | ||
# environment, this will attempt to open index.html with the users' | ||
# default program | ||
if [[ -z "${GITHUB_ACTION_IS_RUNNING}" ]]; then | ||
open docs/build/html/index.html | ||
fi | ||
|
||
} | ||
|
||
pip install toml | ||
bash scripts/install.sh | ||
bash scripts/install.sh doc | ||
bash scripts/update_version.sh set | ||
build_docs | ||
bash scripts/update_version.sh reset |
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,6 @@ | ||
#!/bin/bash | ||
|
||
pip install flit~=3.7 | ||
bash scripts/update_version.sh set | ||
flit build | ||
bash scripts/update_version.sh reset |
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,27 @@ | ||
#!/bin/bash | ||
|
||
# Good stuff. The poor man's toml parser | ||
# https://github.com/pypa/pip/issues/8049 | ||
# This is the analog of pip install -e ".[...]" since for whatever reason | ||
# it does not appear to work cleanly with pip | ||
install_doc_requirements_only () { | ||
python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["project"]["optional-dependencies"]["doc"]))' | pip install -r /dev/stdin | ||
} | ||
|
||
install_test_requirements_only () { | ||
python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["project"]["optional-dependencies"]["test"]))' | pip install -r /dev/stdin | ||
} | ||
|
||
install_requirements() { | ||
python3 -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["project"]["dependencies"]))' | pip install -r /dev/stdin | ||
} | ||
|
||
|
||
pip install toml | ||
if [ "$1" = "doc" ]; then | ||
install_doc_requirements_only | ||
elif [ "$1" = "test" ]; then | ||
install_test_requirements_only | ||
else | ||
install_requirements | ||
fi |
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,35 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_NAME="gpax" | ||
|
||
replace_version_in_init () { | ||
pip install dunamai~=1.12 | ||
version="$(dunamai from git --style pep440 --no-metadata)" | ||
dunamai check "$version" --style pep440 | ||
sed_command="s/... # semantic-version-placeholder/'$version'/g" | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
sed -i '' "$sed_command" "$PACKAGE_NAME"/__init__.py | ||
else | ||
sed -i "$sed_command" "$PACKAGE_NAME"/__init__.py | ||
fi | ||
echo "__init__ version set to" "$version" | ||
export _TMP_VERSION="$version" | ||
} | ||
|
||
reset_version_to_ellipsis () { | ||
current_version=$(grep "__version__" "$PACKAGE_NAME"/__init__.py) | ||
sed_command="s/$current_version/__version__ = ... # semantic-version-placeholder/g" | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
sed -i '' "$sed_command" "$PACKAGE_NAME"/__init__.py | ||
else | ||
sed -i "$sed_command" "$PACKAGE_NAME"/__init__.py | ||
fi | ||
echo "$current_version" "reset to placeholder" | ||
} | ||
|
||
|
||
if [ "$1" == "set" ]; then | ||
replace_version_in_init | ||
elif [ "$1" == "reset" ]; then | ||
reset_version_to_ellipsis | ||
fi |