govcookiecutter icon indicating copy to clipboard operation
govcookiecutter copied to clipboard

Make the `{{ cookiecutter.repo_name }}/src` package installable

Open ESKYoung opened this issue 3 years ago • 1 comments

It might be useful to make the src package installable by adding a setup.py file. Adding this could make it easier to publish packages on PyPI, and may also resolve some of the path issues that can occur when using Jupyter notebooks. Note you may need the autoreload Jupyter extension to get all the latest local changes for a locally installed package.

Some things to consider:

  • moving all the subfolders within {{ cookiecutter.repo_name }}/src into something like{{ cookiecutter.repo_name }}/src/{{ cookiecutter.repo_name.lower().replace(' ', '_').replace('-', '_' ) }}
  • adding a {{ cookiecutter.repo_name }}/setup.py; for examples see ONS Best Practice and Impact, or navdeep-G's one
  • adding -e . to {{ cookiecutter.repo_name }}/requirements.txt
  • refactoring any environment variables related to folder paths within {{ cookiecutter.repo_name }}/src
  • refactoring any relevant documentation and tests

ESKYoung avatar Jun 21 '21 09:06 ESKYoung

Upvoting as this causes a bit of work every time I use the repo template.

Following the example in the python docs, I find the hatchling build with a pyproject.toml setup (no setup.* files) to be the most straightforward. Also to alter the src directory to src/package_name as in the docs example.

r-leyshon avatar Nov 14 '22 07:11 r-leyshon