Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: Split Python requirements management #96

Merged
merged 6 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions requirements.app.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
asyncpg==0.27.0
fastapi==0.89.1
ormar==0.12.1
psycopg2-binary==2.9.5
uvicorn==0.20.0
11 changes: 5 additions & 6 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
asyncpg==0.27.0
fastapi==0.89.1
ormar==0.12.1
psycopg2-binary==2.9.5
uvicorn==0.20.0
pip-tools==7.3.0
# Compile project requirement with (pip-tools needed):
# pip-compile --output-file=requirements.txt requirements.in

-r requirements.python.in
-r requirements.app.in
-r docs/requirements.in
1 change: 1 addition & 0 deletions requirements.python.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip-tools==7.3.0
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
anyio==4.0.0
# via starlette
asyncpg==0.27.0
# via -r requirements.in
# via -r requirements.app.in
babel==2.13.1
# via
# mkdocs-git-revision-date-localized-plugin
Expand Down Expand Up @@ -40,7 +40,7 @@ databases==0.6.2
defusedxml==0.7.1
# via cairosvg
fastapi==0.89.1
# via -r requirements.in
# via -r requirements.app.in
ghp-import==2.1.0
# via mkdocs
gitdb==4.0.11
Expand Down Expand Up @@ -112,7 +112,7 @@ mkdocs-section-index==0.3.8
natsort==8.4.0
# via mkdocs-awesome-pages-plugin
ormar==0.12.1
# via -r requirements.in
# via -r requirements.app.in
packaging==23.2
# via
# build
Expand All @@ -126,11 +126,11 @@ pillow==9.5.0
# cairosvg
# mkdocs-material
pip-tools==7.3.0
# via -r requirements.in
# via -r requirements.python.in
platformdirs==4.0.0
# via mkdocs
psycopg2-binary==2.9.5
# via -r requirements.in
# via -r requirements.app.in
pycparser==2.21
# via cffi
pydantic==1.10.4
Expand Down Expand Up @@ -193,7 +193,7 @@ typing-extensions==4.8.0
urllib3==2.1.0
# via requests
uvicorn==0.20.0
# via -r requirements.in
# via -r requirements.app.in
verspec==0.1.0
# via mike
watchdog==3.0.0
Expand Down
29 changes: 20 additions & 9 deletions scripts/bootstrap.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ set -e #ux
cwd="$(pwd)"
## Change to project directory
cd "$(dirname "$0")/.."
# shellcheck source="../.env"
source .env
if [ -f .env ]; then
# shellcheck source="../.env" disable=SC1091
source .env
fi

./scripts/python_setup.sh "$@"

echo "-- Shell: Source profile in case it's been updated"
# shellcheck source="$HOME/.profile"
# shellcheck source="$HOME/.profile" disable=SC1091
source "$HOME/.profile"
echo "-- Activate Python virtual environment"
# shellcheck source="../.venv/bin/activate"
source .venv/bin/activate
echo "-- Source '.env' configuration file"
# shellcheck source="../.env"
source .env

if [[ ! $(pip -V) =~ .*\.venv.* ]]; then
echo "-- Python: Activate '.venv' virtual environment"
# shellcheck source="../.venv/bin/activate" disable=SC1091
source .venv/bin/activate
fi

echo "-- Install project Python requirements in venv"
pip install -r requirements.txt

if [ -f .env ]; then
echo "-- Source '.env' configuration file"
# shellcheck source="../.env" disable=SC1091
source .env
fi

## and go back
cd "$cwd"
Empty file modified scripts/prestart.sh
100644 → 100755
Empty file.
19 changes: 13 additions & 6 deletions scripts/python_setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ cwd="$(pwd)"
## Change to project directory
cd "$(dirname "$0")/.."
# shellcheck source="../.env"
source .env
if [ -f .env ]; then
# shellcheck source="../.env"
source .env
fi

## Only compatible with Debian and Ubuntu
if [[ ! $(dpkg -s python3-venv) ]]; then
Expand All @@ -20,13 +23,17 @@ if [ ! -d .venv ]; then
python3 -m venv .venv
fi

echo "-- Python: Activate '.venv' virtual environment"
# shellcheck source="../.venv/bin/activate"
source .venv/bin/activate
if [[ ! $(pip -V) =~ .*\.venv.* ]]; then
echo "-- Python: Activate '.venv' virtual environment"
# shellcheck source="../.venv/bin/activate" disable=SC1091
source .venv/bin/activate
fi

echo "-- Upgrage Python pip and setuptools in venv"
pip install --upgrade setuptools pip
echo "-- Install Python requirements in venv"
pip install -r requirements.txt

echo "-- Install Python setup requirements in venv"
pip install -r requirements.python.in

## and go back
cd "$cwd"