A template repository for developing Python packages using Poetry in a VSCode devcontainer. Comes pre-configured with Poetry and Quarto for package documentation.
- Devcontainer configuration for VSCode
- Poetry for dependency management
- Quarto for documentation
- Pre-configured development environment
Pre-requisites: Ensure you have the following installed on your system: Visual Studio Code (VSCode) and Docker Desktop
- Click "Use this template" to create a new repository
- Clone your new repository
- Open in VSCode with devcontainer extension
- VSCode will prompt to reopen in container - accept this (will take a few minutes)
Alternatively, click 'Use this template' in this repository, then select 'Open in a codespace' to try it out directly in your browser.
Open a terminal in your container workspace and run the following:
- Initialize Poetry project:
poetry init
- Set up development dependencies:
poetry add --group dev pytest
poetry add --group dev quartodocs
- Create your package structure:
mkdir your_package_name
touch your_package_name/__init__.py
Documentation is handled through Quarto. To build the documentation:
quarto render
After creating a new repository from this template:
Alternatively, replace steps 1 and 2 by clicking 'Use this template' in this repository, then select 'Open in a codespace' to try it out directly in your browser.
-
Clone your repository and open in VSCode
git clone <your-repo-url> code <repo-directory>
-
When prompted, reopen in container (or use Command Palette: "Reopen in Container")
-
Initialize your Poetry project (update with your details)
poetry init --name hellopy \ --description "Your package description" \ --author "Your Name <[email protected]>" \ --python "^3.11" \ -n
-
Create initial package structure
mkdir hellopy && \ touch hellopy/__init__.py && \ touch hellopy/hello.py
-
Populate
hello.py
with the followingdef hello(): """ Print a greeting message. Example usage: ```{python} from hellopy.hello import hello hello() ``` """ print("Hello!")
-
Install your package in editor mode, add IPython and Jupyter to aid development, and activate virtual
poetry install && \ poetry add --group dev ipython jupyter
-
Activate virtual environment
source .venv/bin/activate
-
Start Ipython (or an interactive Jupyter window)
ipython
-
In Ipython, import
hello()
from hellopy.hello import hello
-
Enjoy developing your package!
# Try editing `hello.py` and re-running the `hello()` command hello()