forked from azavea/raster-vision
-
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.
Add scripts for building packages and publishing them to PyPi (azavea…
…#1915) * add pypi_build and pypi_publish scripts * update release instructions --------- Co-authored-by: Adeel Hassan <ahassan@element84.com>
- Loading branch information
Showing
3 changed files
with
149 additions
and
40 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
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,42 @@ | ||
#!/bin/bash | ||
|
||
# Determine the script's directory (even if it's a symbolic link) | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | ||
SCRIPTS_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SRC_DIR="$( cd -P "$( dirname "$SCRIPTS_DIR" )" && pwd )" | ||
|
||
# List of plugins to build | ||
plugins=("rastervision_pipeline" "rastervision_aws_batch" "rastervision_aws_s3" "rastervision_core" "rastervision_pytorch_learner" "rastervision_pytorch_backend" "rastervision_gdal_vsi") | ||
|
||
# Usage documentation | ||
function usage() { | ||
echo "Usage: $(basename "$0") [--test]" | ||
echo "" | ||
echo "Build Raster Vision plugins and top-level package." | ||
} | ||
|
||
# Check for command-line arguments | ||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then | ||
usage | ||
exit | ||
fi | ||
|
||
# Function to build a plugin | ||
function build_plugin() { | ||
cd "$SRC_DIR/$1" | ||
echo "Building $1 ... " | ||
python setup.py sdist bdist_wheel | ||
echo "Done." | ||
cd "$SRC_DIR" | ||
} | ||
|
||
# Build each plugin | ||
for plugin in "${plugins[@]}"; do | ||
build_plugin "$plugin" | ||
done | ||
|
||
# Build the top-level package | ||
echo "rastervision ... " | ||
python setup.py sdist bdist_wheel | ||
echo "Done." |
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,92 @@ | ||
#!/bin/bash | ||
|
||
# Determine the script's directory (even if it's a symbolic link) | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do SOURCE="$(readlink "$SOURCE")"; done | ||
SCRIPTS_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" | ||
SRC_DIR="$(cd -P "$(dirname "$SCRIPTS_DIR")" && pwd)" | ||
|
||
# List of plugins to publish | ||
plugins=("rastervision_pipeline" "rastervision_aws_batch" "rastervision_aws_s3" "rastervision_core" "rastervision_pytorch_learner" "rastervision_pytorch_backend" "rastervision_gdal_vsi") | ||
|
||
# Usage documentation | ||
function usage() { | ||
echo "Usage: $(basename "$0") [--test]" | ||
echo "" | ||
echo "Publish Raster Vision plugins and top-level package to PyPI or TestPyPI." | ||
echo "" | ||
echo "Options:" | ||
echo " -y Automatically answer 'yes' to prompts." | ||
echo " --test Publish to TestPyPI instead of PyPI." | ||
} | ||
|
||
# Function to publish a package to the specified repository | ||
function publish_package() { | ||
if [ "$publish_to_test" = true ]; then | ||
echo "Publishing to TestPyPI ... " | ||
twine upload --repository testpypi dist/* | ||
else | ||
echo "Publishing to PyPI ... " | ||
twine upload dist/* | ||
fi | ||
echo "Done." | ||
} | ||
|
||
# publish a plugin | ||
function publish_plugin() { | ||
local plugin_name="$1" | ||
cd "$SRC_DIR/$plugin_name" | ||
echo "Publishing $plugin_name ... " | ||
publish_package | ||
cd "$SRC_DIR" | ||
} | ||
|
||
# publish all plugins and the top-level package | ||
function publish_all() { | ||
# Publish each plugin | ||
for plugin in "${plugins[@]}"; do | ||
publish_plugin "$plugin" | ||
done | ||
|
||
# Publish the top-level package | ||
echo "Publishing rastervision ... " | ||
publish_package | ||
} | ||
|
||
# Check for command-line arguments | ||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then | ||
usage | ||
exit | ||
fi | ||
|
||
# Check if the --test flag is passed | ||
publish_to_test=false | ||
if [[ "$1" == "--test" ]]; then | ||
publish_to_test=true | ||
# Remove the --test flag from the arguments | ||
shift | ||
fi | ||
|
||
# If testing: publish and exit | ||
if [ "$publish_to_test" = true ]; then | ||
publish_all | ||
exit | ||
fi | ||
|
||
# If actually publishing: prompt for confirmation | ||
if [[ "$1" == "-y" ]]; then | ||
response="y" | ||
else | ||
read -r -p "Actually publish to PyPi? (y/N): " response | ||
fi | ||
|
||
case "$response" in | ||
[yY][eE][sS]|[yY]) | ||
echo "Publishing to PyPi..." | ||
publish_all | ||
;; | ||
*) | ||
echo "Aborting." | ||
;; | ||
esac | ||
|