development.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. .. _development:
  2. Development
  3. -----------
  4. You need the following requirements:
  5. - ``hatch`` for test automation and package dependency managements. If you don’t
  6. have hatch, you can use ``pipx run hatch`` to run it without installing, or
  7. ``pipx install hatch``. Dependencies and their versions are specified in the
  8. pyproject.toml file and updated in GitHub with Dependabot.
  9. You can run ``hatch env show`` to list available environments and scripts.
  10. ::
  11. hatch env create
  12. hatch run init # init repo with pre-commit hooks
  13. hatch run lint
  14. hatch run tests.py3.11:all
  15. Hatch handles everything for you, including setting up an temporary
  16. virtual environment for each run.
  17. - ``pre-commit`` for all style and consistency checking. While you can
  18. run it with nox, this is such an important tool that it deserves to
  19. be installed on its own. If pre-commit fails during pushing upstream
  20. then stage changes, Commit Extend (into previous commit), and repeat
  21. pushing.
  22. ``pip`` and ``hatch`` are pinned in .github/workflows/constraints.txt for
  23. consistency with CI/CD.
  24. If you like install hatch and required deps in archlinux with::
  25. pacman -S python-hatch python-hyperlink python-httpx
  26. While ``pre-commit`` is listed as a ’dev’ dependency, you also have the option
  27. to install it globally using pipx. This can be done with the following command::
  28. pipx install pre-commit
  29. Setting up a development with direnv
  30. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. ::
  32. echo "layout hatch" > .envrc
  33. hatch run init
  34. Setting up a development environment manually
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. You can set up a development environment by running:
  37. ::
  38. python3 -m venv .venv
  39. source ./.venv/bin/activate
  40. pip install -v -e .[dev,tests,docs]
  41. With direnv for using `Jupyter <https://jupyter.org/>`__ during
  42. development:
  43. ::
  44. jupiter notebook
  45. And only in case you need a system wide easy accessible kernel:
  46. ::
  47. python -m ipykernel install --user --name="dt_evolv"
  48. Testing and coverage
  49. ~~~~~~~~~~~~~~~~~~~~
  50. Use pytest to run the unit checks:
  51. ::
  52. pytest
  53. Use ``coverage`` to generate coverage reports:
  54. ::
  55. coverage run --branch -p -m pytest
  56. Or use hatch:
  57. ::
  58. hatch run tests:all
  59. (hatch run tests:cov)
  60. Building docs
  61. ~~~~~~~~~~~~~
  62. You can build the docs using:
  63. ::
  64. hatch run docs
  65. You can see a preview with:
  66. ::
  67. hatch run docserve
  68. When needed (e.g. API updates):
  69. ::
  70. sphinx-apidoc -f -o docs/api/ src/dt_evolv/
  71. Bump and releasing
  72. ~~~~~~~~~~~~~~~~~~
  73. To bump version and upload build to test.pypi using:
  74. ::
  75. hatch run bump
  76. hatch run bump "--increment PATCH" "--files-only" \
  77. ["--no-verify" to bypass pre-commit and commit-msg hooks]
  78. git push
  79. while to update only the CHANGELOG.md file:
  80. ::
  81. hatch run ch
  82. Release will automatically occur after pushing.
  83. (Otherwise)
  84. ::
  85. pipx run --spec commitizen cz bump --changelog-to-stdout --files-only \
  86. (--prerelease alpha) --increment MINOR
  87. To keep clean development history use branches and pr:
  88. ::
  89. gh pr create --fill
  90. gh pr merge --squash --delete-branch [-t “fix|ci|feat: msg”]
  91. Configuration files
  92. ~~~~~~~~~~~~~~~~~~~
  93. Manually updated pinned dependencies for CI/CD:
  94. - .github/workflows/constraints.txt (testing dependabot)
  95. Configuration files:
  96. - pre-commit configured in .pre-commit-config.yaml;
  97. - bandit (sys) configured in bandit.yml;
  98. - pylint (sys) configured in pyproject.toml;
  99. - isort (sys) configured in pyproject.toml;
  100. - black configured in pyproject.toml (pinned in pre-commit);
  101. - ruff configured in pyproject.toml (pinned in pre-commit);
  102. - darglint configured in .darglint (pinned in pre-commit);
  103. - codespell configured in .codespellrc (pinned in pre-commit);
  104. - coverage configured in pyproject.toml (tests deps);
  105. - mypy configured in pyproject.toml (tests deps);
  106. - commitizen in pyproject.toml (dev deps and pinned in pre-commit).
  107. While the exact dependencies and their versions are specified in the
  108. pyproject.toml file and updated in GitHub with Dependabot, a complete list of
  109. all the required packages and their versions (including transitive dependencies)
  110. can be generated by pip-deepfreeze in the requirements-[dev,docs,tests].txt
  111. files. This makes it possible to maintain a clear and detailed record of the
  112. project's dependency requirements, aiding in maintaining a stable and
  113. predictable environment across different setups.
  114. Other manual actions:
  115. ::
  116. pylint src/ tests/
  117. bandit -r src/