- Clone the repository:
git clone https://github.com/ilovepdf/iloveimg-python.git
cd iloveimg-python- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements_dev.txt
pip install -e .The
-e .flag installs the package in editable mode.
Create pyrightconfig.json in the project root:
{
"extraPaths": ["/path/to/lib/python/site-packages"]
}Copy .env.example to .env and configure:
cp .env.example .envRequired variables:
ILOVEIMG_PUBLIC_KEY- Your API public keyILOVEIMG_SECRET_KEY- Your API secret key
Optional variables:
PYTHONLOGLEVEL- Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)FOLDER_SAMPLE_PATH- Path to sample files for testing
# Unit tests only
pytest tests/unit/
# Integration tests (requires API keys)
pytest tests/integration/
# All tests
pytest tests/The project uses:
- Black for formatting
- Ruff for fast linting and formatting
- Pyright for static type checking
Run formatting and linting:
black .
ruff check .
ruff format .
pyright iloveimg/For pre-commit hooks (autom
- Create
iloveimg/newtask_task.pyextendingTask - Add unit tests in
tests/unit/ - Add integration test in
tests/integration/ - Add sample script in
samples/ - Update
iloveimg/__init__.pyto export the task
iloveimg-python/
├── iloveimg/ # Core library
│ ├── *task.py # Task implementations
│ ├── task.py # Base task class
│ ├── exceptions/ # Custom exceptions
│ └── validators/ # Input validators
├── samples/ # Usage examples
├── tests/ # Unit & integration tests
├── .docker/ # Docker configurations
├── README.md # Main documentation
├── INSTALL.md # Installation guide
└── DEVELOPMENT.md # This file
Build and run tests in Docker using docker-compose:
# Build images
docker-compose -f .docker/docker-compose.yml build
# Run tests with a specific Python version
docker-compose -f .docker/docker-compose.yml run --rm python310 pytest tests/unit
# Run all tests
docker-compose -f .docker/docker-compose.yml run --rm python310 pytest tests/Available Python versions: python310, python311, python312, python313, python314
For full Docker instructions, see .docker/README.md.
- Issues: https://github.com/ilovepdf/iloveimg-python/issues
- API Docs: https://developer.iloveimg.com/docs
- The version is defined only in
pyproject.toml→[project].version.
Example: to bump from 1.0.1 to 1.0.2, change in pyproject.toml:
version = "1.0.1"→version = "1.0.2"
For a new release, just update the version in pyproject.toml.
To publish a new version to PyPI:
- Update the version in
pyproject.toml. - Build the distributions:
pip install build twine
python -m build- Upload to PyPI:
TWINE_USERNAME="__token__"
TWINE_PASSWORD="<your PyPI token>"
twine upload dist/*