Skip to content

Commit ccb6ef7

Browse files
committed
- Switched from setup.cfg to pyproject.toml for configuration.
- Removed build_sphinx from setup.py and documented how to build.
1 parent 269108d commit ccb6ef7

File tree

10 files changed

+235
-211
lines changed

10 files changed

+235
-211
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ serialize =
88
{major}.{minor}.{patch}{release}
99
{major}.{minor}.{patch}
1010

11-
[bumpversion:file:setup.cfg]
12-
search = version = {current_version}
13-
replace = version = {new_version}
14-
1511
[bumpversion:file:jsonargparse/__init__.py]
1612

1713
[bumpversion:file:.sonarcloud.properties]

.circleci/config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ jobs:
88
- checkout
99
- run:
1010
name: Build wheel package
11-
command: ./setup.py bdist_wheel sdist
11+
command: |
12+
pip3 install -U setuptools
13+
./setup.py bdist_wheel sdist
1214
- persist_to_workspace:
1315
root: .
1416
paths:
@@ -26,7 +28,7 @@ jobs:
2628
py=$(python3 --version | sed -r 's|.* 3\.([0-9]+)\..*|3.\1|')
2729
virtualenv -p python3 venv$py
2830
. venv$py/bin/activate
29-
pip3 install $(ls ./dist/*.whl)[test_no_urls]
31+
pip3 install $(ls ./dist/*.whl)[test-no-urls]
3032
python3 -m jsonargparse_tests coverage xml coverage_py$py.xml
3133
pip3 install $(ls ./dist/*.whl)[test,all]
3234
python3 -m jsonargparse_tests coverage xml coverage_py${py}_all.xml

.github/workflows/code-checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
with:
1515
python-version: 3.8
1616
cache: pip
17-
cache-dependency-path: "**/setup.cfg"
17+
cache-dependency-path: "**/pyproject.toml"
1818
- run: pip install -e .[test,mypy]
1919
- run: mypy jsonargparse*/*.py
2020
pylint:
@@ -25,6 +25,6 @@ jobs:
2525
with:
2626
python-version: 3.8
2727
cache: pip
28-
cache-dependency-path: "**/setup.cfg"
28+
cache-dependency-path: "**/pyproject.toml"
2929
- run: pip install -e .[all,test,pylint]
30-
- run: pylint --rcfile=setup.cfg jsonargparse*/*.py
30+
- run: pylint jsonargparse*/*.py

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ repos:
9393

9494
- id: pycodestyle
9595
name: pycodestyle
96-
entry: pycodestyle
96+
entry: pycodestyle --exclude=sphinx/conf.py,setup.py --ignore=E241,E265,E128,E266,E226,E722,E252,E231,W291,E303,E221,E402,E306,E704,E251,E301,W504,E302 --max-line-length=180
9797
language: system
9898
types: [python]
9999
verbose: true
100100

101101
- id: pylint
102-
name: pylint --rcfile=setup.cfg
103-
entry: pylint --rcfile=setup.cfg
102+
name: pylint
103+
entry: pylint
104104
language: system
105105
types: [python]
106106
verbose: true

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ The semantic versioning only considers the public API as described in
1212
paths are considered internals and can change in minor and patch releases.
1313

1414

15+
v4.21.0 (2023-04-??)
16+
--------------------
17+
18+
Changed
19+
^^^^^^^
20+
- Switched from ``setup.cfg`` to ``pyproject.toml`` for configuration.
21+
- Removed ``build_sphinx`` from ``setup.py`` and documented how to build.
22+
23+
1524
v4.20.1 (2023-03-30)
1625
--------------------
1726

CONTRIBUTING.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ proposing enhancements, or more directly by creating `pull requests
77
<https://github.com/omni-us/jsonargparse/pulls>`_.
88

99
If you intend to work with the source code, note that this project does not
10-
include any :code:`requirements.txt` file. This is by intention. To make it very
10+
include any ``requirements.txt`` file. This is by intention. To make it very
1111
clear what are the requirements for different use cases, all the requirements of
12-
the project are stored in the file :code:`setup.cfg`. The basic runtime
13-
requirements are defined in section :code:`[options]` in the
14-
:code:`install_requires` entry. All extras requires for optional features listed
15-
in :ref:`installation` are stored in section :code:`[options.extras_require]`.
16-
Also there are :code:`test`, :code:`test_no_urls`, :code:`dev` and :code:`doc`
17-
entries in the same :code:`[options.extras_require]` section which lists
18-
requirements for testing, development and documentation building.
12+
the project are stored in the file ``pyproject.toml``. The basic runtime
13+
requirements are defined in ``dependencies``. Requirements for optional features
14+
stored in ``[project.optional-dependencies]``. Also in the same section there
15+
are requirements for testing, development and documentation building: ``test``,
16+
``test-no-urls``, ``dev`` and ``doc``.
1917

2018
The recommended way to work with the source code is the following. First clone
2119
the repository, then create a virtual environment, activate it and finally
@@ -42,9 +40,17 @@ is done as follows:
4240
4341
pre-commit install
4442
43+
To build the documentation run:
44+
45+
.. code-block:: bash
46+
47+
sphinx-build sphinx sphinx/_build sphinx/index.rst
48+
49+
Then to see it, open the file ``sphinx/_build/index.html`` in a browser.
50+
4551
Running the unit tests can be done either using using `tox
46-
<https://tox.readthedocs.io/en/stable/>`__ or the :code:`setup.py` script. The
47-
unit tests are also installed with the package, thus can be run in a production
52+
<https://tox.readthedocs.io/en/stable/>`__ or the ``setup.py`` script. The unit
53+
tests are also installed with the package, thus can be run in a production
4854
system.
4955

5056
.. code-block:: bash

README.rst

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ via :ref:`sub-commands` similar to the single class example above, i.e.
209209
function to execute. If multiple classes or a mixture of functions and classes
210210
is given to :func:`.CLI`, to execute a method of a class, two levels of
211211
:ref:`sub-commands` are required. The first sub-command would be the name of the
212-
class and the second the name of the method, i.e. :code:`example.py class
213-
[init_arguments] method [arguments]`.
212+
class and the second the name of the method, i.e. ``example.py class
213+
[init_arguments] method [arguments]``.
214214

215215
.. note::
216216

@@ -673,8 +673,8 @@ Furthermore unexperienced users might mistakenly use ``type=bool`` which would
673673
not provide the intended behavior.
674674

675675
With jsonargparse adding an argument with ``type=bool`` the intended action is
676-
implemented. If given as values ``{'yes', 'true'}`` or :code:`{'no', 'false'}`
677-
the corresponding parsed values would be ``True`` or ``False``. For example:
676+
implemented. If given as values ``{'yes', 'true'}`` or ``{'no', 'false'}`` the
677+
corresponding parsed values would be ``True`` or ``False``. For example:
678678

679679
.. testsetup:: boolean
680680

@@ -704,8 +704,8 @@ straightforward. A couple of examples would be:
704704
parser.add_argument('--with-op2', action=ActionYesNo(yes_prefix='with-', no_prefix='without-'))
705705

706706
If the :class:`.ActionYesNo` class is used in conjunction with ``nargs='?'`` the
707-
options can also be set by giving as value any of :code:`{'true', 'yes',
708-
'false', 'no'}`.
707+
options can also be set by giving as value any of ``{'true', 'yes', 'false',
708+
'no'}``.
709709

710710

711711
.. _enums:
@@ -978,8 +978,7 @@ is how complex numbers are registered: ``register_type(complex)``. For other
978978
type classes that don't have these properties, to register it might be necessary
979979
to provide a serializer and/or deserializer function. Including the serializer
980980
and deserializer functions, the registration of the complex numbers example is
981-
equivalent to :code:`register_type(complex, serializer=str,
982-
deserializer=complex)`.
981+
equivalent to ``register_type(complex, serializer=str, deserializer=complex)``.
983982

984983
A more useful example could be registering the ``datetime`` class. This case
985984
requires to give both a serializer and a deserializer as seen below.
@@ -1071,12 +1070,11 @@ the expected structure in the config files.
10711070
The :py:attr:`.ArgumentParser.default_config_files` property can be set when
10721071
creating a parser to specify patterns to search for configuration files. For
10731072
example if a parser is created as
1074-
:code:`ArgumentParser(default_config_files=['~/.myapp.yaml',
1075-
'/etc/myapp.yaml'])`, when parsing if any of those two config files exist it
1076-
will be parsed and used to override the defaults. All matched config files are
1077-
parsed and applied in the given order. The default config files are always
1078-
parsed first, this means that any command line argument will override its
1079-
values.
1073+
``ArgumentParser(default_config_files=['~/.myapp.yaml', '/etc/myapp.yaml'])``,
1074+
when parsing if any of those two config files exist it will be parsed and used
1075+
to override the defaults. All matched config files are parsed and applied in the
1076+
given order. The default config files are always parsed first, this means that
1077+
any command line argument will override its values.
10801078

10811079
It is also possible to add an argument to explicitly provide a configuration
10821080
file path. Providing a config file as an argument does not disable the parsing
@@ -2367,7 +2365,7 @@ disabled. To enable, the ``logger`` argument should be set when creating an
23672365
existing logger object which is used for the whole application. For convenience,
23682366
to enable a default logger the ``logger`` argument can also receive ``True`` or
23692367
a string which sets the name of the logger or a dictionary that can include the
2370-
name and the level, e.g. :code:`{"name": "myapp", "level": "ERROR"}`. If
2368+
name and the level, e.g. ``{"name": "myapp", "level": "ERROR"}``. If
23712369
`reconplogger <https://pypi.org/project/reconplogger/>`__ is installed, setting
23722370
``logger`` to ``True`` or a dictionary without specifying a name, then the
23732371
reconplogger is used. If reconplogger is installed and the

pyproject.toml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
[build-system]
2+
requires = ["setuptools>=65.6.3", "wheel>=0.38.4"]
3+
4+
[project]
5+
name = "jsonargparse"
6+
dynamic = ["version", "readme"]
7+
description = "Implement minimal boilerplate CLIs derived from type hints and parse from command line, config files and environment variables."
8+
authors = [
9+
{name = "Mauricio Villegas", email = "mauricio@omnius.com"},
10+
]
11+
license = {file = "LICENSE.rst"}
12+
requires-python = ">=3.6"
13+
14+
classifiers = [
15+
"Development Status :: 5 - Production/Stable",
16+
"Programming Language :: Python",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3 :: Only",
19+
"Programming Language :: Python :: 3.6",
20+
"Programming Language :: Python :: 3.7",
21+
"Programming Language :: Python :: 3.8",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Intended Audience :: Developers",
26+
"License :: OSI Approved :: MIT License",
27+
"Operating System :: POSIX :: Linux",
28+
"Operating System :: MacOS",
29+
"Operating System :: Microsoft :: Windows",
30+
]
31+
32+
dependencies = [
33+
"PyYAML>=3.13",
34+
"contextvars>=2.4; python_version == '3.6'",
35+
"dataclasses>=0.8; python_version == '3.6'",
36+
]
37+
38+
[project.optional-dependencies]
39+
all = [
40+
"jsonargparse[signatures]",
41+
"jsonargparse[jsonschema]",
42+
"jsonargparse[jsonnet]",
43+
"jsonargparse[urls]",
44+
"jsonargparse[fsspec]",
45+
"jsonargparse[argcomplete]",
46+
"jsonargparse[ruyaml]",
47+
"jsonargparse[omegaconf]",
48+
"jsonargparse[typing-extensions]",
49+
"jsonargparse[reconplogger]",
50+
]
51+
signatures = [
52+
"docstring-parser>=0.15",
53+
"typeshed-client>=2.1.0",
54+
]
55+
jsonschema = [
56+
"jsonschema>=3.2.0",
57+
]
58+
jsonnet = [
59+
"jsonnet>=0.13.0; os_name == 'posix'",
60+
"jsonnet-binary>=0.17.0; os_name != 'posix'",
61+
]
62+
urls = [
63+
"requests>=2.18.4",
64+
]
65+
fsspec = [
66+
"fsspec>=0.8.4",
67+
]
68+
argcomplete = [
69+
"argcomplete>=2.0.0",
70+
]
71+
ruyaml = [
72+
"ruyaml>=0.20.0",
73+
]
74+
omegaconf = [
75+
"omegaconf>=2.1.1",
76+
]
77+
typing-extensions = [
78+
"typing-extensions>=3.10.0.0; python_version < '3.8'",
79+
]
80+
reconplogger = [
81+
"reconplogger>=4.4.0",
82+
]
83+
test = [
84+
"jsonargparse[test-no-urls]",
85+
"jsonargparse[types-pyyaml]",
86+
"responses>=0.12.0",
87+
"types-requests>=2.28.9",
88+
]
89+
test-no-urls = [
90+
"coverage>=4.5.1",
91+
]
92+
dev = [
93+
"jsonargparse[test]",
94+
"jsonargparse[doc]",
95+
"jsonargparse[pylint]",
96+
"jsonargparse[mypy]",
97+
"pre-commit>=2.19.0",
98+
"tox>=3.25.0",
99+
"pycodestyle>=2.5.0",
100+
]
101+
pylint = [
102+
"pylint>=2.15.6",
103+
]
104+
mypy = [
105+
"jsonargparse[types-pyyaml]",
106+
"mypy>=0.701",
107+
]
108+
types-pyyaml = [
109+
"types-PyYAML>=6.0.11",
110+
]
111+
doc = [
112+
"Sphinx>=1.7.9",
113+
"sphinx-rtd-theme>=0.4.3",
114+
"autodocsumm>=0.1.10",
115+
"sphinx-autodoc-typehints>=1.19.5",
116+
]
117+
maintainer = [
118+
"bump2version>=0.5.11",
119+
]
120+
121+
[project.urls]
122+
Documentation-stable = "https://jsonargparse.readthedocs.io/en/stable/"
123+
Documentation-latest = "https://jsonargparse.readthedocs.io/en/latest/"
124+
Changes = "https://jsonargparse.readthedocs.io/en/stable/changelog.html"
125+
GitHub = "https://github.com/omni-us/jsonargparse"
126+
PyPI = "https://pypi.org/project/jsonargparse"
127+
CircleCI = "https://circleci.com/gh/omni-us/jsonargparse"
128+
SonarCloud = "https://sonarcloud.io/dashboard?id=omni-us_jsonargparse"
129+
Codecov = "https://codecov.io/gh/omni-us/jsonargparse"
130+
131+
[tool.setuptools]
132+
platforms = ["Any"]
133+
packages = ["jsonargparse", "jsonargparse_tests"]
134+
135+
136+
[tool.setuptools.dynamic]
137+
version = {attr = "jsonargparse.__version__"}
138+
139+
140+
[tool.setuptools.package-data]
141+
jsonargparse = [
142+
"*.pyi",
143+
"py.typed",
144+
]
145+
146+
147+
[tool.mypy]
148+
ignore_missing_imports = true
149+
allow_redefinition = true
150+
warn_unused_ignores = true
151+
152+
153+
[tool.pylint]
154+
disable = "no-member"
155+
errors-only = true
156+
157+
158+
[tool.isort]
159+
profile = "black"
160+
multi_line_output = 3
161+
162+
163+
[tool.tox]
164+
legacy_tox_ini = """
165+
[tox]
166+
envlist = py{37,38,39,310,311}-{all,no}-extras,pypy3,omegaconf
167+
skip_missing_interpreters = true
168+
169+
[testenv]
170+
extras =
171+
all-extras: test,all
172+
no-extras: test-no-urls
173+
changedir = jsonargparse_tests
174+
commands = python -m unittest
175+
usedevelop = true
176+
177+
[testenv:omegaconf]
178+
extras = test,all
179+
setenv =
180+
JSONARGPARSE_OMEGACONF_FULL_TEST = true
181+
"""

0 commit comments

Comments
 (0)