Skip to content

Commit

Permalink
Switch to pdm as project manager
Browse files Browse the repository at this point in the history
1. lockfiles, so CI can be consistent. It wasn't locked and was failing
because of this.
2. less boiler plate for building and
uploading wheels, for setting up dev env
3. allows venvs for different python verisons, useful for
eg #49
4. less config files
5. add metadata to pyproject.toml, for better ecosystem interoperability
6. Just more modern and better updates.
  • Loading branch information
NickCrews committed May 30, 2023
1 parent 10a9c1a commit 9a0fae5
Show file tree
Hide file tree
Showing 12 changed files with 681 additions and 94 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,50 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- name: Set up PDM for Python ${{ matrix.python-version }}
uses: pdm-project/setup-pdm@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
pdm sync -d -G dev
# Linting is taken care of by pre-commit
# in a different github action
- name: Run tests
run: |
pytest --cov-report term-missing --cov-report xml --cov=docopt --mypy
pdm run -v pytest --cov-report term-missing --cov-report xml --cov=docopt --mypy
- name: Upload coverage
uses: codecov/codecov-action@v2
with:
name: Python ${{ matrix.python-version }}
fail_ci_if_error: true

- name: Build wheels and sdist
run: |
pdm build
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
# These are pure-python, so we don't need to worry about platform
name: wheels
# name: Python ${{ matrix.python-version }}
path: |
dist/*.whl
dist/*.tar.gz
release:
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade twine build
- name: Build package
run: |
python -m build
twine check dist/*
name: wheels
path: dist

- name: Upload packages to Jazzband
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ pip-log.txt
# Unit test / coverage reports
.coverage
coverage.xml
.pdm-python
12 changes: 7 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
### Changed
- Tweak a few things to restore compatibility with docopt (the original repo) 0.6.2
See PR https://github.com/jazzband/docopt-ng/pull/36 for more info

1. BREAKING: Restore what constitutes an "option":
Now the important rule to follow is
`any line starting with - or -- is treated as an option`.
This means that some things that did NOT used to be treated
as options, now ARE treated as options:

1. lines before `usage:`
2. non-indented --options
3. lines not inside the options: section

However, we also keep one part of the old behavior of this fork where in the line
`header that ends with the keyword options: --foo`, --foo is still treated as
an option because the start of a line up to `options:` is ignored.

2. BREAKING: Error messages are tweaked a little bit. Unlikely that you relied
on them, but just in case.

3. NONBREAKING: Now allow for blank lines between options.
As described in https://github.com/jazzband/docopt-ng/issues/33

Expand All @@ -42,6 +42,8 @@
Now, both of these examples are treated more intuitively, where Enable
is treated as the description

- (for devs) Switch to PDM as project manager

## Version 0.8.1:

- Fixup of auto release in Github Actions
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,18 @@ out, read the source if in doubt.
We would *love* to hear what you think about **docopt-ng** on our
[issues page](https://github.com/jazzband/docopt-ng/issues). Make pull requests, report bugs, and suggest ideas.

To setup your dev environment, fork this repo, clone it locally, and then create
a dev environment:
To setup your dev environment, fork this repo and clone it locally.
We use [pdm](https://pdm.fming.dev/latest/#installation) to
manage the project, so install that first.

python -m venv .venv
source .venv/bin/activate
Then install dev requirements and the package itself as editable, then
install the pre-commit hooks:

Then install this package as editable, as well as dev requirements.

python -m pip install -e .[dev]
pdm sync -d -G dev
pdm run pre-commit install

Useful testing, linting, and formatting commands:

pytest
black **/*.py
flake8 **.*.py
pdm run pytest
pdm run black .
pdm run ruff .
3 changes: 2 additions & 1 deletion docopt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
from typing import Union
from typing import cast

from ._version import __version__ as __version__

__all__ = ["docopt", "magic_docopt", "magic", "DocoptExit"]
__version__ = "0.8.1"


def levenshtein_norm(source: str, target: str) -> float:
Expand Down
1 change: 1 addition & 0 deletions docopt/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.8.2"

0 comments on commit 9a0fae5

Please sign in to comment.