-
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 #21 from uclahs-cds/aholmes-create-pypi-packages
Additional changes to prepare for releasing on PyPI
- Loading branch information
Showing
21 changed files
with
290 additions
and
53 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 |
---|---|---|
|
@@ -8,43 +8,23 @@ A collection of Python libraries for creating web applications, working with dat | |
|
||
* Create a BL_Python [web application](src/web/README.md) | ||
|
||
# Using `BL_Python` in your projects | ||
|
||
Currently these libraries are not available in any package repository, and so much be imported via other means. | ||
|
||
The suggested method is to use the `git+ssh` [VCS URL](https://pip.pypa.io/en/stable/topics/vcs-support/) with `pip`. | ||
|
||
As an example, include the `BL_Python.programming` library like this within `pyproject.toml`: | ||
|
||
```toml | ||
[project] | ||
dependencies = [ | ||
"bl-python-programming@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/programming" | ||
] | ||
``` | ||
|
||
Make note of the following: | ||
* The library name is prefixed with `bl-python-` followed by the library name, which is `programming` in this example. This is due to how Python namespaces packages, and the pattern is necessary for the other libraries as well. | ||
* The Git URL is followed by `@`, then `main`. Use this if you want the _unstable_ features in the `main` Git branch. Any Git [ref](https://git-scm.com/book/en/v2/Git-Internals-Git-References) can be used, which is helpful to lock the dependency to a specific version. The `@` is always needed when specifying a ref. | ||
* The Git URL ends with `#subdirectory=src/programming`. This is necessary to specify that the dependency `bl-python-programming` exists at `src/programming`. | ||
|
||
## Important requirement! | ||
|
||
Due to limitations in `pip`, some `BL_Python` libraries that depend on other `BL_Python` libraries need those dependencies explicitly defined in applications using those libraries. | ||
|
||
The libraries that require this will outline their explicit dependencies in their respective readme files. `pip` will also show an error if these requirements are not met, which will aid in discovery of invalid dependency configurations in your applications. | ||
|
||
# Available Libraries | ||
|
||
Following are each of the libraries in this repository. | ||
|
||
They can be used in Python under the `BL_Python` namespace. For example, to use the database libraries you would import from `BL_Python.database`. | ||
|
||
To use these packages during development of `BL_Python` itself, please refer to [Development](#development). | ||
|
||
## AWS [ `BL_Python.aws` ] | ||
Libraries for working with AWS. | ||
|
||
Review the `BL_Python.AWS` [readme](src/AWS/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.aws` | ||
|
||
#### Git VCS URL | ||
`bl-python-aws@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/AWS` | ||
|
||
|
@@ -53,6 +33,9 @@ Libraries for working with SQLite and PostgreSQL databases. | |
|
||
Review the `BL_Python.database` [readme](src/database/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.database` | ||
|
||
#### Git VCS URL | ||
`bl-python-database@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/database` | ||
|
||
|
@@ -61,6 +44,9 @@ Utilities and tools for assisting in development of software. | |
|
||
Review the `BL_Python.development` [readme](src/development/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.development` | ||
|
||
#### Git VCS URL | ||
`bl-python-development@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/development` | ||
|
||
|
@@ -69,6 +55,9 @@ Libraries for PaaS offerings such as tools for altering application configuratio | |
|
||
Review the `BL_Python.platform` [readme](src/platform/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.platform` | ||
|
||
#### Git VCS URL | ||
`bl-python-platform@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/platform` | ||
|
||
|
@@ -77,6 +66,9 @@ Libraries used for writing software, such as pattern implementations so wheels d | |
|
||
Review the `BL_Python.programming` [readme](src/programming/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.programming` | ||
|
||
#### Git VCS URL | ||
`bl-python-programming@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/programming` | ||
|
||
|
@@ -85,6 +77,9 @@ Libraries used to aid in automated testing. | |
|
||
Review the `BL_Python.testing` [readme](src/testing/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.testing` | ||
|
||
#### Git VCS URL | ||
`bl-python-testing@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/testing` | ||
|
||
|
@@ -93,6 +88,9 @@ Libraries used to building web applications. | |
|
||
Review the `BL_Python.web` [readme](src/web/README.md) | ||
|
||
#### PyPI Package Name | ||
`bl-python.web` | ||
|
||
#### Git VCS URL | ||
`bl-python-web@ git+ssh://[email protected]/uclahs-cds/private-BL-python-libraries.git@main#subdirectory=src/web` | ||
|
||
|
@@ -104,4 +102,10 @@ When developing from within the mono-repo, the libraries can be individually ins | |
|
||
To install the base dependencies, run `pip install -e .` from the mono-repo root. Development dependencies can be installed with `pip install -e .[dev-dependencies]` | ||
|
||
To install the library dependencies, run, for example, `pip install -e src/web` to install `BL_Python.web`. Similar to the mono-repo, development dependencies can be installed with `pip install -e src/web[dev-dependencies]`. | ||
To install the library dependencies, run, for example, `pip install -e src/web` to install `BL_Python.web`. Similar to the mono-repo, development dependencies can be installed with `pip install -e src/web[dev-dependencies]`. | ||
|
||
## Important requirement! | ||
|
||
Due to limitations in `pip`, some `BL_Python` libraries that depend on other `BL_Python` libraries need those dependencies explicitly defined in applications using those libraries. | ||
|
||
The libraries that require this will outline their explicit dependencies in their respective readme files. `pip` will also show an error if these requirements are not met, which will aid in discovery of invalid dependency configurations in your software. |
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,97 @@ | ||
#!/bin/bash | ||
set -eEo pipefail | ||
|
||
spinwait_pid= | ||
spinwait_col= | ||
spinwait() { | ||
IFS=';' | ||
# inspiration https://unix.stackexchange.com/a/183121 | ||
read -sdR -p $'\E[6n' spinwait_row spinwait_col | ||
spinwait_row="${spinwait_row#*[}" | ||
|
||
s=(\| / - \\) | ||
i=0 | ||
while true; do | ||
tput cup $((spinwait_row-1)) $spinwait_col 2> /dev/null | ||
echo -en " ${s[i]}"; i=$(( (i + 1) % ${#s[@]})) | ||
sleep 0.2 | ||
done & | ||
spinwait_pid=$! | ||
} | ||
spinwait-stop() { | ||
optional_msg=$1 | ||
kill $spinwait_pid 2> /dev/null | ||
tput cup $((spinwait_row-1)) $spinwait_col 2> /dev/null | ||
[ -n "$optional_msg" ] && echo -e " $optional_msg" || echo -e " " | ||
} | ||
|
||
project_name= | ||
get-project-name() { | ||
# inspiration https://stackoverflow.com/a/73519411 | ||
project_name=$(awk \ | ||
-F' = ' \ | ||
-v s="project" \ | ||
-v p="name" \ | ||
' | ||
# process only sections (they start with ^[ ) | ||
/^\[/{ | ||
gsub(/[\[\]]/, "", $1) | ||
f = ($1 == s) | ||
next | ||
} | ||
# print only the value following the ` = ` | ||
# only for the line starting with `name = ` | ||
NF && f && $1==p{ | ||
gsub(/"/, "", $2) | ||
print $2 | ||
}' pyproject.toml) | ||
} | ||
|
||
trap 'spinwait-stop' ERR | ||
trap 'spinwait-stop; exit' SIGINT SIGTERM | ||
build() { | ||
dir="$1" | ||
pushd $dir 1> /dev/null | ||
get-project-name | ||
echo -n Building $project_name | ||
spinwait | ||
rm -rf dist/ | ||
python -m build 1> /dev/null | ||
spinwait-stop done | ||
popd 1> /dev/null | ||
} | ||
|
||
publish() { | ||
set +e | ||
local dir="$1" | ||
local repository | ||
[ -n "$2" ] && repository="$2" || repository="testpypi" | ||
pushd $dir 1> /dev/null | ||
get-project-name | ||
echo Publishing $project_name to $repository | ||
python -m twine upload --repository $repository dist/* | ||
popd 1> /dev/null | ||
} | ||
|
||
declare -a packages=( \ | ||
. \ | ||
src/AWS \ | ||
src/database \ | ||
src/development \ | ||
src/platform \ | ||
src/programming \ | ||
src/testing \ | ||
src/web | ||
) | ||
|
||
for package in ${packages[@]}; do | ||
build $package | ||
done | ||
|
||
# default to testpypi | ||
[ -n "$1" ] && repository="$1" || repository="testpypi" | ||
|
||
tput init 2> /dev/null | ||
for package in ${packages[@]}; do | ||
publish $package $repository | ||
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
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 @@ | ||
# Changelog | ||
|
||
Review the `BL_Python` [CHANGELOG.md](https://github.com/uclahs-cds/BL_Python/blob/main/CHANGELOG.md). |
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,3 @@ | ||
# Changelog | ||
|
||
Review the `BL_Python` [CHANGELOG.md](https://github.com/uclahs-cds/BL_Python/blob/main/CHANGELOG.md). |
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,3 @@ | ||
# Changelog | ||
|
||
Review the `BL_Python` [CHANGELOG.md](https://github.com/uclahs-cds/BL_Python/blob/main/CHANGELOG.md). |
Oops, something went wrong.