Skip to content

Commit 76317e4

Browse files
committed
Move from legacy setup.py to pyproject.toml with flit
This change simplifies the build logic on the new packaging metadata format provided with `pyproject.toml` using the flit build backend. The setuptools build backend wasn't featureful enough to be usable. This still doesn't fix the fact that installing `deepdiff` results in a broken `deep` CLI command, but it at least pushes the ball towards a world where that will be possible, someday. Signed-off-by: Enji Cooper <[email protected]>
1 parent 0d55a11 commit 76317e4

11 files changed

+154
-127
lines changed

setup.cfg renamed to .bumpversion.cfg

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@ commit = True
44
tag = True
55
tag_name = {new_version}
66

7-
[flake8]
8-
max-line-length = 120
9-
builtins = json
10-
statistics = true
11-
ignore = E202
12-
exclude = ./data,./src,.svn,CVS,.bzr,.hg,.git,__pycache__
13-
14-
[bumpversion:file:setup.py]
7+
[bumpversion:file:pyproject.toml]
158

169
[bumpversion:file:README.md]
1710

.github/workflows/main.yaml

+4-18
Original file line numberDiff line numberDiff line change
@@ -27,50 +27,36 @@ jobs:
2727
with:
2828
# This path is specific to Ubuntu
2929
path: ~/.cache/pip
30-
# Look to see if there is a cache hit for the corresponding requirements file
31-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev3.8.txt') }}
3230
restore-keys: |
33-
${{ runner.os }}-pip-
3431
${{ runner.os }}-
3532
- name: Cache pip
3633
if: matrix.python-version != 3.8
3734
env:
3835
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
3936
uses: actions/cache@v4
4037
with:
41-
# This path is specific to Ubuntu
42-
path: ~/.cache/pip
43-
# Look to see if there is a cache hit for the corresponding requirements file
44-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
4538
restore-keys: |
46-
${{ runner.os }}-pip-
4739
${{ runner.os }}-
4840
- name: Upgrade setuptools
4941
if: matrix.python-version >= 3.12
5042
run: |
5143
# workaround for 3.12, SEE: https://github.com/pypa/setuptools/issues/3661#issuecomment-1813845177
5244
pip install --upgrade setuptools
53-
- name: Install dependencies
54-
if: matrix.python-version > 3.9
55-
run: pip install -r requirements-dev.txt
56-
- name: Install dependencies
57-
if: matrix.python-version <= 3.9
58-
run: pip install -r requirements-dev3.8.txt
5945
- name: Lint with flake8
6046
if: matrix.python-version == 3.12
6147
run: |
6248
# stop the build if there are Python syntax errors or undefined names
63-
flake8 deepdiff --count --select=E9,F63,F7,F82 --show-source --statistics
49+
tox -e flake8 -- deepdiff --count --select=E9,F63,F7,F82 --show-source --statistics
6450
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
65-
flake8 deepdiff --count --exit-zero --max-complexity=26 --max-line-lengt=250 --statistics
51+
tox -e flake8 -- deepdiff --count --exit-zero --max-complexity=26 --max-line-lengt=250 --statistics
6652
- name: Test with pytest and get the coverage
6753
if: matrix.python-version == 3.12
6854
run: |
69-
pytest --benchmark-disable --cov-report=xml --cov=deepdiff tests/ --runslow
55+
tox -s -- --benchmark-disable --cov-report=xml --cov=deepdiff tests/ --runslow
7056
- name: Test with pytest and no coverage report
7157
if: matrix.python-version != 3.12
7258
run: |
73-
pytest --benchmark-disable
59+
tox -s -- --benchmark-disable tests/
7460
- name: Upload coverage to Codecov
7561
uses: codecov/codecov-action@v4
7662
if: matrix.python-version == 3.12

pyproject.toml

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
[build-system]
2+
requires = ["flit_core >=3.11,<4"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "deepdiff"
7+
version = "8.4.2"
8+
dependencies = [
9+
"orderly-set>=5.3.0,<6",
10+
]
11+
requires-python = ">=3.8"
12+
authors = [
13+
{ name = "Seperman", email = "[email protected]" }
14+
]
15+
maintainers = [
16+
{ name = "Seperman", email = "[email protected]" }
17+
]
18+
description = "Deep Difference and Search of any Python object/data. Recreate objects by adding adding deltas to each other."
19+
readme = "README.md"
20+
license = {file = "LICENSE"}
21+
keywords = []
22+
classifiers = [
23+
"Intended Audience :: Developers",
24+
"Operating System :: OS Independent",
25+
"Topic :: Software Development",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Python :: Implementation :: PyPy",
33+
"Development Status :: 5 - Production/Stable",
34+
"License :: OSI Approved :: MIT License"
35+
]
36+
37+
# `dependency-groups` would make this a lot cleaner, in theory.
38+
[project.optional-dependencies]
39+
coverage = [
40+
"coverage~=7.6.0"
41+
]
42+
cli = [
43+
"click~=8.1.0",
44+
"pyyaml~=6.0.0"
45+
]
46+
dev = [
47+
"bump2version~=1.0.0",
48+
"jsonpickle~=4.0.0",
49+
"ipdb~=0.13.0",
50+
"numpy~=2.2.0; python_version >= '3.10'",
51+
"numpy~=2.0; python_version < '3.10'",
52+
"python-dateutil~=2.9.0",
53+
"orjson~=3.10.0",
54+
"tomli~=2.2.0",
55+
"tomli-w~=1.2.0",
56+
"pandas~=2.2.0",
57+
"polars~=1.21.0",
58+
]
59+
docs = [
60+
# We use the html style that is not supported in Sphinx 7 anymore.
61+
"Sphinx~=6.2.0",
62+
"sphinx-sitemap~=2.6.0",
63+
"sphinxemoji~=0.3.0"
64+
]
65+
static = [
66+
"flake8~=7.1.0",
67+
"flake8-pyproject~=1.2.3",
68+
"pydantic~=2.10.0",
69+
"types-setuptools~=75.8.0; python_version > '3.8'",
70+
]
71+
test = [
72+
"pytest~=8.3.0",
73+
"pytest-benchmark~=5.1.0",
74+
"pytest-cov~=6.0.0",
75+
"python-dotenv~=1.0.0",
76+
]
77+
78+
[project.scripts]
79+
deep = "deepdiff.commands:cli"
80+
81+
[project.urls]
82+
Homepage = "https://zepworks.com/deepdiff/"
83+
Documentation = "https://zepworks.com/deepdiff/"
84+
Repository = "https://github.com/seperman/deepdiff"
85+
Issues = "https://github.com/seperman/deepdiff/issues"
86+
87+
[tool.coverage.run]
88+
branch = true
89+
source = ["."]
90+
91+
[tool.flake8]
92+
max-line-length = 120
93+
builtins = "json"
94+
statistics = true
95+
ignore = "E202"
96+
exclude = "./data,./src,.svn,CVS,.bzr,.hg,.git,__pycache__"
97+
98+
[tool.pytest.ini_options]
99+
addopts = "--pdbcls=IPython.terminal.debugger:Pdb"
100+
101+
[tool.setuptools]
102+
packages = ["deepdiff"]
103+
104+
[tool.setuptools.package-metadata]
105+
deepdiff = ["py.typed"]
106+
107+
[tool.tox]
108+
legacy_tox_ini = """
109+
[tox]
110+
min_version = 4.0
111+
env_list =
112+
flake8
113+
# XXX: this needs work.
114+
#mypy
115+
py38
116+
py39
117+
py310
118+
py311
119+
py312
120+
py313
121+
122+
[testenv]
123+
deps =
124+
.[cli]
125+
.[coverage]
126+
.[dev]
127+
.[static]
128+
.[test]
129+
commands =
130+
python -m pytest --cov=deepdiff --cov-report term-missing {posargs:-vv tests}
131+
132+
[testenv:flake8]
133+
deps =
134+
.[cli]
135+
.[dev]
136+
.[static]
137+
commands =
138+
python -m flake8 {posargs:deepdiff}
139+
140+
[testenv:mypy]
141+
deps =
142+
.[cli]
143+
.[dev]
144+
.[static]
145+
.[test]
146+
mypy
147+
commands =
148+
python -m mypy --install-types --non-interactive {posargs:deepdiff}
149+
"""

pytest.ini

-2
This file was deleted.

requirements-cli.txt

-2
This file was deleted.

requirements-dev.txt

-22
This file was deleted.

requirements-docs.txt

-3
This file was deleted.

requirements-optimize.txt

-1
This file was deleted.

requirements.txt

-1
This file was deleted.

run_tests.sh

-1
This file was deleted.

setup.py

-69
This file was deleted.

0 commit comments

Comments
 (0)