py_template is a Python library that can be deployed in various ways depending on your use case. This guide covers common deployment scenarios.
# Install build tools
uv add --dev build
# Build the distribution packages
uv run python -m build
# This creates:
# - dist/py_template-0.1.0.tar.gz (source distribution)
# - dist/py_template-0.1.0-py3-none-any.whl (wheel)# Install from local directory
pip install /path/to/py_template
# Install in editable mode (for development)
pip install -e /path/to/py_templateFor proprietary software, you can use a private package repository:
# Install pypiserver
pip install pypiserver
# Start server
pypi-server -p 8080 /path/to/packages
# Upload package
twine upload --repository-url http://localhost:8080 dist/*
# Install from private server
pip install --index-url http://localhost:8080/simple/ py_templateConfigure your .pypirc:
[distutils]
index-servers =
private-repo
[private-repo]
repository: https://your-artifactory.com/repository/pypi/
username: your-username
password: your-passwordUpload:
twine upload -r private-repo dist/*# Install from main branch
pip install git+https://github.com/your-org/py_template.git
# Install from specific tag
pip install git+https://github.com/your-org/py_template.git@v0.1.0
# Install from specific branch
pip install git+https://github.com/your-org/py_template.git@dev# requirements.txt
py_template @ git+https://github.com/your-org/py_template.git@v0.1.0[project.dependencies]
py_template = { git = "https://github.com/your-org/py_template.git", tag = "v0.1.0" }# Install only production dependencies
uv sync --no-dev
# Or with pip
pip install -r requirements.txtCreate a .env file based on .env.example:
cp .env.example .env
# Edit .env with your configurationWhile py_template is a library, you might want to containerize applications that use it:
FROM python:3.12-slim
WORKDIR /app
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/
# Copy dependency files
COPY pyproject.toml uv.lock* ./
# Install dependencies
RUN uv sync --no-dev --frozen
# Copy application code
COPY . .
# Set Python path
ENV PYTHONPATH=/app/src
CMD ["python", "-m", "your_app"]The project includes pre-configured workflows:
- CI (.github/workflows/ci.yml) - Runs tests and linting
- Security (.github/workflows/security.yml) - Security scanning
- Code Quality (.github/workflows/code-quality.yml) - Code quality checks
- Update version in src/py_template/version.py
- Update CHANGELOG.md
- Create a git tag:
git tag -a v0.1.0 -m "Release version 0.1.0" git push origin v0.1.0 - Build and distribute the package
Follow semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Incompatible API changes
- MINOR: Backward-compatible functionality additions
- PATCH: Backward-compatible bug fixes
# Manually update version in src/py_template/__version__.py
# Then commit and tag
git commit -am "Bump version to 0.2.0"
git tag -a v0.2.0 -m "Release version 0.2.0"
git push && git push --tagsFor applications using py_template:
from py_template import __version__
def health_check():
"""Verify py_template is installed and working."""
return {
"status": "healthy",
"py_template_version": __version__
}# Update dependencies
uv sync --upgrade
# Check for security vulnerabilities
uv run safety check
# Review and commit uv.lock
git add uv.lock
git commit -m "Update dependencies"# Revert to previous version
pip install git+https://github.com/your-org/py_template.git@v0.0.9# Install specific version
pip install py_template==0.0.9- Private Repository: Keep your repository private since this is proprietary software
- Access Control: Limit access to the package repository
- Dependency Scanning: Regularly scan dependencies for vulnerabilities
- Code Signing: Consider signing your packages
- Secret Management: Never commit API keys or credentials
Import Errors
# Ensure PYTHONPATH is set correctly
export PYTHONPATH=/path/to/installation/srcDependency Conflicts
# Use virtual environment
uv venv
source .venv/bin/activate
uv sync- Check README.md for basic usage
- Review development.md for development setup
- See api.md for API documentation
- Source Code: Keep in version control (Git)
- Dependencies: Lock files (uv.lock) ensure reproducibility
- Configuration: Store
.env.examplein version control
# Clone repository
git clone https://github.com/your-org/py_template.git
cd py_template
# Restore dependencies
uv sync
# Verify installation
uv run py_template info