Skip to content

Commit

Permalink
add: Add dev dependencies to user setup.cfg (#88)
Browse files Browse the repository at this point in the history
* add: add dev requirements to the setup.cfg

* remove: remove requirements file

* docs: update docs to refelect the updated dev requirements

* fix: replace requirements install in workflow for pip install

* fix: update makefile to use pip install over requiremnets.txt

* fix: update makefile to install package as dev or user

* fix: remove requirements from makefile and update windows makefile

* docs: update docs to use make command and remove requirements.txt file

* style: fixed layout issue in readme

* style: fix the layout of the initial readme

* docs: updated contributing guides inside package
  • Loading branch information
joshlynchONS authored Jun 12, 2023
1 parent df58ec8 commit ce8e083
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/govcookiecutter-template-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
20 changes: 13 additions & 7 deletions {{ cookiecutter.repo_name }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions {{ cookiecutter.repo_name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
20 changes: 13 additions & 7 deletions {{ cookiecutter.repo_name }}/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,31 +16,36 @@ 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"
GOTO :EOF

: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

Expand All @@ -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
Expand Down
8 changes: 0 additions & 8 deletions {{ cookiecutter.repo_name }}/requirements.txt

This file was deleted.

12 changes: 8 additions & 4 deletions {{ cookiecutter.repo_name }}/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +31,3 @@ install_requires =
python-dotenv
Sphinx
toml
python_requires = >=3.6
package_dir =
=./src
zip_safe = no

0 comments on commit ce8e083

Please sign in to comment.