Create-PyPi-Package
A Python project template for creating, testing, and packaging a Python project as a distributable PyPI package.
This repository demonstrates a structured Python package setup using modern packaging tools, automated testing, development dependencies, and CI/CD with GitHub Actions.
🚀 Features
- 📦 Python package structure using the
srclayout - 🛠️ Package configuration with
setuptools - 🧪 Automated testing with
pytest - 🔍 Code quality and testing with
tox - ⚙️ Project configuration using
pyproject.toml - 🔄 CI workflow with GitHub Actions
- 📋 Separate production and development requirements
- 📄 MIT License
- 🧩 Example package:
PyInception
📁 Project Structure
Create-PyPi-Package/
│
├── .github/
│ └── workflows/
│ └── ...
│
├── src/
│ └── PyInception/
│ ├── __init__.py
│ └── ...
│
├── tests/
│ └── ...
│
├── .gitignore
├── LICENSE
├── README.md
├── demo.excalidraw
├── init_setup.sh
├── pyproject.toml
├── requirements.txt
├── requirements_dev.txt
├── setup.cfg
├── setup.py
├── template.py
└── tox.ini
🛠️ Technologies & Tools
- Python
- setuptools
- pytest
- tox
- Git & GitHub
- GitHub Actions
- PyPI
⚙️ Installation
1. Clone the repository
git clone https://github.com/rizowanKabir/Create-PyPi-Package.git
Navigate into the project:
cd Create-PyPi-Package
2. Create a Virtual Environment
Windows
python -m venv venv
Activate it:
venv\Scripts\activate
Linux / macOS
python3 -m venv venv
source venv/bin/activate
3. Upgrade pip
python -m pip install --upgrade pip
4. Install Dependencies
For the main project:
pip install -r requirements.txt
For development:
pip install -r requirements_dev.txt
📦 Installing the Package Locally
You can install the package in editable mode during development:
pip install -e .
This allows you to modify the source code without reinstalling the package every time.
🧪 Running Tests
Run the test suite using:
pytest
You can also run tests through tox:
tox
🔨 Building the Package
Install the build tool:
pip install build
Then build the package:
python -m build
This will create distribution files inside the dist/ directory.
Typical output:
dist/
├── PyInception-0.0.1.tar.gz
└── PyInception-0.0.1-py3-none-any.whl
The generated files are:
- Source Distribution (
.tar.gz) - Wheel Distribution (
.whl)
📤 Publishing to PyPI
Before publishing, install twine:
pip install twine
Check the generated distributions:
twine check dist/*
Upload the package to PyPI:
twine upload dist/*
You will need a PyPI account and appropriate API credentials to publish a package.
⚠️ Never commit your PyPI API token or other sensitive credentials to GitHub.
🔄 Continuous Integration
This project includes a GitHub Actions workflow under:
.github/workflows/
The workflow can be used to automatically run project checks and tests when changes are pushed to GitHub.
This helps ensure that new changes do not break the project.
🧩 Package Development Workflow
A typical development workflow for this project is:
Write Code
↓
Run Tests
↓
Run Tox
↓
Build Package
↓
Check Distribution
↓
Publish to PyPI
Commands:
pytest
tox
python -m build
twine check dist/*
twine upload dist/*
💡 Why Use the src Layout?
This project uses the src layout:
src/
└── PyInception/
The src layout helps prevent accidentally importing the local source directory instead of the installed package.
It also provides a cleaner structure for Python package development and distribution.
📝 Configuration Files
pyproject.toml
Contains modern Python project/build configuration.
setup.py
Contains package setup information using setuptools.
setup.cfg
Provides additional package configuration.
tox.ini
Defines environments and automated testing configuration.
requirements.txt
Contains dependencies required by the project.
requirements_dev.txt
Contains additional dependencies useful for development and testing.
🤝 Contributing
Contributions are welcome!
- Fork the repository.
- Create a new branch:
git checkout -b feature/my-feature - Make your changes.
- Run the tests:
pytest - Commit your changes:
git commit -m "Add new feature" - Push to the branch:
git push origin feature/my-feature - Open a Pull Request.
📄 License
This project is licensed under the MIT License.
See the LICENSE file for more information.
Repository: https://github.com/rizowanKabir/Create-PyPi-Package
Release files for PyInception-riz 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyinception_riz-0.0.4.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyinception_riz-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / pyinception_riz-0.0.4.tar.gz
| Download URL | pyinception_riz-0.0.4.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d717d7868f17c94e8747989cc63cd1b461569606cb3695fb763545a3efe68c0c
|
|
BLAKE2b-256 checksum How to use checksums |
b26b729058fd0c86dfbde851db6bebdffbd8db5b7f60752dab3c81de55587e00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / pyinception_riz-0.0.4-py3-none-any.whl
| Download URL | pyinception_riz-0.0.4-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d302631a5476f52b8f8444a6f39f7bb6a1aa8ca81f7577ac439cb60f97dd6199
|
|
BLAKE2b-256 checksum How to use checksums |
8dea2a22195e84b14b1152aaf1610151a54e51fbdbc1da885ebbe6d64e9fb040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|