Skip to content

Commit

Permalink
Merge pull request #173 from Preocts/preocts
Browse files Browse the repository at this point in the history
Move contributing details
  • Loading branch information
Preocts authored Aug 3, 2024
2 parents 0d2edad + e74dcc2 commit 8c78971
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 165 deletions.
169 changes: 155 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ Before contributing, please either ask to claim an existing open issue or create
a new issue to discuss your proposed changes with the owner(s) of this repo
before making any changes.

*Any pull requests without an approved issue associated with them will be
closed*
Any pull requests without a clearly defined issue being solved will be closed.

## Bug reports
### Bug reports

Found a bug but do not have time or do not wish to contribute a fix? Please
submit an issue for our awareness. Your feedback drives the continued
development of the project!

## Fork

Create your own fork of this repo that you will make your changes on.

## Creating your feature

Always base your changes off the `main` branch unless otherwise asked.

## Pull Request
### Pull Request

All pull requests must:

Expand All @@ -30,16 +21,166 @@ All pull requests must:
- If the PR is a bug fix there must be a test that duplicates the bug, proving
it is fixed

## Code Style
### Code Style

Follow the patterns seen in the code. Walk where others have walked.

The majority of code style nits will be met when passing `pre-commit` checks
prior to submitting a pull request.

## Tests
### Tests

- Smaller tests are easier to work with
- Mock at a minimum
- No test should be dependent on another
- No test should be dependent on secrets/tokens


---

# Local developer installation

The following steps outline how to install this repo for local development.

## Prerequisites

### Clone repo

```console
git clone https://github.com/[ORG NAME]/[REPO NAME]

cd [REPO NAME]
```

### Virtual Environment

Use a ([`venv`](https://docs.python.org/3/library/venv.html)), or equivalent,
when working with python projects. Leveraging a `venv` will ensure the installed
dependency files will not impact other python projects or any system
dependencies.

**Windows users**: Depending on your python install you will use `py` in place
of `python` to create the `venv`.

**Linux/Mac users**: Replace `python`, if needed, with the appropriate call to
the desired version while creating the `venv`. (e.g. `python3` or `python3.12`)

**All users**: Once inside an active `venv` all systems should allow the use of
`python` for command line instructions. This will ensure you are using the
`venv`'s python and not the system level python.

### Create the `venv`:

```console
python -m venv venv
```

Activate the `venv`:

```console
# Linux/Mac
. venv/bin/activate

# Windows
venv\Scripts\activate
```

The command prompt should now have a `(venv)` prefix on it. `python` will now
call the version of the interpreter used to create the `venv`

To deactivate (exit) the `venv`:

```console
deactivate
```

---

## Developer Installation Steps

### Install editable library and development requirements

```console
python -m pip install --editable .[dev,test]
```

### Install pre-commit [(see below for details)](#pre-commit)

```console
pre-commit install
```

### Install with nox

If you have `nox` installed with `pipx` or in the current venv you can use the
following session. This is an alternative to the two steps above.

```console
nox -s install
```

---

## Pre-commit and nox tools

### Run pre-commit on all files

```console
pre-commit run --all-files
```

### Run tests with coverage (quick)

```console
nox -e coverage
```

### Run tests (slow)

```console
nox
```

### Build dist

```console
nox -e build
```

---

## Updating dependencies

New dependencys can be added to the `requirements-*.in` file. It is recommended
to only use pins when specific versions or upgrades beyond a certain version are
to be avoided. Otherwise, allow `pip-compile` to manage the pins in the
generated `requirements-*.txt` files.

Once updated following the steps below, the package can be installed if needed.

### Update the generated files with changes

```console
nox -e update
```

### Upgrade all generated dependencies

```console
nox -e upgrade
```

---

## [pre-commit](https://pre-commit.com)

> A framework for managing and maintaining multi-language pre-commit hooks.
This repo is setup with a `.pre-commit-config.yaml` with the expectation that
any code submitted for review already passes all selected pre-commit checks.

---

## Error: File "setup.py" not found

Update `pip` to at least version 22.3.1
151 changes: 0 additions & 151 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,154 +37,3 @@ fit.
- **A:** I'm constantly finding new tweaks that make the template fit just a
little better. I'm also open to ideas and suggestions so please drop an
issue if you have one.

---

# Local developer installation

The following steps outline how to install this repo for local development. See
the [CONTRIBUTING.md](CONTRIBUTING.md) file in the repo root for information on
contributing to the repo.

## Prerequisites

### Clone repo

```console
git clone https://github.com/[ORG NAME]/[REPO NAME]

cd [REPO NAME]
```

### Virtual Environment

Use a ([`venv`](https://docs.python.org/3/library/venv.html)), or equivalent,
when working with python projects. Leveraging a `venv` will ensure the installed
dependency files will not impact other python projects or any system
dependencies.

**Windows users**: Depending on your python install you will use `py` in place
of `python` to create the `venv`.

**Linux/Mac users**: Replace `python`, if needed, with the appropriate call to
the desired version while creating the `venv`. (e.g. `python3` or `python3.8`)

**All users**: Once inside an active `venv` all systems should allow the use of
`python` for command line instructions. This will ensure you are using the
`venv`'s python and not the system level python.

### Create the `venv`:

```console
python -m venv venv
```

Activate the `venv`:

```console
# Linux/Mac
. venv/bin/activate

# Windows
venv\Scripts\activate
```

The command prompt should now have a `(venv)` prefix on it. `python` will now
call the version of the interpreter used to create the `venv`

To deactivate (exit) the `venv`:

```console
deactivate
```

---

## Developer Installation Steps

### Install editable library and development requirements

```console
python -m pip install --editable .[dev,test]
```

### Install pre-commit [(see below for details)](#pre-commit)

```console
pre-commit install
```

### Install with nox

If you have `nox` installed with `pipx` or in the current venv you can use the
following session. This is an alternative to the two steps above.

```console
nox -s install
```

---

## Pre-commit and nox tools

### Run pre-commit on all files

```console
pre-commit run --all-files
```

### Run tests with coverage (quick)

```console
nox -e coverage
```

### Run tests (slow)

```console
nox
```

### Build dist

```console
nox -e build
```

---

## Updating dependencies

New dependencys can be added to the `requirements-*.in` file. It is recommended
to only use pins when specific versions or upgrades beyond a certain version are
to be avoided. Otherwise, allow `pip-compile` to manage the pins in the
generated `requirements-*.txt` files.

Once updated following the steps below, the package can be installed if needed.

### Update the generated files with changes

```console
nox -e update
```

### Upgrade all generated dependencies

```console
nox -e upgrade
```

---

## [pre-commit](https://pre-commit.com)

> A framework for managing and maintaining multi-language pre-commit hooks.
This repo is setup with a `.pre-commit-config.yaml` with the expectation that
any code submitted for review already passes all selected pre-commit checks.

---

## Error: File "setup.py" not found

Update `pip` to at least version 22.3.1
16 changes: 16 additions & 0 deletions init_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
PLACEHOLDER_DIR = [Path("src/module_name/sample_data")]
PYPROJECT_TARGET = Path("pyproject.toml")
README_TARGET = Path("README.md")
CONTRIBUTING_TARGET = Path("CONTRIBUTING.md")
NOX_TARGET = Path("noxfile.py")
ALT_FILE_DIR = Path("alt_files")
REQUIREMENTS_DIR = Path("requirements")
Expand Down Expand Up @@ -111,6 +112,20 @@ def replace_readme_values(data: ProjectData) -> None:
README_TARGET.write_text(readme)


@bookends("Updating references in CONTRIBUTING.md")
def replace_contributing_values(data: ProjectData) -> None:
"""Update badge urls and placeholders in README.md"""
readme = CONTRIBUTING_TARGET.read_text()
default = ProjectData()

readme = re.sub(ORG, data.org_name, readme)
readme = re.sub(REPO, data.repo_name, readme)
readme = re.sub(re.escape(default.org_name), data.org_name, readme)
readme = re.sub(re.escape(default.repo_name), data.repo_name, readme)

CONTRIBUTING_TARGET.write_text(readme)


@bookends("Updating noxfile.py values")
def replace_nox_values(data: ProjectData) -> None:
"""Update nox value, replacing module_name with actual module name."""
Expand All @@ -134,6 +149,7 @@ def rename_module_folder(name: str) -> None:
replace_pyproject_values(project_data)
replace_nox_values(project_data)
replace_readme_values(project_data)
replace_contributing_values(project_data)

delete_placeholder_files()
delete_placeholder_directories()
Expand Down

0 comments on commit 8c78971

Please sign in to comment.