A template repo holding Roboflow's common setup for a python project.
You can install the package using pip
pip install -e .or for development
pip install -e ".[dev]"The project has the following structure
├── .github
│ └── workflows
│ └── test.yml # holds our github action config
├── .gitignore
├── README.md
├── pyproject.toml
├── src
│ └── sandbox
│ ├── __init__.py
│ └── hello.py
└── test
└── test_hello.py
We use pre-commit to ensure code quality. You can install it using:
pre-commit installYou can run the checks manually on all files:
pre-commit run --all-filesWe now use mypy for type checking. Type hints are enforced and checked automatically via pre-commit hooks.
pytest is used to run our tests.
pytest . -vImportant: Before publishing, edit __version__ in src/sandbox/init.py to match the wanted new version.
We use twine to upload our package.
# Build the package
python3 -m build
# Upload to TestPyPI (to verify everything is correct)
# Note: For TestPyPI you need to use your TestPyPI credentials
twine upload -r testpypi dist/* --verbose
# Upload to PyPI
twine upload dist/* --verboseNote: For authentication, we recommend using API tokens. Set TWINE_USERNAME to __token__ and TWINE_PASSWORD to your token value.
We use GitHub actions to automatically run tests and check code quality when a new PR is done on main.
On any pull request, we will check the code quality and tests.
When a new release is created, we will try to push the new code to PyPi. We use twine to make our life easier.
The correct steps to create a new release are the following:
- edit
__version__in src/sandbox/init.py to match the wanted new version. - create a new
tagwith the release name, e.g.git tag v0.0.1 && git push origin v0.0.1or from the GitHub UI. - create a new release from GitHub UI
The CI will run when you create the new release.
This is a template repo, it's meant to be used inside GitHub upon repo creation.
There are several very good templates on GitHub, I prefer to use code we wrote instead of blinding taking the most starred template and having features we don't need. From experience, it's better to keep it simple and general enough for our specific use cases.