Below is a bare‑bones, data‑science‑oriented Python module template that uses pyproject.toml and a Conda environment. It’s designed to be:
-
Easy to clone and set up via Conda
-
Minimal
-
PEP 517/518‑compliant for modern packaging
📌 Quick‑Start Checklist
-
Fork & clone
-
Conda‑create: conda env create -f environment.yml
-
Activate: conda activate my_project
-
Install: pip install -e .
-
Run: import your module in a Python REPL or script
📁 Project Structure
my_project/
├── environment.yml # Conda environment spec
├── pyproject.toml # Build system & metadata
├── README.md # Overview + setup instructions
├── .gitignore # Files & dirs to ignore in Git
└── src/
└── my_project/
├── __init__.py # Makes this a Python package
└── core.py # Your module’s main code
📋 File Descriptions
File / Directory | Purpose | Details |
---|---|---|
environment.yml | Conda env spec | Lists Python version & dependencies (e.g. numpy, pandas, matplotlib). |
pyproject.toml | Build config & metadata | Specifies package name, version, author, and build backend (setuptools or poetry). |
README.md | Project overview + setup guide | Explains project purpose, how to install, usage examples. |
.gitignore | Git ignore rules | Excludes pycache/, .env/, .ipynb_checkpoints/, etc. |
src/my_project/ | Python package source | All your .py modules live here. |
src/my_project/init.py | Package initializer | Keeps package namespace clean; optionally exposes key functions. |
🛠️ Setup Instructions
1. Clone the repository
git clone https://github.com/<your‑username>/my_project.git
cd my_project
2. Create & activate the Conda environment
conda env create -f environment.yml
conda activate my_project
Alternative
Contents Use requirements.txt instead of environment.yml with
python -m venv .env source .env/bin/activate # macOS/Linux ..env\Scripts\activate # Windows pip install -r requirements.txt
3. Install your package in “editable” mode
pip install -e .
This lets you modify src/my_project/ and see changes immediately.
4. Verify installation
python -c "import my_project; print(my_project.__version__)"
⚙️ environment.yml
Example
name: my_project
channels:
- conda-forge
dependencies:
- python=3.10
- numpy
- pandas
- matplotlib
- pip # for pip‑only packages
- pip:
- scikit-learn # example pip package
📐 pyproject.toml
Example
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "my_project"
version = "0.1.0"
description = "A minimal data science Python module."
authors = [
{ name="Your Name", email="you@example.com" }
]
readme = "README.md"
license = { file="LICENSE" }
dependencies = [
"numpy>=1.20",
"pandas>=1.3"
]
[tool.setuptools.packages.find]
where = ["src"]
Tip for careful readers:
-
You can replace Setuptools with Poetry by swapping the [build-system] section and using poetry.lock/pyproject.toml for dependency management.
-
Add a tests/ directory and CI workflow (e.g., GitHub Actions) later for automated testing.