Simple template for Python 3.12
with pyenv
/pyenv-virtualenv
and poetry
.
git clone git@github.com:markgreene74/python-template.git
- make sure
pyenv
andpyenv-virtualenv
are installed - install python
3.12
, for example3.12.3
pyenv install 3.12.3
- create a virtual environment
pyenv virtualenv 3.12.3 python-template-3-12
- activate the virtual environment
pyenv activate python-template-3-12
- make sure
pip
andsetuptools
are up-to-datepip install --upgrade pip setuptools
- install poetry
pip install --upgrade poetry==1.8.3
- to install
- the application runtime dependencies
poetry install --only main
- the application test dependencies
poetry install --with test
- the application dev and test dependencies
poetry install --with test,dev
- the dependencies but not the current project
poetry install --no-root --with test,dev
- the application runtime dependencies
This project uses pre-commit
.
- install the hooks from the
.pre-commit-config.yaml
filepre-commit install
- build the image
docker build -t python-template .
- run the container
docker run -it --rm python-template
Intermediate stages (test
, dev
) are available in the Dockerfile
. Build them with:
docker build -t python-template . --target <stage>
For example, build and tun the tests with:
docker build -t python-template . --target test && \
docker run -it --rm python-template
- create the file
.with_pyenv
if you want to install Python usingpyenv
touch .with_pyenv
- start the
vagrant
boxNOTE: when the VM is started for the first timevagrant up
vagrant
will run the provisioning script. It's a good idea to redirect the output to a log file for troubleshooting.vagrant up 2>&1 | tee -a $(date +%F)-vagrant-up.log
- login to the box
vagrant ssh
- poetry
- pre-commit