Skip to content

Commit

Permalink
Use setuptools-scm to manage version
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Jan 17, 2022
1 parent 95e745f commit 6d88a13
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
/build/
/dist/
/.eggs/
/yq/version.py

# IDE project files
/.pydevproject
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
test_deps:
pip install .[tests]

version: yq/version.py
yq/version.py: setup.py
echo "__version__ = '$$(python setup.py --version)'" > $@

lint: test_deps
flake8 $$(python setup.py --name)

Expand All @@ -14,7 +10,7 @@ test: test_deps lint
docs:
sphinx-build docs docs/html

install: clean version
install: clean
pip install build
python -m build
pip install --upgrade dist/*.whl
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
description="Command-line YAML/XML processor - jq wrapper for YAML/XML documents",
long_description=open("README.rst").read(),
python_requires=">=3.6",
use_scm_version={
"write_to": "yq/version.py",
},
setup_requires=['setuptools_scm >= 3.4.3'],
install_requires=[
"PyYAML >= 5.3.1",
"xmltodict >= 0.11.0",
Expand Down
6 changes: 5 additions & 1 deletion yq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
from .parser import get_parser, jq_arg_spec
from .loader import get_loader
from .dumper import get_dumper
from .version import __version__ # noqa

try:
from .version import version as __version__
except ImportError:
__version__ = "0.0.0"

class JSONDateTimeEncoder(json.JSONEncoder):
def default(self, o):
Expand Down
5 changes: 4 additions & 1 deletion yq/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import sys, argparse, subprocess

from .version import __version__
try:
from .version import version as __version__
except ImportError:
__version__ = "0.0.0"

# jq arguments that consume positionals must be listed here to avoid our parser mistaking them for our positionals
jq_arg_spec = {"--indent": 1, "-f": 1, "--from-file": 1, "-L": 1, "--arg": 2, "--argjson": 2, "--slurpfile": 2,
Expand Down
1 change: 0 additions & 1 deletion yq/version.py

This file was deleted.

0 comments on commit 6d88a13

Please sign in to comment.