A Python project with proper structure and version control using Poetry.
my-python-project/
├── src/ # Source code
│ └── my_python_project/ # Main package
├── tests/ # Test files
├── docs/ # Documentation
├── examples/ # Example usage
├── pyproject.toml # Poetry configuration
└── README.md
- Python 3.8 or higher
- Poetry (install with:
pip install poetry)
- Clone the repository:
git clone <your-repo-url>
cd my-python-project- Install dependencies with Poetry:
poetry install- Activate the virtual environment:
poetry shellThe project includes a CLI with several commands:
# Greet someone
poetry run my-project hello --name Alice
# Calculate sum of numbers
poetry run my-project sum-numbers 1 2 3 4 5
# Process sample data
poetry run my-project process
# Show help
poetry run my-project --helpfrom my_python_project.core import DataProcessor, greet, calculate_sum
# Greet someone
message = greet("Alice")
print(message) # "Hello, Alice! Welcome to My Python Project!"
# Calculate sum
total = calculate_sum([1, 2, 3, 4, 5])
print(total) # 15
# Use the data processor
processor = DataProcessor()
processor.add_data("hello")
processor.add_data("world")
result = processor.process_data()
print(result) # ['HELLO', 'WORLD']- Install development dependencies:
poetry install --with dev- Activate the virtual environment:
poetry shell# Format code with Black
poetry run black src/ tests/
# Sort imports with isort
poetry run isort src/ tests/
# Check code style with flake8
poetry run flake8 src/ tests/
# Type checking with mypy
poetry run mypy src/# Run tests
poetry run pytest
# Run tests with coverage
poetry run pytest --cov=src
# Run tests in watch mode
poetry run pytest-watch# Build the package
poetry build
# Publish to PyPI (requires authentication)
poetry publish# Add a dependency
poetry add package-name
# Add a development dependency
poetry add --group dev package-name
# Remove a dependency
poetry remove package-name
# Update dependencies
poetry update
# Show dependency tree
poetry show --tree
# Export requirements.txt (if needed)
poetry export -f requirements.txt --output requirements.txt- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run code quality checks:
poetry run black src/ tests/ && poetry run isort src/ tests/ && poetry run flake8 src/ tests/ - Run tests:
poetry run pytest - Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
[Add your license here]