Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin dev requirements, drop makefile #38

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions Makefile

This file was deleted.

136 changes: 72 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,24 @@ closing=0

# Local developer installation

It is **strongly** recommended to use a virtual environment
([`venv`](https://docs.python.org/3/library/venv.html)) when working with python
projects. Leveraging a `venv` will ensure the installed dependency files will
not impact other python projects or any system dependencies.
The following steps outline how to install this repo for local development.

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/Precots/commented-configparser

cd commented-configparser
```

### 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`.
Expand All @@ -129,94 +139,105 @@ the desired version while creating the `venv`. (e.g. `python3` or `python3.8`)
`python` for command line instructions. This will ensure you are using the
`venv`'s python and not the system level python.

---

## Installation steps

Clone this repo and enter root directory of repo:
### Create the `venv`:

```console
$ git clone https://github.com/Preocts/commented-configparser
$ cd commented-configparser
```

Create the `venv`:

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

Activate the `venv`:

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

# Windows
$ venv\Scripts\activate
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`

Install editable library and development requirements:
To deactivate (exit) the `venv`:

```console
deactivate
```

---

## Developer Installation Steps

### Install editable library and development requirements

```console
# Update pip and tools
$ python -m pip install --upgrade pip
python -m pip install --editable .[dev,test]
```

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

# Install editable version of library
$ python -m pip install --editable .[dev]
```console
pre-commit install
```

Install pre-commit [(see below for details)](#pre-commit):
### 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
$ pre-commit install
nox -s install
```

---

## Misc Steps
## Pre-commit and nox tools

Run pre-commit on all files:
### Run pre-commit on all files

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

Run tests:
### Run tests with coverage (quick)

```console
$ tox [-r] [-e py3x]
nox -e coverage
```

Build dist:
### Run tests (slow)

```console
$ python -m pip install --upgrade build

$ python -m build
nox
```

To deactivate (exit) the `venv`:
### Build dist

```console
$ deactivate
nox -e build
```

---

## Note on flake8:
## Updating dependencies

`flake8` is included in the `requirements-dev.txt` of the project. However it
disagrees with `black`, the formatter of choice, on max-line-length and two
general linting errors. `.pre-commit-config.yaml` is already configured to
ignore these. `flake8` doesn't support `pyproject.toml` so be sure to add the
following to the editor of choice as needed.
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.

```ini
--ignore=W503,E203
--max-line-length=88
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
```

---
Expand All @@ -227,22 +248,9 @@ following to the editor of choice as needed.

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.
`pre-commit` is installed with the development requirements and runs seemlessly
with `git` hooks.

---

## Makefile

This repo has a Makefile with some quality of life scripts if the system
supports `make`. Please note there are no checks for an active `venv` in the
Makefile.
## Error: File "setup.py" not found

| PHONY | Description |
| ------------- | -------------------------------------------------------------------------- |
| `init` | Update pip to newest version |
| `install` | install the project |
| `install-dev` | install development/test requirements and project as editable install |
| `upgrade-dev` | update all dependencies, regenerate requirements.txt (disabled by default) |
| `build-dist` | Build source distribution and wheel distribution |
| `clean` | Deletes build, tox, coverage, pytest, mypy, cache, and pyc artifacts |
Update `pip` to at least version 22.3.1
24 changes: 8 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,15 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython"
]

dependencies = []
# Dynamic dependencies are loaded from requirements*.txt files
dynamic = ["dependencies", "optional-dependencies"]

[project.optional-dependencies]
dev = [
"pre-commit",
"black",
"mypy",
"flake8",
"flake8-builtins",
"flake8-pep585",
]
test = [
"pytest",
"pytest-randomly",
"coverage",
"nox"
]
[tool.setuptools.dynamic.dependencies]
file = ["requirements/requirements.txt"]

[tool.setuptools.dynamic.optional-dependencies]
dev = { file = ["requirements/requirements-dev.txt"] }
test = { file = ["requirements/requirements-test.txt"] }

[project.urls]
homepage = "https://github.com/Preocts/commented-configparser"
Expand Down
15 changes: 15 additions & 0 deletions requirements/requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Development Requirements - linting, formatting, etc.
# Ensure to set PIP_INDEX_URL to the correct value for your environment
# This is the URL to the Artifactory instance that hosts the Python packages (default: pypi.org)
# This will not be emitted to the requirements*.txt files and must be set in the environment
# before running pip install

# Constrain versions installed to be compatible with core dependencies
--constraint requirements.txt

pre-commit
black
mypy
flake8
flake8-builtins
flake8-pep585
59 changes: 59 additions & 0 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --no-emit-index-url requirements/requirements-dev.in
#
black==24.3.0
# via -r requirements/requirements-dev.in
cfgv==3.4.0
# via pre-commit
click==8.1.7
# via black
distlib==0.3.8
# via virtualenv
filelock==3.13.1
# via virtualenv
flake8==7.0.0
# via
# -r requirements/requirements-dev.in
# flake8-builtins
flake8-builtins==2.2.0
# via -r requirements/requirements-dev.in
flake8-pep585==0.1.7
# via -r requirements/requirements-dev.in
identify==2.5.35
# via pre-commit
mccabe==0.7.0
# via flake8
mypy==1.9.0
# via -r requirements/requirements-dev.in
mypy-extensions==1.0.0
# via
# black
# mypy
nodeenv==1.8.0
# via pre-commit
packaging==24.0
# via black
pathspec==0.12.1
# via black
platformdirs==4.2.0
# via
# black
# virtualenv
pre-commit==3.6.2
# via -r requirements/requirements-dev.in
pycodestyle==2.11.1
# via flake8
pyflakes==3.2.0
# via flake8
pyyaml==6.0.1
# via pre-commit
typing-extensions==4.10.0
# via mypy
virtualenv==20.25.1
# via pre-commit

# The following packages are considered to be unsafe in a requirements file:
# setuptools
14 changes: 14 additions & 0 deletions requirements/requirements-test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Testing Requirements
# ----------------------------------------
# Ensure to set PIP_INDEX_URL to the correct value for your environment
# This is the URL to the Artifactory instance that hosts the Python packages (default: pypi.org)
# This will not be emitted to the requirements*.txt files and must be set in the environment
# before running pip install

# Constrain versions installed to be compatible with core dependencies
--constraint requirements.txt

pytest
pytest-randomly
coverage
nox
Loading