Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6208a54

Browse filesBrowse files
committed
Modernize project configs with uv & pyproject.toml
* Raise version to 3.0.3-alpha.1 * In pyproject.toml: - Use new dependency group from PEP 735 - Move all project related data from setup.cfg to pyproject.toml - Consolidate flake8, pycodestyle with ruff - Split Towncrier config type "trivial" into "trivial" and "internal" * Add uv's lock file (uv.lock) * Create config file for ruff (.ruff.toml) * Create config file for pytest (.pytest.ini) * Simplify tox.ini and remove old stuff * Document installation with new uv command * Simplify Sphinx config with find_version() * Update the authors * Use uv in GitHub Action python-testing.yml workflow
1 parent 8daa571 commit 6208a54
Copy full SHA for 6208a54

14 files changed

+1691
-159
lines changed

‎.editorconfig

Copy file name to clipboardExpand all lines: .editorconfig
+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ root = true
44
[*]
55
end_of_line = lf
66
charset = utf-8
7+
max_line_length = 99
78

89
[*.py]
910
indent_style = space

‎.github/workflows/python-testing.yml

Copy file name to clipboardExpand all lines: .github/workflows/python-testing.yml
+29-23
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,34 @@ jobs:
7171
check:
7272
runs-on: ubuntu-latest
7373
needs: check-files
74-
# Timout of 15min
7574
timeout-minutes: 15
7675
# needs.check-files.outputs.can_run
7776
if: ${{ needs.check-files.outputs.can_run == '1' }}
7877

7978
steps:
8079
- uses: actions/checkout@v4
81-
- name: Set up Python ${{ matrix.python-version }}
82-
uses: actions/setup-python@v5
80+
81+
- name: Install uv
82+
uses: astral-sh/setup-uv@v3
8383
with:
84-
python-version: 3.8
85-
cache: 'pip'
86-
- name: Install dependencies
87-
run: |
88-
python3 -m pip install --upgrade pip setuptools>60 setuptools-scm>=60
89-
pip install tox tox-gh-actions
90-
- name: Check
84+
enable-cache: true
85+
86+
- name: Set up Python 3.7
87+
# check tox.ini for the lowest version
88+
run: uv python install 3.7
89+
90+
- name: Install the project
9191
run: |
92-
tox run -e checks
92+
uv sync --all-extras --group gh-action
93+
94+
- name: Checks
95+
continue-on-error: true
96+
run: uv run tox run -e checks
9397

9498
tests:
9599
needs: check
96100
runs-on: ${{ matrix.os }}
97-
continue-on-error: true
101+
# continue-on-error: true
98102
strategy:
99103
max-parallel: 5
100104
fail-fast: true
@@ -114,15 +118,17 @@ jobs:
114118

115119
steps:
116120
- uses: actions/checkout@v4
117-
- name: Set up Python ${{ matrix.python-version }} for ${{ matrix.os }}
118-
uses: actions/setup-python@v5
119-
with:
120-
python-version: ${{ matrix.python-version }}
121-
cache: 'pip'
122-
- name: Install dependencies
123-
run: |
124-
python3 -m pip install --upgrade pip
125-
pip install tox tox-gh-actions
126-
- name: Test with tox
121+
122+
- name: Install uv
123+
uses: astral-sh/setup-uv@v3
124+
125+
- name: Set up Python ${{ matrix.python-version }}
126+
run: uv python install ${{ matrix.python-version }}
127+
128+
- name: Install the project
127129
run: |
128-
tox run
130+
uv sync --all-extras --dev
131+
uv pip install tox tox-gh-actions
132+
133+
- name: Checks
134+
run: uv run tox run -e ${{ matrix.python-version }}

‎.pytest.ini

Copy file name to clipboard
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[pytest]
2+
norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/
3+
testpaths = tests docs
4+
pythonpath = src tests
5+
filterwarnings =
6+
ignore:Function 'semver.*:DeprecationWarning
7+
# ' <- This apostroph is just to fix syntax highlighting
8+
addopts =
9+
--import-mode=importlib
10+
--no-cov-on-fail
11+
--cov=semver
12+
--cov-report=term-missing
13+
--doctest-glob='*.rst'
14+
--doctest-modules
15+
--doctest-report ndiff

‎.ruff.toml

Copy file name to clipboard
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# Configuration file for ruff
3+
# See https://docs.astral.sh/ruff/configuration/
4+
5+
line-length = 88
6+
indent-width = 4
7+
include = [
8+
"pyproject.toml",
9+
"src/**/*.py",
10+
"tests/**/*.py",
11+
"docs/**/*.py",
12+
]
13+
14+
[lint]
15+
extend-ignore = [
16+
"RUF005",
17+
"RUF012",
18+
# Comment contains ambiguous `’` (RIGHT SINGLE QUOTATION MARK):
19+
"RUF003",
20+
"ISC001",
21+
]
22+
select = [
23+
"F", # pyflakes
24+
"E", # pycodestyle
25+
"I", # isort
26+
"N", # pep8-naming
27+
"UP", # pyupgrade
28+
"RUF", # ruff
29+
"B", # flake8-bugbear
30+
"C4", # flake8-comprehensions
31+
"ISC", # flake8-implicit-str-concat
32+
"PTH", # flake8-use-pathlib
33+
"SIM", # flake8-simplify
34+
"TID", # flake8-tidy-imports
35+
]
36+
# TODO: Remove ISC001 ignore when formatter updated: https://github.com/astral-sh/ruff/issues/8272
37+
38+
39+
[format]
40+
# Exclude type hint stub files from formatting.
41+
exclude = ["*.pyi"]
42+
43+
# Like Black, use double quotes for strings.
44+
quote-style = "double"
45+
46+
# Like Black, indent with spaces, rather than tabs.
47+
indent-style = "space"
48+
49+
# Like Black, respect magic trailing commas.
50+
skip-magic-trailing-comma = false
51+
52+
docstring-code-format = true
53+
docstring-code-line-length = "dynamic"

‎changelog.d/pr447.internal.rst

Copy file name to clipboard
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Modernize project configs with :file:`pyproject.toml`
2+
3+
* In :file:`pyproject.toml`:
4+
* Move all project related data from :file:`setup.cfg` to :file:`pyproject.toml`
5+
* Use new dependency group from :pep:`735`
6+
* Consolidate flake8, isort, pycodestyle with ruff
7+
* Split towncrier config type "trivial" into "trivial" and
8+
"internal"
9+
* Create config file for ruff (:file:`.ruff.toml`)
10+
* Create config file for pytest (:file:`.pytest.ini`)
11+
* Simplify :file:`tox.ini` and remove old stuff
12+
* Document installation with new :command:`uv` command
13+
* Simplify Sphinx config with :func:`find_version()`
14+
* Update the authors
15+
* Use :command:`uv` in GitHub Action :file:`python-testing.yml` workflow

‎docs/Makefile

Copy file name to clipboardExpand all lines: docs/Makefile
+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ SPHINXPROJ = semver
88
SOURCEDIR = .
99
BUILDDIR = _build
1010

11+
# Set the source directory for your project
12+
SRC_DIR = ../src
13+
14+
# Set the PYTHONPATH environment variable
15+
export PYTHONPATH := $(SRC_DIR):$(PYTHONPATH)
16+
1117
# Put it first so that "make" without argument is like "make help".
1218
help:
1319
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

‎docs/conf.py

Copy file name to clipboardExpand all lines: docs/conf.py
+16-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# python-semver documentation build configuration file
54
#
@@ -16,37 +15,31 @@
1615
# add these directories to sys.path here. If the directory is relative to the
1716
# documentation root, use os.path.abspath to make it absolute, like shown here.
1817
#
19-
import codecs
20-
from datetime import date
18+
2119
import os
2220
import re
23-
import sys
21+
from datetime import date
22+
from pathlib import Path
2423

25-
SRC_DIR = os.path.abspath("../src/")
26-
sys.path.insert(0, SRC_DIR)
27-
# from semver import __version__ # noqa: E402
24+
SRC_DIR = Path(__file__).absolute().parent.parent / "src"
2825
YEAR = date.today().year
2926

3027

31-
def read(*parts):
32-
"""
33-
Build an absolute path from *parts* and and return the contents of the
34-
resulting file. Assume UTF-8 encoding.
35-
"""
36-
here = os.path.abspath(os.path.dirname(__file__))
37-
with codecs.open(os.path.join(here, *parts), "rb", "utf-8") as f:
38-
return f.read()
39-
40-
41-
def find_version(*file_paths):
28+
def find_version(path: Path) -> str:
4229
"""
4330
Build a path from *file_paths* and search for a ``__version__``
4431
string inside.
4532
"""
46-
version_file = read(*file_paths)
47-
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
33+
content = Path(path).read_text(encoding="utf-8")
34+
35+
version_match = re.search(
36+
r"^__version__ = ['\"]([^'\"]*)['\"]",
37+
content,
38+
re.MULTILINE
39+
)
4840
if version_match:
4941
return version_match.group(1)
42+
5043
raise RuntimeError("Unable to find version string.")
5144

5245

@@ -86,14 +79,14 @@ def find_version(*file_paths):
8679
# General information about the project.
8780
project = "python-semver"
8881
copyright = f"{YEAR}, Kostiantyn Rybnikov and all"
89-
author = "Kostiantyn Rybnikov and all"
82+
author = "Kostiantyn Rybnikov, Tom Schraitle, Sebastien Celles, and others"
9083

9184
# The version info for the project you're documenting, acts as replacement for
9285
# |version| and |release|, also used in various other places throughout the
9386
# built documents.
9487
#
9588
# The short X.Y version.
96-
release = find_version("../src/semver/__about__.py")
89+
release = find_version(SRC_DIR / "semver/__about__.py")
9790
# The full version, including alpha/beta/rc tags.
9891
version = release # .rsplit(u".", 1)[0]
9992

@@ -174,7 +167,7 @@ def find_version(*file_paths):
174167
"github_button": True,
175168
#:
176169
"github_type": "star",
177-
#: whether to apply a Fork me on Github banner
170+
#: whether to apply a "Fork me on Github" banner
178171
#: in the top right corner of the page:
179172
# "github_banner": True,
180173
#

‎docs/install.rst

Copy file name to clipboardExpand all lines: docs/install.rst
+19-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ For users who have to stay with major 2 releases only, use the following line::
2525
semver>=2,<3
2626

2727

28-
Pip
29-
---
28+
With Pip
29+
--------
3030

3131
.. code-block:: bash
32+
:name: install-pip
3233
3334
pip3 install semver
3435
@@ -40,6 +41,19 @@ with an URL and its version:
4041
pip3 install git+https://github.com/python-semver/python-semver.git@3.0.0
4142
4243
44+
With uv
45+
-------
46+
47+
First, install the :command:`uv` command. Refer to https://docs.astral.sh/uv/getting-started/installation/ for more information.
48+
49+
Then use the command :command:`uv` to install the package:
50+
51+
.. code-block:: bash
52+
:name: install-uv
53+
54+
uv pip install semver
55+
56+
4357
Linux Distributions
4458
-------------------
4559

@@ -101,7 +115,9 @@ openSUSE
101115

102116
1. Enable the ``devel:languages:python`` repository of the Open Build Service::
103117

104-
$ sudo zypper addrepo --refresh obs://devel:languages:python devel_languages_python
118+
$ sudo zypper addrepo --refresh \
119+
--name devel_languages_python \
120+
"https://download.opensuse.org/repositories/devel:/languages:/python/\$releasever"
105121

106122
2. Install the package::
107123

‎docs/usage/semver-version.rst

Copy file name to clipboardExpand all lines: docs/usage/semver-version.rst
+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Getting the Version of semver
44
To know the version of semver itself, use the following construct::
55

66
>>> semver.__version__
7-
'3.0.2'
7+
'3.0.3-alpha.1'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.