setuputils3 2.0.3__tar.gz → 2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {setuputils3-2.0.3 → setuputils3-2.2}/PKG-INFO +35 -11
- {setuputils3-2.0.3 → setuputils3-2.2}/README.md +34 -7
- {setuputils3-2.0.3 → setuputils3-2.2}/pyproject.toml +2 -1
- {setuputils3-2.0.3 → setuputils3-2.2}/setup.cfg +2 -1
- {setuputils3-2.0.3 → setuputils3-2.2}/setuputils.py +17 -47
- setuputils3-2.2/setuputils_build.py +40 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: setuputils3
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2
|
|
4
4
|
Summary: A utility module to automate building setup configuration files.
|
|
5
5
|
Home-page: http://pypi.org/project/setuputils3
|
|
6
6
|
Author: Peter A. Donis
|
|
7
7
|
Author-email: peterdonis@alum.mit.edu
|
|
8
8
|
License: PSF
|
|
9
|
-
Platform: UNKNOWN
|
|
10
9
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
10
|
Classifier: Environment :: Console
|
|
12
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -46,7 +45,10 @@ Using setuputils in this mode is simple: for each section of
|
|
|
46
45
|
in the root of your source tree in files with an ``.in`` extension,
|
|
47
46
|
one for each section that will end up in ``setup.cfg``. For example,
|
|
48
47
|
you would put metadata in the file ``metadata.in``, options in the
|
|
49
|
-
file ``options.in``, etc.
|
|
48
|
+
file ``options.in``, etc. For subsections, just use the subsection
|
|
49
|
+
name as it would appear in ``setup.cfg`` as the base file name, so,
|
|
50
|
+
for example, entry points would appear in ``options.entry_points.in``.
|
|
51
|
+
Do not include anything in the ``.in`` files that you want
|
|
50
52
|
``setuputils`` to auto-discover, so, for example, if you want
|
|
51
53
|
``setuputils`` to auto-discover your packages, you would not include
|
|
52
54
|
"packages" in your ``options.in`` file at all (whereas with
|
|
@@ -62,28 +64,50 @@ file for you. You can then look at it to make sure it is correct
|
|
|
62
64
|
before using a build backend to build your distribution.
|
|
63
65
|
|
|
64
66
|
With this mode, if you are using a PEP 517 compliant build backend, you
|
|
65
|
-
do not need a ``setup.py`` script at all.
|
|
67
|
+
do not need a ``setup.py`` script at all. You can use ``setuptools`` as
|
|
66
68
|
such a backend as long as you include a ``pyproject.toml file`` and specify
|
|
67
|
-
``setuptools`` in it, as described in the Python packaging documentation.
|
|
69
|
+
``setuptools`` in it, as described in the Python packaging documentation.
|
|
68
70
|
If you do have a ``setup.py`` script, all it would need to contain is
|
|
69
71
|
an import of ``setuptools`` and call to ``setuptools.setup()`` with no
|
|
70
72
|
arguments (since all of the information needed is in ``setup.cfg``).
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
You can also use ``setuputils`` itself as a PEP 517 compliant build
|
|
75
|
+
backend. In this mode, you can still run ``setuputils`` as described above
|
|
76
|
+
before doing your build to make sure ``setup.cfg`` is correct. But using
|
|
77
|
+
``setuputils`` as your build backend ensures that ``setup.cfg`` will be
|
|
78
|
+
rebuilt on every build to ensure consistency with the current state of
|
|
79
|
+
your source tree. To use ``setuputils`` as your build backend, your
|
|
80
|
+
``pyproject.toml`` should look like this:
|
|
81
|
+
|
|
82
|
+
[build-system]
|
|
83
|
+
requires = ["setuputils3 >= 2.1", "setuptools >= 40.8.0", "wheel"]
|
|
84
|
+
build-backend = "setuputils_build"
|
|
85
|
+
|
|
86
|
+
You still need to include ``setuptools`` and ``wheel`` as build
|
|
87
|
+
requirements, since ``setuputils`` depends on them; the ``setuputils``
|
|
88
|
+
build backend is just a thin wrapper around ``setuptools.build_meta``
|
|
89
|
+
that ensures that ``setup.cfg`` is built and up to date before the
|
|
90
|
+
``setuptools`` build runs.
|
|
91
|
+
|
|
92
|
+
Note that if you have a ``setup.py`` script that was used with previous
|
|
93
|
+
versions of ``setuputils``, you do not have to transition it to the
|
|
74
94
|
new format using ``.in`` files all at once. ``Setuputils`` will read any
|
|
75
95
|
global variables that are defined in your ``setup.py``, as you would have
|
|
76
|
-
done in previous ``setuputils versions
|
|
96
|
+
done in previous ``setuputils`` versions, and include them in what it
|
|
77
97
|
outputs to ``setup.cfg`` after processing them just as it would have in
|
|
78
98
|
previous versions, so you can transition things incrementally if that works
|
|
79
99
|
better for your project. (However, you should remove any calls to
|
|
80
100
|
``setup_vars`` in your ``setup.py`` script, leaving only the call to
|
|
81
101
|
``setuptools.setup()`` with no arguments, since all the information
|
|
82
|
-
it needs will be in ``setup.cfg``.)
|
|
102
|
+
it needs will be in ``setup.cfg``.) Note that if you have a ``setup.py``
|
|
103
|
+
script, you cannot use ``setuputils`` as a build backend; you can only
|
|
104
|
+
use it to generate ``setup.cfg`` before doing a build. Also note that if
|
|
105
|
+
you are using ``setuputils`` in this "legacy" mode, you will have to
|
|
106
|
+
include it in your source distributions (instead of just listing it as a
|
|
107
|
+
requirement in ``pyprojects.toml``), since "legacy" mode builds have no
|
|
108
|
+
way of specifying build requirements other than setuptools itself.
|
|
83
109
|
|
|
84
110
|
See the module docstrings for more information.
|
|
85
111
|
|
|
86
112
|
SETUPUTILS3 is Copyright (C) 2012-2022 by Peter A. Donis.
|
|
87
113
|
Released under the Python Software Foundation License.
|
|
88
|
-
|
|
89
|
-
|
|
@@ -25,7 +25,10 @@ Using setuputils in this mode is simple: for each section of
|
|
|
25
25
|
in the root of your source tree in files with an ``.in`` extension,
|
|
26
26
|
one for each section that will end up in ``setup.cfg``. For example,
|
|
27
27
|
you would put metadata in the file ``metadata.in``, options in the
|
|
28
|
-
file ``options.in``, etc.
|
|
28
|
+
file ``options.in``, etc. For subsections, just use the subsection
|
|
29
|
+
name as it would appear in ``setup.cfg`` as the base file name, so,
|
|
30
|
+
for example, entry points would appear in ``options.entry_points.in``.
|
|
31
|
+
Do not include anything in the ``.in`` files that you want
|
|
29
32
|
``setuputils`` to auto-discover, so, for example, if you want
|
|
30
33
|
``setuputils`` to auto-discover your packages, you would not include
|
|
31
34
|
"packages" in your ``options.in`` file at all (whereas with
|
|
@@ -41,24 +44,48 @@ file for you. You can then look at it to make sure it is correct
|
|
|
41
44
|
before using a build backend to build your distribution.
|
|
42
45
|
|
|
43
46
|
With this mode, if you are using a PEP 517 compliant build backend, you
|
|
44
|
-
do not need a ``setup.py`` script at all.
|
|
47
|
+
do not need a ``setup.py`` script at all. You can use ``setuptools`` as
|
|
45
48
|
such a backend as long as you include a ``pyproject.toml file`` and specify
|
|
46
|
-
``setuptools`` in it, as described in the Python packaging documentation.
|
|
49
|
+
``setuptools`` in it, as described in the Python packaging documentation.
|
|
47
50
|
If you do have a ``setup.py`` script, all it would need to contain is
|
|
48
51
|
an import of ``setuptools`` and call to ``setuptools.setup()`` with no
|
|
49
52
|
arguments (since all of the information needed is in ``setup.cfg``).
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
You can also use ``setuputils`` itself as a PEP 517 compliant build
|
|
55
|
+
backend. In this mode, you can still run ``setuputils`` as described above
|
|
56
|
+
before doing your build to make sure ``setup.cfg`` is correct. But using
|
|
57
|
+
``setuputils`` as your build backend ensures that ``setup.cfg`` will be
|
|
58
|
+
rebuilt on every build to ensure consistency with the current state of
|
|
59
|
+
your source tree. To use ``setuputils`` as your build backend, your
|
|
60
|
+
``pyproject.toml`` should look like this:
|
|
61
|
+
|
|
62
|
+
[build-system]
|
|
63
|
+
requires = ["setuputils3 >= 2.1", "setuptools >= 40.8.0", "wheel"]
|
|
64
|
+
build-backend = "setuputils_build"
|
|
65
|
+
|
|
66
|
+
You still need to include ``setuptools`` and ``wheel`` as build
|
|
67
|
+
requirements, since ``setuputils`` depends on them; the ``setuputils``
|
|
68
|
+
build backend is just a thin wrapper around ``setuptools.build_meta``
|
|
69
|
+
that ensures that ``setup.cfg`` is built and up to date before the
|
|
70
|
+
``setuptools`` build runs.
|
|
71
|
+
|
|
72
|
+
Note that if you have a ``setup.py`` script that was used with previous
|
|
73
|
+
versions of ``setuputils``, you do not have to transition it to the
|
|
53
74
|
new format using ``.in`` files all at once. ``Setuputils`` will read any
|
|
54
75
|
global variables that are defined in your ``setup.py``, as you would have
|
|
55
|
-
done in previous ``setuputils versions
|
|
76
|
+
done in previous ``setuputils`` versions, and include them in what it
|
|
56
77
|
outputs to ``setup.cfg`` after processing them just as it would have in
|
|
57
78
|
previous versions, so you can transition things incrementally if that works
|
|
58
79
|
better for your project. (However, you should remove any calls to
|
|
59
80
|
``setup_vars`` in your ``setup.py`` script, leaving only the call to
|
|
60
81
|
``setuptools.setup()`` with no arguments, since all the information
|
|
61
|
-
it needs will be in ``setup.cfg``.)
|
|
82
|
+
it needs will be in ``setup.cfg``.) Note that if you have a ``setup.py``
|
|
83
|
+
script, you cannot use ``setuputils`` as a build backend; you can only
|
|
84
|
+
use it to generate ``setup.cfg`` before doing a build. Also note that if
|
|
85
|
+
you are using ``setuputils`` in this "legacy" mode, you will have to
|
|
86
|
+
include it in your source distributions (instead of just listing it as a
|
|
87
|
+
requirement in ``pyprojects.toml``), since "legacy" mode builds have no
|
|
88
|
+
way of specifying build requirements other than setuptools itself.
|
|
62
89
|
|
|
63
90
|
See the module docstrings for more information.
|
|
64
91
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = setuputils3
|
|
3
|
-
version = 2.
|
|
3
|
+
version = 2.2
|
|
4
4
|
description = A utility module to automate building setup configuration files.
|
|
5
5
|
long_description = file: README.md
|
|
6
6
|
long_description_content_type = text/markdown
|
|
@@ -23,6 +23,7 @@ classifiers =
|
|
|
23
23
|
[options]
|
|
24
24
|
py_modules =
|
|
25
25
|
setuputils
|
|
26
|
+
setuputils_build
|
|
26
27
|
|
|
27
28
|
[egg_info]
|
|
28
29
|
egg_base = /tmp
|
|
@@ -22,49 +22,15 @@ have no way of getting an advance look at what the tool thinks should go
|
|
|
22
22
|
into your distribution; you only see what's in the distribution after it
|
|
23
23
|
is built.
|
|
24
24
|
|
|
25
|
-
Using setuputils in this mode is
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(Note that, in addition to the standard setuptools keywords, there are
|
|
36
|
-
a few extra keywords that are used by setuputils itself, either to allow
|
|
37
|
-
simpler inputs that then get expanded into standard format, as with the
|
|
38
|
-
"dev_status" keyword, or to allow you to pass options to setuputils to
|
|
39
|
-
control its behavior, as with the "autodiscover" keyword. These keywords
|
|
40
|
-
are described further in the appropriate function docstrings below.)
|
|
41
|
-
|
|
42
|
-
Once you have created your .in files, then you simply execute
|
|
43
|
-
|
|
44
|
-
python3 -m setuputils
|
|
45
|
-
|
|
46
|
-
in the root of your source tree. This will build the setup.cfg file for
|
|
47
|
-
you. You can then look at it to make sure it is correct before using a
|
|
48
|
-
build backend to build your distribution.
|
|
49
|
-
|
|
50
|
-
With this mode, if you are using a PEP 517 compliant build backend, you
|
|
51
|
-
do not need a setup.py script at all. (Setuptools qualifies as such a
|
|
52
|
-
backend as long as you include a pyproject.toml file and specify
|
|
53
|
-
setuptools in it, as described in the Python packaging documentation.)
|
|
54
|
-
If you do have a setup.py script, all it would need to contain is
|
|
55
|
-
an import of ``setuptools`` and call to ``setuptools.setup()`` with no
|
|
56
|
-
arguments (since all of the information needed is in setup.cfg). Note,
|
|
57
|
-
however, that if you have a setup.py script that was used with previous
|
|
58
|
-
versions of setuputils, you do not have to transition it to the new
|
|
59
|
-
format using .in files all at once. Setuputils will read any global
|
|
60
|
-
variables that are defined in your setup.py, as you would have done in
|
|
61
|
-
previous setuputils versions, and include them in what it outputs to
|
|
62
|
-
setup.cfg after processing them just as it would have in previous
|
|
63
|
-
versions, so you can transition things incrementally if that works
|
|
64
|
-
better for your project. (However, you should remove any calls to
|
|
65
|
-
setup_vars in your setup.py script, leaving only the call to
|
|
66
|
-
``setuptools.setup()`` with no arguments, since all the information
|
|
67
|
-
it needs will be in setup.cfg.)
|
|
25
|
+
Using setuputils in this mode is described in the README file that comes
|
|
26
|
+
with the setuputils distribution. This mode supports both being run as
|
|
27
|
+
a stand-alone tool to build setup.cfg prior to doing an sdist or wheel
|
|
28
|
+
build, and being run as a PEP 517 build backend that builds setup.cfg
|
|
29
|
+
before each build to ensure consistency with the current state of your
|
|
30
|
+
source tree. This mode also supports reading global variables from a
|
|
31
|
+
setup.py script if that is present (see further comments below); but if
|
|
32
|
+
setup.py is present, setuputils cannot be used as a build backend, it
|
|
33
|
+
can only be used to generate setup.cfg prior to doing a build.
|
|
68
34
|
|
|
69
35
|
(Note that extension modules are currently not supported in setup.cfg,
|
|
70
36
|
so you cannot use setuputils in setup.cfg mode if your distribution
|
|
@@ -998,7 +964,7 @@ def strtobool(value):
|
|
|
998
964
|
|
|
999
965
|
|
|
1000
966
|
def read_in_lines(lines,
|
|
1001
|
-
sep="=",
|
|
967
|
+
sep=" = ", endsep=" =", listsep=","):
|
|
1002
968
|
|
|
1003
969
|
in_vars = {}
|
|
1004
970
|
open_key = None
|
|
@@ -1015,9 +981,9 @@ def read_in_lines(lines,
|
|
|
1015
981
|
line = line.strip()
|
|
1016
982
|
if not line:
|
|
1017
983
|
continue
|
|
1018
|
-
if (not dangling) and (sep in line)
|
|
984
|
+
if (not dangling) and ((sep in line) or line.endswith(endsep)):
|
|
1019
985
|
close_open_key()
|
|
1020
|
-
key, value = (s.strip() for s in line.split(sep))
|
|
986
|
+
key, value = (s.strip() for s in line.split(endsep if line.endswith(endsep) else sep))
|
|
1021
987
|
if value:
|
|
1022
988
|
key_type = supported_keywords.get(key, type(value))
|
|
1023
989
|
if key_type in (list, dict):
|
|
@@ -1043,10 +1009,14 @@ def read_in_lines(lines,
|
|
|
1043
1009
|
return in_vars
|
|
1044
1010
|
|
|
1045
1011
|
|
|
1012
|
+
def in_filename(section):
|
|
1013
|
+
return "{}.in".format(section)
|
|
1014
|
+
|
|
1015
|
+
|
|
1046
1016
|
def read_in_files():
|
|
1047
1017
|
varmap = {}
|
|
1048
1018
|
for section, _ in setup_cfg_sections:
|
|
1049
|
-
filename =
|
|
1019
|
+
filename = in_filename(section)
|
|
1050
1020
|
if os.path.isfile(filename):
|
|
1051
1021
|
with open(filename, 'r') as f:
|
|
1052
1022
|
lines = f.readlines()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Module SETUPUTILS_BUILD -- PEP 517 backend for setuputils
|
|
4
|
+
Copyright (C) 2012-2022 by Peter A. Donis
|
|
5
|
+
|
|
6
|
+
Released under the Python Software Foundation License.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Builder(object):
|
|
13
|
+
|
|
14
|
+
setuptools_fns = (
|
|
15
|
+
'get_requires_for_build_wheel',
|
|
16
|
+
'get_requires_for_build_sdist',
|
|
17
|
+
'prepare_metadata_for_build_wheel',
|
|
18
|
+
'build_sdist',
|
|
19
|
+
'build_wheel',
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
self.ensure_setup_cfg()
|
|
24
|
+
import setuptools.build_meta
|
|
25
|
+
for fname in self.setuptools_fns:
|
|
26
|
+
setattr(self, fname, getattr(setuptools.build_meta, fname))
|
|
27
|
+
|
|
28
|
+
def ensure_setup_cfg(self):
|
|
29
|
+
import setuputils
|
|
30
|
+
if any(os.path.isfile(setuputils.in_filename(section)) for section, _ in setuputils.setup_cfg_sections):
|
|
31
|
+
setuputils.write_setup_cfg()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
_builder = Builder()
|
|
35
|
+
|
|
36
|
+
get_requires_for_build_wheel = _builder.get_requires_for_build_wheel
|
|
37
|
+
get_requires_for_build_sdist = _builder.get_requires_for_build_sdist
|
|
38
|
+
prepare_metadata_for_build_wheel = _builder.prepare_metadata_for_build_wheel
|
|
39
|
+
build_wheel = _builder.build_wheel
|
|
40
|
+
build_sdist = _builder.build_sdist
|