diff --git a/.github/workflows/govcookiecutter-template-build.yml b/.github/workflows/govcookiecutter-template-build.yml index 1668c38..964bd53 100644 --- a/.github/workflows/govcookiecutter-template-build.yml +++ b/.github/workflows/govcookiecutter-template-build.yml @@ -69,7 +69,7 @@ jobs: make docs elif [ "$RUNNER_OS" == "Windows" ]; then pip install -U pip setuptools - pip install -r requirements.txt + pip install -e .[dev] pre-commit install sphinx-build -b html ./docs ./docs/_build else diff --git a/README.md b/README.md index bb61781..3e78761 100644 --- a/README.md +++ b/README.md @@ -40,19 +40,24 @@ Once you've answered all the prompts, your project will be created. Then: 1. Set up a Python virtual environment — [there are many ways to set up a virtual environment][pluralsight], so we'll let you decide what's best for you! + 2. In your terminal, navigate to your new project, and initialise Git ```shell git init ``` + 3. Install the necessary packages using `pip` and the pre-commit hooks: ```shell - pip install -r requirements.txt + python -m pip install -U pip setuptools + python -m pip install -e .[dev] pre-commit install ``` + or use the `make` command: ```shell - make requirements + make install_dev ``` + 4. Stage all your project files, and make your first commit ```shell git add . diff --git a/{{ cookiecutter.repo_name }}/Makefile b/{{ cookiecutter.repo_name }}/Makefile index d22da3f..24203d8 100644 --- a/{{ cookiecutter.repo_name }}/Makefile +++ b/{{ cookiecutter.repo_name }}/Makefile @@ -5,32 +5,38 @@ docs docs_check_external_links help + install + install_dev prepare_docs_folder - requirements .DEFAULT_GOAL := help -## Install the Python requirements for contributors, and install pre-commit hooks -requirements: +## Install the Python package for contributors, and install pre-commit hooks +install_dev: python -m pip install -U pip setuptools - python -m pip install -r requirements.txt + python -m pip install -e .[dev] pre-commit install +## Install the Python package for users +install: + python -m pip install -U pip setuptools + python -m pip install -e . + ## Create a `docs/_build` folder, if it does not exist. Otherwise delete any sub-folders and their contents within it prepare_docs_folder: if [ ! -d "./docs/_build" ]; then mkdir ./docs/_build; fi find ./docs/_build -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \; ## Compile the Sphinx documentation in HTML format in the docs/_build folder from a clean build -docs: prepare_docs_folder requirements +docs: prepare_docs_folder install_dev sphinx-build -b html ./docs ./docs/_build ## Check external links in the Sphinx documentation using linkcheck in the docs/_build folder from a clean build -docs_check_external_links: prepare_docs_folder requirements +docs_check_external_links: prepare_docs_folder install_dev sphinx-build -b linkcheck ./docs ./docs/_build ## Run code coverage -coverage: requirements +coverage: install_dev coverage run -m pytest ## Run code coverage, and produce a HTML output diff --git a/{{ cookiecutter.repo_name }}/README.md b/{{ cookiecutter.repo_name }}/README.md index e87a172..301c4e0 100644 --- a/{{ cookiecutter.repo_name }}/README.md +++ b/{{ cookiecutter.repo_name }}/README.md @@ -20,8 +20,13 @@ Whilst in the root folder, in the command prompt, you can install the package an using: ```shell +python -m pip install -U pip setuptools pip install -e . ``` +or use the `make` command: +```shell +make install +``` This installs an editable version of the package. Meaning, when you update the package code, you do not have to reinstall it for the changes to take effect. @@ -79,10 +84,15 @@ contributing guidelines][contributing]. credentials](#required-secrets-and-credentials) - [load environment variables][docs-loading-environment-variables] from `.env` -To install the Python requirements, open your terminal and enter: - +To install the contributing requirements, open your terminal and enter: +```shell +python -m pip install -U pip setuptools +pip install -e .[dev] +pre-commit install +``` +or use the `make` command: ```shell -pip install -r requirements.txt +make install_dev ``` ## Acknowledgements diff --git a/{{ cookiecutter.repo_name }}/docs/contributor_guide/CONTRIBUTING.md b/{{ cookiecutter.repo_name }}/docs/contributor_guide/CONTRIBUTING.md index 621f328..a9d09bd 100644 --- a/{{ cookiecutter.repo_name }}/docs/contributor_guide/CONTRIBUTING.md +++ b/{{ cookiecutter.repo_name }}/docs/contributor_guide/CONTRIBUTING.md @@ -10,18 +10,17 @@ we'd be happy to help! ## Getting started -To start contributing, open your terminal, and install the required Python packages, -and [pre-commit hooks][pre-commit] using: +To start contributing, open your terminal and install the package and +[pre-commit hooks][pre-commit] using: ```shell -pip install -r requirements.txt +pip install -e .[dev] pre-commit install ``` -or the `make` command: - +or use the `make` command: ```shell -make requirements +make install_dev ``` The pre-commit hooks are a security feature to ensure, for example, no secrets[^1], diff --git a/{{ cookiecutter.repo_name }}/make.bat b/{{ cookiecutter.repo_name }}/make.bat index 30ab66b..6f79204 100644 --- a/{{ cookiecutter.repo_name }}/make.bat +++ b/{{ cookiecutter.repo_name }}/make.bat @@ -2,7 +2,8 @@ IF /I "%1"=="" GOTO .DEFAULT_GOAL -IF /I "%1"=="requirements" GOTO requirements +IF /I "%1"=="install" GOTO install +IF /I "%1"=="install_dev" GOTO install_dev IF /I "%1"=="prepare_docs_folder" GOTO prepare_docs_folder IF /I "%1"=="docs" GOTO docs IF /I "%1"=="docs_check_external_links" GOTO docs_check_external_links @@ -15,12 +16,17 @@ GOTO error :.DEFAULT_GOAL GOTO help -:requirements +:install_dev python -m pip install -U pip setuptools - python -m pip install -r requirements.txt + python -m pip install -e .[dev] pre-commit install GOTO :EOF +:install + python -m pip install -U pip setuptools + python -m pip install -e . + GOTO :EOF + :prepare_docs_folder IF exist "./docs/_build" ( rmdir /s /q "./docs/_build/" ) mkdir ".\docs\_build" @@ -28,18 +34,18 @@ GOTO error :docs CALL make.bat prepare_docs_folder - CALL make.bat requirements + CALL make.bat install_dev sphinx-build -b html ./docs ./docs/_build GOTO :EOF :docs_check_external_links CALL make.bat prepare_docs_folder - CALL make.bat requirements + CALL make.bat install_dev sphinx-build -b linkcheck ./docs ./docs/_build GOTO :EOF :coverage - CALL make.bat requirements + CALL make.bat install_dev coverage run -m pytest GOTO :EOF @@ -54,7 +60,7 @@ GOTO error GOTO :EOF :help - ECHO make: Use one of the following commands: requirements, docs, docs_check_external_links, coverage, coverage_html, coverage_xml. + ECHO make: Use one of the following commands: install, install_dev, docs, docs_check_external_links, coverage, coverage_html, coverage_xml. GOTO :EOF :error diff --git a/{{ cookiecutter.repo_name }}/requirements.txt b/{{ cookiecutter.repo_name }}/requirements.txt deleted file mode 100644 index 7326347..0000000 --- a/{{ cookiecutter.repo_name }}/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -coverage -detect-secrets==1.0.3 -myst-parser -pre-commit -pytest -python-dotenv -Sphinx -toml diff --git a/{{ cookiecutter.repo_name }}/setup.cfg b/{{ cookiecutter.repo_name }}/setup.cfg index 57d7892..2c37313 100644 --- a/{{ cookiecutter.repo_name }}/setup.cfg +++ b/{{ cookiecutter.repo_name }}/setup.cfg @@ -14,6 +14,14 @@ classifiers = packages = {{ cookiecutter.repo_name.lower().replace(' ', '_').replace('-', '_') }} install_requires = + pyyaml +python_requires = >=3.6 +package_dir = + =./src +zip_safe = no + +[options.extras_require] +dev = coverage detect-secrets == 1.0.3 myst-parser @@ -23,7 +31,3 @@ install_requires = python-dotenv Sphinx toml -python_requires = >=3.6 -package_dir = - =./src -zip_safe = no