Skip to content

Commit ea63564

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 8811a42 commit ea63564

11 files changed

+152
-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

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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.9"
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.9",
27+
"Programming Language :: Python :: 3.10",
28+
"Programming Language :: Python :: 3.11",
29+
"Programming Language :: Python :: 3.12",
30+
"Programming Language :: Python :: 3.13",
31+
"Programming Language :: Python :: Implementation :: PyPy",
32+
"Development Status :: 5 - Production/Stable",
33+
"License :: OSI Approved :: MIT License"
34+
]
35+
36+
# `dependency-groups` would make this a lot cleaner, in theory.
37+
[project.optional-dependencies]
38+
coverage = [
39+
"coverage~=7.6.0"
40+
]
41+
cli = [
42+
"click~=8.1.0",
43+
"pyyaml~=6.0.0"
44+
]
45+
dev = [
46+
"bump2version~=1.0.0",
47+
"jsonpickle~=4.0.0",
48+
"ipdb~=0.13.0",
49+
"numpy~=2.2.0; python_version >= '3.10'",
50+
"numpy~=2.0; python_version < '3.10'",
51+
"python-dateutil~=2.9.0",
52+
"orjson~=3.10.0",
53+
"tomli~=2.2.0",
54+
"tomli-w~=1.2.0",
55+
"pandas~=2.2.0",
56+
"polars~=1.21.0",
57+
]
58+
docs = [
59+
# We use the html style that is not supported in Sphinx 7 anymore.
60+
"Sphinx~=6.2.0",
61+
"sphinx-sitemap~=2.6.0",
62+
"sphinxemoji~=0.3.0"
63+
]
64+
static = [
65+
"flake8~=7.1.0",
66+
"flake8-pyproject~=1.2.3",
67+
"pydantic~=2.10.0",
68+
"types-setuptools~=75.8.0",
69+
]
70+
test = [
71+
"pytest~=8.3.0",
72+
"pytest-benchmark~=5.1.0",
73+
"pytest-cov~=6.0.0",
74+
"python-dotenv~=1.0.0",
75+
]
76+
77+
[project.scripts]
78+
deep = "deepdiff.commands:cli"
79+
80+
[project.urls]
81+
Homepage = "https://zepworks.com/deepdiff/"
82+
Documentation = "https://zepworks.com/deepdiff/"
83+
Repository = "https://github.com/seperman/deepdiff"
84+
Issues = "https://github.com/seperman/deepdiff/issues"
85+
86+
[tool.coverage.run]
87+
branch = true
88+
source = ["."]
89+
90+
[tool.flake8]
91+
max-line-length = 120
92+
builtins = "json"
93+
statistics = true
94+
ignore = "E202"
95+
exclude = "./data,./src,.svn,CVS,.bzr,.hg,.git,__pycache__"
96+
97+
[tool.pytest.ini_options]
98+
addopts = "--pdbcls=IPython.terminal.debugger:Pdb"
99+
100+
[tool.setuptools]
101+
packages = ["deepdiff"]
102+
103+
[tool.setuptools.package-metadata]
104+
deepdiff = ["py.typed"]
105+
106+
[tool.tox]
107+
legacy_tox_ini = """
108+
[tox]
109+
min_version = 4.0
110+
env_list =
111+
flake8
112+
# XXX: this needs work.
113+
#mypy
114+
py39
115+
py310
116+
py311
117+
py312
118+
py313
119+
120+
[testenv]
121+
deps =
122+
.[cli]
123+
.[coverage]
124+
.[dev]
125+
.[static]
126+
.[test]
127+
commands =
128+
python -m pytest --cov=deepdiff --cov-report term-missing {posargs:-vv tests}
129+
130+
[testenv:flake8]
131+
deps =
132+
.[cli]
133+
.[dev]
134+
.[static]
135+
commands =
136+
python -m flake8 {posargs:deepdiff}
137+
138+
[testenv:mypy]
139+
deps =
140+
.[cli]
141+
.[dev]
142+
.[static]
143+
.[test]
144+
mypy
145+
commands =
146+
python -m mypy --install-types --non-interactive {posargs:deepdiff}
147+
"""

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)