Skip to content

Commit 98155d3

Browse files
committed
Moved the metadata into setup.cfg.
Added `pyproject.toml`. Version is now fetched and populated automatically from git tags using setuptools_scm. Metadata stored in source files is fetched using `read_version`. Got rid of raw scripts, using `console_scripts` entry point since now.
1 parent 714df3c commit 98155d3

File tree

8 files changed

+68
-101
lines changed

8 files changed

+68
-101
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
*.pyc
1+
/jsonpatch/version.py
2+
*.py[co]
23
build
34
.coverage
45
dist

jsonpatch.py renamed to jsonpatch/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
str = unicode
6767

6868
# Will be parsed by setup.py to determine package metadata
69-
__author__ = 'Stefan Kögl <stefan@skoegl.net>'
69+
__author__ = 'Stefan Kögl'
70+
__email__ = 'stefan@skoegl.net'
71+
__author__ += ' <' + __email__ + '>'
7072
__version__ = '1.32'
7173
__website__ = 'https://github.com/stefankoegl/python-json-patch'
7274
__license__ = 'Modified BSD License'

jsonpatch/cli/__init__.py

Whitespace-only changes.

bin/jsondiff renamed to jsonpatch/cli/jsondiff.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55

66
import sys
77
import json
8-
import jsonpatch
98
import argparse
109

10+
from .. import __version__, make_patch
11+
1112

1213
parser = argparse.ArgumentParser(description='Diff two JSON files')
1314
parser.add_argument('FILE1', type=argparse.FileType('r'))
1415
parser.add_argument('FILE2', type=argparse.FileType('r'))
1516
parser.add_argument('--indent', type=int, default=None,
1617
help='Indent output by n spaces')
1718
parser.add_argument('-v', '--version', action='version',
18-
version='%(prog)s ' + jsonpatch.__version__)
19+
version='%(prog)s ' + __version__)
1920

2021

2122
def main():
@@ -30,7 +31,7 @@ def diff_files():
3031
args = parser.parse_args()
3132
doc1 = json.load(args.FILE1)
3233
doc2 = json.load(args.FILE2)
33-
patch = jsonpatch.make_patch(doc1, doc2)
34+
patch = make_patch(doc1, doc2)
3435
if patch.patch:
3536
print(json.dumps(patch.patch, indent=args.indent))
3637
sys.exit(1)

bin/jsonpatch renamed to jsonpatch/cli/jsonpatch.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import sys
55
import os.path
66
import json
7-
import jsonpatch
87
import tempfile
98
import argparse
109

10+
from .. import __version__, apply_patch
11+
1112

1213
parser = argparse.ArgumentParser(
1314
description='Apply a JSON patch on a JSON file')
@@ -23,7 +24,7 @@
2324
parser.add_argument('-i', '--in-place', action='store_true',
2425
help='Modify ORIGINAL in-place instead of to stdout')
2526
parser.add_argument('-v', '--version', action='version',
26-
version='%(prog)s ' + jsonpatch.__version__)
27+
version='%(prog)s ' + __version__)
2728
parser.add_argument('-u', '--preserve-unicode', action='store_true',
2829
help='Output Unicode character as-is without using Code Point')
2930

@@ -39,7 +40,7 @@ def patch_files():
3940
args = parser.parse_args()
4041
doc = json.load(args.ORIGINAL)
4142
patch = json.load(args.PATCH)
42-
result = jsonpatch.apply_patch(doc, patch)
43+
result = apply_patch(doc, patch)
4344

4445
if args.in_place:
4546
dirname = os.path.abspath(os.path.dirname(args.ORIGINAL.name))

pyproject.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[build-system]
2+
requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3", "read_version[toml] >= 0.3.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
write_to = "jsonpatch/version.py"
7+
write_to_template = "__version__ = '{version}'\n"
8+
9+
[tool.read_version]
10+
author = "jsonpatch.__init__:__author__"
11+
author_email = "jsonpatch.__init__:__email__"
12+
url = "jsonpatch.__init__:__website__"
13+
license = "jsonpatch.__init__:__license__"

setup.cfg

+42
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
1+
[metadata]
2+
name = jsonpatch
3+
description = Apply JSON-Patches (RFC 6902)
4+
long_description = file: README.md
5+
long_description_content_type = text/markdown
6+
classifiers =
7+
Development Status :: 5 - Production/Stable
8+
Environment :: Console
9+
Intended Audience :: Developers
10+
License :: OSI Approved :: BSD License
11+
Operating System :: OS Independent
12+
Programming Language :: Python
13+
Programming Language :: Python :: 2
14+
Programming Language :: Python :: 2.7
15+
Programming Language :: Python :: 3
16+
Programming Language :: Python :: 3.5
17+
Programming Language :: Python :: 3.6
18+
Programming Language :: Python :: 3.7
19+
Programming Language :: Python :: 3.8
20+
Programming Language :: Python :: 3.9
21+
Programming Language :: Python :: Implementation :: CPython
22+
Programming Language :: Python :: Implementation :: PyPy
23+
Topic :: Software Development :: Libraries
24+
Topic :: Utilities
25+
project_urls =
26+
Website = https://github.com/stefankoegl/python-json-patch
27+
Repository = https://github.com/stefankoegl/python-json-patch.git
28+
Documentation = https://python-json-patch.readthedocs.org/
29+
PyPI = https://pypi.org/pypi/jsonpatch
30+
Tests = https://travis-ci.org/stefankoegl/python-json-patch
31+
Test Coverage = https://coveralls.io/r/stefankoegl/python-json-patch
32+
33+
[options]
34+
packages = jsonpatch, jsonpatch.cli
35+
install_requires = jsonpointer>=1.9
36+
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
37+
38+
[options.entry_points]
39+
console_scripts =
40+
jsondiff = jsonpatch.cli.jsondiff:main
41+
jsonpatch = jsonpatch.cli.jsonpatch:main
42+
143
[bdist_wheel]
244
universal = 1

setup.py

-93
This file was deleted.

0 commit comments

Comments
 (0)