Modern Setup Configuration - PyCompTox v0.3.0¶
Overview¶
PyCompTox has been upgraded to use modern Python packaging standards (PEP 621) with pyproject.toml as the primary configuration file.
What Changed¶
✅ New: pyproject.toml¶
All project metadata and configuration is now in pyproject.toml:
- Package metadata: name, version, description, authors, URLs
- Dependencies: Core and optional dependencies
- Build system: Modern build backend (setuptools>=61.0)
- Tool configurations: black, mypy, pytest, coverage, isort
- Entry points: CLI command
pycomptox-setup
✅ Updated: setup.py¶
setup.py is now a minimal backward compatibility shim:
- All configuration moved to pyproject.toml
- Keeps compatibility with older tools
- Simply calls setup() with no arguments
✅ New: main.py¶
Added CLI module with command-line interface:
- pycomptox-setup set YOUR_KEY - Save API key
- pycomptox-setup show - Show configuration
- pycomptox-setup test - Test API connection
- pycomptox-setup delete - Delete saved key
Can also use: python -m pycomptox [command]
✅ New: py.typed¶
Added PEP 561 marker file for type checking support: - Enables type checkers (mypy) to use package types - Provides better IDE autocomplete - Full type annotation support
✅ New: MANIFEST.in¶
Controls distribution contents: - Includes: README, LICENSE, docs, type markers, tests - Excludes: cache files, build artifacts, notebooks
Optional Dependencies¶
Development Tools¶
Includes: - pytest, pytest-cov (testing) - black (formatting) - flake8 (linting) - mypy (type checking) - types-requests (type stubs)
Notebook Support¶
Includes: - jupyter (notebooks) - pandas (data analysis) - matplotlib (visualization)
All Optional Dependencies¶
Includes everything (dev + notebook).
Tool Configurations¶
Black (Code Formatting)¶
Usage:
MyPy (Type Checking)¶
Usage:
Pytest (Testing)¶
Usage:
Coverage (Test Coverage)¶
Usage:
Isort (Import Sorting)¶
Usage:
Installation Methods¶
Standard Install¶
Installs only core dependencies (requests).
Editable Install (Development)¶
Installs in editable mode - changes to source code are immediately available without reinstalling.
With Optional Dependencies¶
# Development tools
pip install -e ".[dev]"
# Notebook support
pip install -e ".[notebook]"
# Everything
pip install -e ".[all]"
Building Distribution¶
Install Build Tools¶
Build Packages¶
Creates:
- dist/pycomptox-0.3.0-py3-none-any.whl (wheel - recommended)
- dist/pycomptox-0.3.0.tar.gz (source distribution)
Install from Wheel¶
Entry Point Scripts¶
After installation, these commands are available:
# Using the pycomptox-setup command
pycomptox-setup show
pycomptox-setup set YOUR_API_KEY
pycomptox-setup test
pycomptox-setup delete
# Using Python module syntax
python -m pycomptox show
python -m pycomptox set YOUR_API_KEY
python -m pycomptox test
python -m pycomptox delete
Benefits of Modern Setup¶
1. Standards Compliance¶
- PEP 621: Modern declarative metadata
- PEP 517/518: Modern build system
- PEP 561: Type checking support
2. Better Tooling Support¶
- Works with all modern Python packaging tools
- Better IDE integration
- Improved type checking
3. Cleaner Configuration¶
- Single source of truth (
pyproject.toml) - No more scattered configuration files
- Tool configs in one place
4. Optional Dependencies¶
- Install only what you need
- Smaller default installation
- Easy to add dev tools
5. Entry Points¶
- Clean CLI interface
- Automatic script creation
- Cross-platform compatibility
Migration from Old Setup¶
If you previously installed with old setup.py:
Verification¶
Test the installation:
# Check version
import pycomptox
print(pycomptox.__version__) # 0.3.0
# Check CLI
import subprocess
result = subprocess.run(["pycomptox-setup", "show"], capture_output=True)
print(result.stdout.decode())
Development Workflow¶
# 1. Clone and enter directory
git clone https://github.com/USEtox/PyCompTox.git
cd PyCompTox
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
# 3. Install in editable mode with dev tools
pip install -e ".[dev]"
# 4. Format code
black src/ tests/
# 5. Sort imports
isort src/ tests/
# 6. Type check
mypy src/pycomptox
# 7. Run tests
pytest tests/
# 8. Check coverage
pytest --cov=pycomptox tests/
# 9. Build distribution
python -m build
Troubleshooting¶
"No module named 'pycomptox'"¶
Solution: Install the package
"pycomptox-setup: command not found"¶
Solution: Reinstall with entry points
Or use Python module syntax:
Build errors¶
Solution: Update build tools
Type checking not working¶
Solution: Install type stubs
Summary¶
PyCompTox now uses modern Python packaging with:
✅ pyproject.toml - Single configuration file
✅ Optional dependencies - Install only what you need
✅ Type checking support - Full PEP 561 compliance
✅ CLI entry points - pycomptox-setup command
✅ Tool configurations - black, mypy, pytest, coverage
✅ Modern build system - PEP 517/518 compliant
✅ Better tooling support - Works with all modern tools
The package is now following current Python packaging best practices!