@@ -13,9 +13,63 @@ It also handles file finders for the supported SCMs.
13
13
.. image :: https://tidelift.com/badges/github/pypa/setuptools_scm
14
14
:target: https://tidelift.com/subscription/pkg/pypi-setuptools_scm?utm_source=pypi-setuptools_scm&utm_medium=readme
15
15
16
+ ``pyproject.toml `` usage
17
+ ------------------------
18
+
19
+ The preferred way to configure ``setuptools_scm `` is to author
20
+ settings in a ``tool.setuptools_scm `` section of ``pyproject.toml ``.
21
+
22
+ This feature requires Setuptools 42 or later, released in Nov, 2019.
23
+ If your project needs to support build from sdist on older versions
24
+ of Setuptools, you will need to also implement the ``setup.py usage ``
25
+ for those legacy environments.
26
+
27
+ First, ensure that ``setuptools_scm `` is present during the project's
28
+ built step by specifying it as one of the build requirements.
29
+
30
+ .. code :: ini
31
+
32
+ # pyproject.toml
33
+ [build-system]
34
+ requires = [" setuptools>=42" , " wheel" , " setuptools_scm[toml]>=3.4" ]
35
+
36
+ Note that the ``toml `` extra must be supplied.
37
+
38
+ That will be sufficient to require ``setuptools_scm `` for projects
39
+ that support PEP 518 (`pip <https://pypi.org/project/pip >`_ and
40
+ `pep517 <https://pypi.org/project/pep517/ >`_). Many tools,
41
+ especially those that invoke ``setup.py `` for any reason, may
42
+ continue to rely on ``setup_requires ``. For maximum compatibility
43
+ with those uses, consider also including a ``setup_requires `` directive
44
+ (described below in ``setup.py usage `` and ``setup.cfg ``).
45
+
46
+ To enable version inference, add this section to your pyproject.toml:
47
+
48
+ .. code :: ini
49
+
50
+ # pyproject.toml
51
+ [tools.setuptools_scm]
52
+
53
+ Including this section is comparable to supplying
54
+ ``use_scm_version=True `` in ``setup.py ``. Additionally,
55
+ include arbitrary keyword arguments in that section
56
+ to be supplied to ``get_version() ``. For example::
57
+
58
+ .. code :: ini
59
+
60
+ # pyproject.toml
61
+ [tools.setuptools_scm]
62
+ write_to = pkg/version.py
63
+
64
+
16
65
``setup.py `` usage
17
66
------------------
18
67
68
+ The following settings are considered legacy behavior and
69
+ superseded by the ``pyproject.toml `` usage, but for maximal
70
+ compatibility, projects may also supply the configuration in
71
+ this older form.
72
+
19
73
To use ``setuptools_scm `` just modify your project's ``setup.py `` file
20
74
like this:
21
75
0 commit comments