Skip to content

Commit

Permalink
Moved the metadata into setup.cfg.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KOLANICH committed Jan 2, 2022
1 parent 714df3c commit 98155d3
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
*.pyc
/jsonpatch/version.py
*.py[co]
build
.coverage
dist
Expand Down
4 changes: 3 additions & 1 deletion jsonpatch.py → jsonpatch/__init__.py
Expand Up @@ -66,7 +66,9 @@
str = unicode

# Will be parsed by setup.py to determine package metadata
__author__ = 'Stefan Kögl <stefan@skoegl.net>'
__author__ = 'Stefan Kögl'
__email__ = 'stefan@skoegl.net'
__author__ += ' <' + __email__ + '>'
__version__ = '1.32'
__website__ = 'https://github.com/stefankoegl/python-json-patch'
__license__ = 'Modified BSD License'
Expand Down
Empty file added jsonpatch/cli/__init__.py
Empty file.
7 changes: 4 additions & 3 deletions bin/jsondiff → jsonpatch/cli/jsondiff.py
Expand Up @@ -5,17 +5,18 @@

import sys
import json
import jsonpatch
import argparse

from .. import __version__, make_patch


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


def main():
Expand All @@ -30,7 +31,7 @@ def diff_files():
args = parser.parse_args()
doc1 = json.load(args.FILE1)
doc2 = json.load(args.FILE2)
patch = jsonpatch.make_patch(doc1, doc2)
patch = make_patch(doc1, doc2)
if patch.patch:
print(json.dumps(patch.patch, indent=args.indent))
sys.exit(1)
Expand Down
7 changes: 4 additions & 3 deletions bin/jsonpatch → jsonpatch/cli/jsonpatch.py
Expand Up @@ -4,10 +4,11 @@
import sys
import os.path
import json
import jsonpatch
import tempfile
import argparse

from .. import __version__, apply_patch


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

Expand All @@ -39,7 +40,7 @@ def patch_files():
args = parser.parse_args()
doc = json.load(args.ORIGINAL)
patch = json.load(args.PATCH)
result = jsonpatch.apply_patch(doc, patch)
result = apply_patch(doc, patch)

if args.in_place:
dirname = os.path.abspath(os.path.dirname(args.ORIGINAL.name))
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
@@ -0,0 +1,13 @@
[build-system]
requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3", "read_version[toml] >= 0.3.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "jsonpatch/version.py"
write_to_template = "__version__ = '{version}'\n"

[tool.read_version]
author = "jsonpatch.__init__:__author__"
author_email = "jsonpatch.__init__:__email__"
url = "jsonpatch.__init__:__website__"
license = "jsonpatch.__init__:__license__"
42 changes: 42 additions & 0 deletions setup.cfg
@@ -1,2 +1,44 @@
[metadata]
name = jsonpatch
description = Apply JSON-Patches (RFC 6902)
long_description = file: README.md
long_description_content_type = text/markdown
classifiers =
Development Status :: 5 - Production/Stable
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Software Development :: Libraries
Topic :: Utilities
project_urls =
Website = https://github.com/stefankoegl/python-json-patch
Repository = https://github.com/stefankoegl/python-json-patch.git
Documentation = https://python-json-patch.readthedocs.org/
PyPI = https://pypi.org/pypi/jsonpatch
Tests = https://travis-ci.org/stefankoegl/python-json-patch
Test Coverage = https://coveralls.io/r/stefankoegl/python-json-patch

[options]
packages = jsonpatch, jsonpatch.cli
install_requires = jsonpointer>=1.9
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*

[options.entry_points]
console_scripts =
jsondiff = jsonpatch.cli.jsondiff:main
jsonpatch = jsonpatch.cli.jsonpatch:main

[bdist_wheel]
universal = 1
93 changes: 0 additions & 93 deletions setup.py

This file was deleted.

0 comments on commit 98155d3

Please sign in to comment.