Skip to content

Commit

Permalink
refactor: Don't fetch all tags and commits, instead tell PDM which ve…
Browse files Browse the repository at this point in the history
…rsion to use when building
  • Loading branch information
pawamoy committed Oct 23, 2024
1 parent 986c947 commit 439acab
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 50 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Configure Git
run: |
Expand Down Expand Up @@ -100,9 +97,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Configure Git
run: |
Expand Down
66 changes: 33 additions & 33 deletions docs/work.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,53 +129,53 @@ Available tasks:

- `build`: Build source and wheel distributions.
- `changelog`: Update the changelog in-place with latest commits.
See [the Changelog section](#changelog).
See [the Changelog section](#changelog).
- `check`: Check it all!
See [the Quality Analysis section](#quality-analysis).
See [the Quality Analysis section](#quality-analysis).
- `check-quality`: Check the code quality.
See [the check-quality section](#check-quality).
See [the check-quality section](#check-quality).
- `check-docs`: Check if the documentation builds correctly.
See [the check-docs section](#check-docs).
See [the check-docs section](#check-docs).
- `check-types`: Check that the code is correctly typed.
See [the check-types section](#check-types).
See [the check-types section](#check-types).
- `clean`: Delete temporary files.
- `coverage`: Report coverage as text and HTML.
- `docs`: Serve the documentation (localhost:8000).
See [the Documentation section](#documentation).
Arguments:
See [the Documentation section](#documentation).
Arguments:
- `host="127.0.0.1"`: The host to serve the docs from.
- `port=8000`: The port to serve the docs on.
- `format`: Run formatting tools on the code.
- `publish`: Publish source and wheel distributions to PyPI.
- `release`: Release a new Python package.
See [the Releases section](#releases).
Arguments:
See [the Releases section](#releases).
Arguments:
- `version` The Python package version.
- `test`: Run the test suite.
See [the Tests section](#tests).
Arguments:
See [the Tests section](#tests).
Arguments:
- `match=""`: A pytest expression to filter selected tests.
- `vscode`: Configure VSCode for the project.
See [VSCode setup](#vscode-setup).
See [VSCode setup](#vscode-setup).

The `make` script provides some additional commands:

- `make help`: Print available commands and tasks.
- `make setup`: Install project and dependencies for all configured Python versions,
as well as in a default virtual environment (`.venv` + `.venvs/*`).
as well as in a default virtual environment (`.venv` + `.venvs/*`).
- `make run command --args`: run arbitrary commands in the default Python virtual environment (`.venv`).
This command can be useful to run a Python interpreter without having to activate the venv:
`make run python`.
This command can be useful to run a Python interpreter without having to activate the venv:
`make run python`.
- `make multirun command --args`: run arbitrary commands for all configured Python versions (`.venvs/*`).
This command can be useful to check something on all Python versions:
`make multirun python -c 'import sys; print(sys.version_info)'`.
This command can be useful to check something on all Python versions:
`make multirun python -c 'import sys; print(sys.version_info)'`.
- `make allrun command --args`: run arbitrary commands in *all* Python virtual environments (`.venv` + `.venvs/*`).
This command can be useful to override some of the installed dependencies,
or to install local packages as editable:
`make allrun pip install -U some-dependency==2.0`, `make allrun pip install -e ../some-project`.
This command can be useful to override some of the installed dependencies,
or to install local packages as editable:
`make allrun pip install -U some-dependency==2.0`, `make allrun pip install -e ../some-project`.
- `make 3.x command --args`: run arbitrary commands for a specific Python versions (`.venvs/3.x`).
This command can be useful to check something on a specific Python version:
`make 3.13 duty docs`.
This command can be useful to check something on a specific Python version:
`make 3.13 duty docs`.

### VSCode setup

Expand Down Expand Up @@ -211,10 +211,10 @@ Now you can start writing and editing code in `src/your_package`.
- You can auto-format the code with `make format`.
- You can run a quality analysis with `make check`.
- Once you wrote tests for your new code,
you can run the test suite with `make test`.
you can run the test suite with `make test`.
- Once you are ready to publish a new release,
run `make changelog`, then `make release version=x.y.z`,
where `x.y.z` is the version added to the changelog.
run `make changelog`, then `make release version=x.y.z`,
where `x.y.z` is the version added to the changelog.

To summarize, the typical workflow is:

Expand Down Expand Up @@ -301,7 +301,7 @@ $ make check-quality
You can disable multiple different warnings on a single line
by separating them with commas:
```python title="src/your_package/module.py"
````python title="src/your_package/module.py"
markdown_docstring = """
Look at this docstring:
Expand All @@ -311,7 +311,7 @@ markdown_docstring = """
\"\"\"
```
""" # noqa: D300,D301
```
````
You can disable a warning globally by adding its ID
into the list in `config/ruff.toml`.
Expand All @@ -321,7 +321,7 @@ You can also disable warnings per file, like so:
```toml title="config/ruff.toml"
[per-file-ignores]
"src/your_package/your_module.py" = [
"T201", # Print statement
"T201", # Print statement
]
```
Expand Down Expand Up @@ -581,11 +581,11 @@ For example, with these docs structure:
```yaml title="mkdocs.yml"
nav:
- Overview: index.md
- Code Reference:
- cli.py: reference/cli.md
- logic.py: reference/logic.md
- Changelog: changelog.md
- Overview: index.md
- Code Reference:
- cli.py: reference/cli.md
- logic.py: reference/logic.md
- Changelog: changelog.md
```
Note that we matched the sections in the navigation with the folder tree,
Expand Down
6 changes: 0 additions & 6 deletions project/.github/workflows/ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -117,9 +114,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Python
uses: actions/setup-python@v5
Expand Down
14 changes: 9 additions & 5 deletions project/scripts/make
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ from textwrap import dedent
from typing import Any, Iterator

PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.9 3.10 3.11 3.12 3.13 3.14").split()
CI = "CI" in os.environ


def shell(cmd: str, capture_output: bool = False, **kwargs: Any) -> str | None:
Expand All @@ -37,11 +38,14 @@ def environ(**kwargs: str) -> Iterator[None]:

def uv_install(venv: Path) -> None:
"""Install dependencies using uv."""
with environ(UV_PROJECT_ENVIRONMENT=str(venv), PYO3_USE_ABI3_FORWARD_COMPATIBILITY="1"):
if "CI" in os.environ:
shell("uv sync --no-editable")
else:
shell("uv sync")
env = {
"UV_PROJECT_ENVIRONMENT": str(venv),
"PYO3_USE_ABI3_FORWARD_COMPATIBILITY": "1",
}
if CI:
env["PDM_BUILD_SCM_VERSION"] = "100"
with environ(**env):
shell(f"uv sync{' --no-editable' if CI else ''}")


def setup() -> None:
Expand Down

0 comments on commit 439acab

Please sign in to comment.