|
| 1 | +# Development |
| 2 | + |
| 3 | +## Environment |
| 4 | + |
| 5 | +For local development, it is required to have Python 3.8 installed. |
| 6 | + |
| 7 | +It is recommended to set up a virtual environment while developing this package to isolate your development environment, |
| 8 | +however, due to the many varied ways Python can be installed and virtual environments can be set up, |
| 9 | +this is left up to the developers to do themselves. |
| 10 | + |
| 11 | +One recommended way is with the built-in `venv` module: |
| 12 | + |
| 13 | +```bash |
| 14 | +python3 -m venv .venv |
| 15 | +source .venv/bin/activate |
| 16 | +``` |
| 17 | + |
| 18 | +To improve on the experience, you can use [pyenv](https://github.com/pyenv/pyenv) to have an environment with a pinned Python version, |
| 19 | +and [direnv](https://github.com/direnv/direnv) to automatically activate/deactivate the environment when you enter/exit the project folder. |
| 20 | + |
| 21 | +## Dependencies |
| 22 | + |
| 23 | +To install this package and its development dependencies, run `make install-dev` |
| 24 | + |
| 25 | +## Formatting |
| 26 | + |
| 27 | +We use `autopep8` and `isort` to automatically format the code to a common format. To run the formatting, just run `make format`. |
| 28 | + |
| 29 | +## Linting, type-checking and unit testing |
| 30 | + |
| 31 | +We use `flake8` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`. |
| 32 | + |
| 33 | +## Integration tests |
| 34 | + |
| 35 | +We have integration tests which build and run actors using the Python SDK on the Apify Platform. |
| 36 | +To run these tests, you need to set the `APIFY_TEST_USER_API_TOKEN` environment variable to the API token of the Apify user you want to use for the tests, |
| 37 | +and then start them with `make integration-tests`. |
| 38 | + |
| 39 | +If you want to run the integration tests on a different environment than the main Apify Platform, |
| 40 | +you need to set the `APIFY_INTEGRATION_TESTS_API_URL` environment variable to the right URL to the Apify API you want to use. |
| 41 | + |
| 42 | +## Documentation |
| 43 | + |
| 44 | +We use the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting the code. |
| 45 | +We document every user-facing class or method, and enforce that using the flake8-docstrings library. |
| 46 | + |
| 47 | +The documentation is then rendered from the docstrings in the code, using `pydoc-markdown` and some heavy post-processing, |
| 48 | +and from Markdown documents in the `docs` folder in the `docs` branch, and then rendered using Docusaurus and published to GitHub pages. |
| 49 | + |
| 50 | +## Release process |
| 51 | + |
| 52 | +Publishing new versions to [PyPI](https://pypi.org/project/apify) happens automatically through GitHub Actions. |
| 53 | + |
| 54 | +On each commit to the `master` branch, a new beta release is published, taking the version number from `src/apify/_version.py` |
| 55 | +and automatically incrementing the beta version suffix by 1 from the last beta release published to PyPI. |
| 56 | + |
| 57 | +A stable version is published when a new release is created using GitHub Releases, again taking the version number from `src/apify/_version.py`. |
| 58 | +The built package assets are automatically uploaded to the GitHub release. |
| 59 | + |
| 60 | +If there is already a stable version with the same version number as in `src/apify/_version.py` published to PyPI, the publish process fails, |
| 61 | +so don't forget to update the version number before releasing a new version. |
| 62 | +The release process also fails when the released version is not described in `CHANGELOG.md`, |
| 63 | +so don't forget to describe the changes in the new version there. |
0 commit comments