Python Package Managers
From pipenv to uv or poetry
Old versions of GenericSuite used "pipenv" as the Python package and dependency management tool. Now, we're migrating to "uv" as the default tool. Poetry is also supported.
To convert an application from pipenv to uv or poetry, follow these steps:
- Go to the project root directory, initialize "uv" or "poetry" and add GenericSuite dependencies:
For uv:
# Initialize "uv" and add GenericSuite dependencies
uv init
uv add ../genericsuite-be
uv add ../genericsuite-be-ai
# Add the backend framework dependencies
uv add chalice
# o
uv add fastapi fastapi-cors mangum "uvicorn[standard]" python-multipart
# o
uv add flask flask-cors gunicorn python-multipart
# Add the development dependencies
uv add --dev pytest coverage cfn-lint
For poetry:
# Initialize "poetry" and add GenericSuite dependencies
poetry init
poetry add ../genericsuite-be
poetry add ../genericsuite-be-ai
# Add the backend framework dependencies
poetry add chalice
# o
poetry add fastapi fastapi-cors mangum "uvicorn[standard]" python-multipart
# o
poetry add flask flask-cors gunicorn python-multipart
# Add the development dependencies
poetry add --dev pytest coverage cfn-lint
- Reinstall GS BE Scripts
npm install genericsuite-be-scripts@latest
- Update the
Makefilefile changing everypipenvreference tobash node_modules/genericsuite-be-scripts/scripts/run_pem.sh+ the Makefile tag:
For example:
Replace:
npm install
With:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh install
Here's the complete example:
install:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh install
npm install
install_dev:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh install_dev
npm install
update:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh update
npm update
update_dev:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh update_dev
npm update
locked_dev:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh locked_dev
locked_install:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh locked_install
lock:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh lock
requirements:
bash node_modules/genericsuite-be-scripts/scripts/aws/run_aws.sh requirements
.
.
.
clean_rm:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh clean_rm
.
.
.
lint:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh lint
types:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh types
coverage:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh coverage
format:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh format
pycodestyle
format_check:
bash node_modules/genericsuite-be-scripts/scripts/run_pem.sh format_check
pycodestyle
-
Search for every non-implemented reference to
pipenvin theMakefilefile and replace it withuvorpoetry. The non-implemented references are those different from:install,install_dev,update,update_dev,locked_dev,locked_install,lock,requirements,clean_rm,lint,types,coverage,format,format_check, -
Search for every reference to "pipenv" in the *.sh files and replace it with:
PEM_TOOL=uv
.
.
# Replace "pipenv" with "${PEM_TOOL}"
-
Search for every reference to
pipenvin thepackage.jsonfile and replace it withuvorpoetry. -
Update the
.envand.env.examplefiles adding the reference to thePEM_TOOLvariable and removing the comment#from the line that contains the dependency management tool that you want to use:
# Python package and dependency management tool (uv, pipenv, and poetry), default to "uv"
# PEM_TOOL=pipenv
# PEM_TOOL=uv
# PEM_TOOL=poetry