[-]
[+]
|
Changed |
python3-setuptools_scm.spec
|
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/CHANGELOG.rst
^
|
@@ -1,3 +1,36 @@
+v3.4.3
+======
+
+* fix #399: ensure the git file finder terminates subprocess after reading archive
+
+v3.4.2
+======
+
+* fix #395: correctly transfer tag regex in the Configuration constructor
+* rollback --first-parent for git describe as it turns out to be a regression for some users
+
+v3.4.1
+======
+
+* pull in #377 to fix #374: correctly set up the default version scheme for pyproject usage.
+ this bugfix got missed when ruushing the release.
+
+v3.4.0
+======
+
+* fix #181 - add support for projects built under setuptools declarative config
+ by way of the setuptools.finalize_distribution_options hook in Setuptools 42.
+
+* fix #305 - ensure the git file finder closes filedescriptors even when errors happen
+
+* fix #381 - clean out env vars from the git hook system to ensure correct function from within
+
+* modernize docs wrt importlib.metadata
+
+*edited*
+
+* use --first-parent for git describe
+
v3.3.3
======
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/MANIFEST.in
^
|
@@ -7,3 +7,5 @@
include tox.ini
include *.rst
include LICENSE
+include *.toml
+recursive-include testing *.bash
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/PKG-INFO
^
|
@@ -1,6 +1,6 @@
-Metadata-Version: 1.2
+Metadata-Version: 2.1
Name: setuptools_scm
-Version: 3.3.3
+Version: 3.4.3
Summary: the blessed package to manage your versions by scm tags
Home-page: https://github.com/pypa/setuptools_scm/
Author: Ronny Pfannschmidt
@@ -13,14 +13,75 @@
in SCM metadata instead of declaring them as the version argument
or in a SCM managed file.
- It also handles file finders for the supported SCMs.
+ Additionally ``setuptools_scm`` provides setuptools with a list of files that are managed by the SCM
+ (i.e. it automatically adds all of the SCM-managed files to the sdist).
+ Unwanted files must be excluded by discarding them via ``MANIFEST.in``.
.. image:: https://travis-ci.org/pypa/setuptools_scm.svg?branch=master
:target: https://travis-ci.org/pypa/setuptools_scm
+ .. image:: https://tidelift.com/badges/package/pypi/setuptools-scm
+ :target: https://tidelift.com/subscription/pkg/pypi-setuptools-scm?utm_source=pypi-setuptools-scm&utm_medium=readme
+
+
+ ``pyproject.toml`` usage
+ ------------------------
+
+ The preferred way to configure ``setuptools_scm`` is to author
+ settings in a ``tool.setuptools_scm`` section of ``pyproject.toml``.
+
+ This feature requires Setuptools 42 or later, released in Nov, 2019.
+ If your project needs to support build from sdist on older versions
+ of Setuptools, you will need to also implement the ``setup.py usage``
+ for those legacy environments.
+
+ First, ensure that ``setuptools_scm`` is present during the project's
+ built step by specifying it as one of the build requirements.
+
+ .. code:: toml
+
+ # pyproject.toml
+ [build-system]
+ requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
+
+ Note that the ``toml`` extra must be supplied.
+
+ That will be sufficient to require ``setuptools_scm`` for projects
+ that support PEP 518 (`pip <https://pypi.org/project/pip>`_ and
+ `pep517 <https://pypi.org/project/pep517/>`_). Many tools,
+ especially those that invoke ``setup.py`` for any reason, may
+ continue to rely on ``setup_requires``. For maximum compatibility
+ with those uses, consider also including a ``setup_requires`` directive
+ (described below in ``setup.py usage`` and ``setup.cfg``).
+
+ To enable version inference, add this section to your pyproject.toml:
+
+ .. code:: toml
+
+ # pyproject.toml
+ [tool.setuptools_scm]
+
+ Including this section is comparable to supplying
+ ``use_scm_version=True`` in ``setup.py``. Additionally,
+ include arbitrary keyword arguments in that section
+ to be supplied to ``get_version()``. For example:
+
+ .. code:: toml
+
+ # pyproject.toml
+
+ [tool.setuptools_scm]
+ write_to = "pkg/version.py"
+
+
``setup.py`` usage
------------------
+ The following settings are considered legacy behavior and
+ superseded by the ``pyproject.toml`` usage, but for maximal
+ compatibility, projects may also supply the configuration in
+ this older form.
+
To use ``setuptools_scm`` just modify your project's ``setup.py`` file
like this:
@@ -52,20 +113,7 @@
...,
)
- Once configured, you can access the version number in your package via
- ``pkg_resources`` (`PEP-0396 <https://www.python.org/dev/peps/pep-0396>`_). For
- example:
-
- .. code:: python
-
- from pkg_resources import get_distribution, DistributionNotFound
- try:
- __version__ = get_distribution(__name__).version
- except DistributionNotFound:
- # package is not installed
- pass
-
- You can also confirm the version number locally via ``setup.py``:
+ You can confirm the version number locally via ``setup.py``:
.. code-block:: shell
@@ -78,8 +126,8 @@
not defined in ``setup.cfg``.
- ``setup.cfg``
- -------------
+ ``setup.cfg`` usage
+ -------------------
If using `setuptools 30.3.0
<https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files>`_
@@ -138,6 +186,43 @@
See `setup.py Usage`_ above for how to use this within ``setup.py``.
+ Retrieving package version at runtime
+ -------------------------------------
+
+ If you have opted not to hardcode the version number inside the package,
+ you can retrieve it at runtime from PEP-0566_ metadata using
+ ``importlib.metadata`` from the standard library
+ or the `importlib_metadata`_ backport:
+
+ .. code:: python
+
+ from importlib.metadata import version, PackageNotFoundError
+
+ try:
+ __version__ = version(__name__)
+ except PackageNotFoundError:
+ # package is not installed
+ pass
+
+ Alternatively, you can use ``pkg_resources`` which is included in
+ ``setuptools``:
+
+ .. code:: python
+
+ from pkg_resources import get_distribution, DistributionNotFound
+
+ try:
+ __version__ = get_distribution(__name__).version
+ except DistributionNotFound:
+ # package is not installed
+ pass
+
+ This does place a runtime dependency on ``setuptools``.
+
+ .. _PEP-0566: https://www.python.org/dev/peps/pep-0566/
+ .. _importlib_metadata: https://pypi.org/project/importlib-metadata/
+
+
Usage from Sphinx
-----------------
@@ -182,9 +267,9 @@
distance and clean:
``{next_version}.dev{distance}+{scm letter}{revision hash}``
no distance and not clean:
- ``{tag}+dYYYMMMDD``
+ ``{tag}+dYYYYMMDD``
distance and not clean:
- ``{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD``
+ ``{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYYMMDD``
The next version is calculated by adding ``1`` to the last numeric component of
the tag.
@@ -220,6 +305,26 @@
Git archives are not supported due to Git shortcomings
+ File finders hook makes most of MANIFEST.in unnecessary
+ -------------------------------------------------------
+
+ ``setuptools_scm`` implements a `file_finders
+ <https://setuptools.readthedocs.io/en/latest/setuptools.html#adding-support-for-revision-control-systems>`_
+ entry point which returns all files tracked by your SCM. This eliminates
+ the need for a manually constructed ``MANIFEST.in`` in most cases where this
+ would be required when not using ``setuptools_scm``, namely:
+
+ * To ensure all relevant files are packaged when running the ``sdist`` command.
+
+ * When using `include_package_data <https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files>`_
+ to include package data as part of the ``build`` or ``bdist_wheel``.
+
+ ``MANIFEST.in`` may still be used: anything defined there overrides the hook.
+ This is mostly useful to exclude files tracked in your SCM from packages,
+ although in principle it can be used to explicitly include non-tracked files
+ too.
+
+
Configuration parameters
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/README.rst
^
|
@@ -5,14 +5,75 @@
in SCM metadata instead of declaring them as the version argument
or in a SCM managed file.
-It also handles file finders for the supported SCMs.
+Additionally ``setuptools_scm`` provides setuptools with a list of files that are managed by the SCM
+(i.e. it automatically adds all of the SCM-managed files to the sdist).
+Unwanted files must be excluded by discarding them via ``MANIFEST.in``.
.. image:: https://travis-ci.org/pypa/setuptools_scm.svg?branch=master
:target: https://travis-ci.org/pypa/setuptools_scm
+.. image:: https://tidelift.com/badges/package/pypi/setuptools-scm
+ :target: https://tidelift.com/subscription/pkg/pypi-setuptools-scm?utm_source=pypi-setuptools-scm&utm_medium=readme
+
+
+``pyproject.toml`` usage
+------------------------
+
+The preferred way to configure ``setuptools_scm`` is to author
+settings in a ``tool.setuptools_scm`` section of ``pyproject.toml``.
+
+This feature requires Setuptools 42 or later, released in Nov, 2019.
+If your project needs to support build from sdist on older versions
+of Setuptools, you will need to also implement the ``setup.py usage``
+for those legacy environments.
+
+First, ensure that ``setuptools_scm`` is present during the project's
+built step by specifying it as one of the build requirements.
+
+.. code:: toml
+
+ # pyproject.toml
+ [build-system]
+ requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
+
+Note that the ``toml`` extra must be supplied.
+
+That will be sufficient to require ``setuptools_scm`` for projects
+that support PEP 518 (`pip <https://pypi.org/project/pip>`_ and
+`pep517 <https://pypi.org/project/pep517/>`_). Many tools,
+especially those that invoke ``setup.py`` for any reason, may
+continue to rely on ``setup_requires``. For maximum compatibility
+with those uses, consider also including a ``setup_requires`` directive
+(described below in ``setup.py usage`` and ``setup.cfg``).
+
+To enable version inference, add this section to your pyproject.toml:
+
+.. code:: toml
+
+ # pyproject.toml
+ [tool.setuptools_scm]
+
+Including this section is comparable to supplying
+``use_scm_version=True`` in ``setup.py``. Additionally,
+include arbitrary keyword arguments in that section
+to be supplied to ``get_version()``. For example:
+
+.. code:: toml
+
+ # pyproject.toml
+
+ [tool.setuptools_scm]
+ write_to = "pkg/version.py"
+
+
``setup.py`` usage
------------------
+The following settings are considered legacy behavior and
+superseded by the ``pyproject.toml`` usage, but for maximal
+compatibility, projects may also supply the configuration in
+this older form.
+
To use ``setuptools_scm`` just modify your project's ``setup.py`` file
like this:
@@ -44,20 +105,7 @@
...,
)
-Once configured, you can access the version number in your package via
-``pkg_resources`` (`PEP-0396 <https://www.python.org/dev/peps/pep-0396>`_). For
-example:
-
-.. code:: python
-
- from pkg_resources import get_distribution, DistributionNotFound
- try:
- __version__ = get_distribution(__name__).version
- except DistributionNotFound:
- # package is not installed
- pass
-
-You can also confirm the version number locally via ``setup.py``:
+You can confirm the version number locally via ``setup.py``:
.. code-block:: shell
@@ -70,8 +118,8 @@
not defined in ``setup.cfg``.
-``setup.cfg``
--------------
+``setup.cfg`` usage
+-------------------
If using `setuptools 30.3.0
<https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files>`_
@@ -130,6 +178,43 @@
See `setup.py Usage`_ above for how to use this within ``setup.py``.
+Retrieving package version at runtime
+-------------------------------------
+
+If you have opted not to hardcode the version number inside the package,
+you can retrieve it at runtime from PEP-0566_ metadata using
+``importlib.metadata`` from the standard library
+or the `importlib_metadata`_ backport:
+
+.. code:: python
+
+ from importlib.metadata import version, PackageNotFoundError
+
+ try:
+ __version__ = version(__name__)
+ except PackageNotFoundError:
+ # package is not installed
+ pass
+
+Alternatively, you can use ``pkg_resources`` which is included in
+``setuptools``:
+
+.. code:: python
+
+ from pkg_resources import get_distribution, DistributionNotFound
+
+ try:
+ __version__ = get_distribution(__name__).version
+ except DistributionNotFound:
+ # package is not installed
+ pass
+
+This does place a runtime dependency on ``setuptools``.
+
+.. _PEP-0566: https://www.python.org/dev/peps/pep-0566/
+.. _importlib_metadata: https://pypi.org/project/importlib-metadata/
+
+
Usage from Sphinx
-----------------
@@ -174,9 +259,9 @@
distance and clean:
``{next_version}.dev{distance}+{scm letter}{revision hash}``
no distance and not clean:
- ``{tag}+dYYYMMMDD``
+ ``{tag}+dYYYYMMDD``
distance and not clean:
- ``{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD``
+ ``{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYYMMDD``
The next version is calculated by adding ``1`` to the last numeric component of
the tag.
@@ -212,6 +297,26 @@
Git archives are not supported due to Git shortcomings
+File finders hook makes most of MANIFEST.in unnecessary
+-------------------------------------------------------
+
+``setuptools_scm`` implements a `file_finders
+<https://setuptools.readthedocs.io/en/latest/setuptools.html#adding-support-for-revision-control-systems>`_
+entry point which returns all files tracked by your SCM. This eliminates
+the need for a manually constructed ``MANIFEST.in`` in most cases where this
+would be required when not using ``setuptools_scm``, namely:
+
+* To ensure all relevant files are packaged when running the ``sdist`` command.
+
+* When using `include_package_data <https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files>`_
+ to include package data as part of the ``build`` or ``bdist_wheel``.
+
+``MANIFEST.in`` may still be used: anything defined there overrides the hook.
+This is mostly useful to exclude files tracked in your SCM from packages,
+although in principle it can be used to explicitly include non-tracked files
+too.
+
+
Configuration parameters
------------------------
@@ -263,7 +368,7 @@
:fallback_version:
A version string that will be used if no other method for detecting the
- version worked (e.g., when using a tarball with no metadata). If this is
+ version worked (e.g., when using a tarball with no metadata). If this is
unset (the default), setuptools_scm will error if it fails to detect the
|
[-]
[+]
|
Added |
setuptools_scm-3.4.3.tar.gz/pyproject.toml
^
|
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools>=34.4", "wheel"]
+build-backend = "setuptools.build_meta"
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/setup.py
^
|
@@ -68,6 +68,9 @@
[setuptools.file_finders]
setuptools_scm = setuptools_scm.integration:find_files
+ [setuptools.finalize_distribution_options]
+ setuptools_scm = setuptools_scm.integration:infer_version
+
[setuptools_scm.parse_scm]
.hg = setuptools_scm.hg:parse
.git = setuptools_scm.git:parse
@@ -111,6 +114,7 @@
"Topic :: Utilities",
],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
+ extras_require=dict(toml=["toml"]),
)
if __name__ == "__main__":
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm.egg-info/PKG-INFO
^
|
@@ -1,6 +1,6 @@
-Metadata-Version: 1.2
+Metadata-Version: 2.1
Name: setuptools-scm
-Version: 3.3.3
+Version: 3.4.3
Summary: the blessed package to manage your versions by scm tags
Home-page: https://github.com/pypa/setuptools_scm/
Author: Ronny Pfannschmidt
@@ -13,14 +13,75 @@
in SCM metadata instead of declaring them as the version argument
or in a SCM managed file.
- It also handles file finders for the supported SCMs.
+ Additionally ``setuptools_scm`` provides setuptools with a list of files that are managed by the SCM
+ (i.e. it automatically adds all of the SCM-managed files to the sdist).
+ Unwanted files must be excluded by discarding them via ``MANIFEST.in``.
.. image:: https://travis-ci.org/pypa/setuptools_scm.svg?branch=master
:target: https://travis-ci.org/pypa/setuptools_scm
+ .. image:: https://tidelift.com/badges/package/pypi/setuptools-scm
+ :target: https://tidelift.com/subscription/pkg/pypi-setuptools-scm?utm_source=pypi-setuptools-scm&utm_medium=readme
+
+
+ ``pyproject.toml`` usage
+ ------------------------
+
+ The preferred way to configure ``setuptools_scm`` is to author
+ settings in a ``tool.setuptools_scm`` section of ``pyproject.toml``.
+
+ This feature requires Setuptools 42 or later, released in Nov, 2019.
+ If your project needs to support build from sdist on older versions
+ of Setuptools, you will need to also implement the ``setup.py usage``
+ for those legacy environments.
+
+ First, ensure that ``setuptools_scm`` is present during the project's
+ built step by specifying it as one of the build requirements.
+
+ .. code:: toml
+
+ # pyproject.toml
+ [build-system]
+ requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
+
+ Note that the ``toml`` extra must be supplied.
+
+ That will be sufficient to require ``setuptools_scm`` for projects
+ that support PEP 518 (`pip <https://pypi.org/project/pip>`_ and
+ `pep517 <https://pypi.org/project/pep517/>`_). Many tools,
+ especially those that invoke ``setup.py`` for any reason, may
+ continue to rely on ``setup_requires``. For maximum compatibility
+ with those uses, consider also including a ``setup_requires`` directive
+ (described below in ``setup.py usage`` and ``setup.cfg``).
+
+ To enable version inference, add this section to your pyproject.toml:
+
+ .. code:: toml
+
+ # pyproject.toml
+ [tool.setuptools_scm]
+
+ Including this section is comparable to supplying
+ ``use_scm_version=True`` in ``setup.py``. Additionally,
+ include arbitrary keyword arguments in that section
+ to be supplied to ``get_version()``. For example:
+
+ .. code:: toml
+
+ # pyproject.toml
+
+ [tool.setuptools_scm]
+ write_to = "pkg/version.py"
+
+
``setup.py`` usage
------------------
+ The following settings are considered legacy behavior and
+ superseded by the ``pyproject.toml`` usage, but for maximal
+ compatibility, projects may also supply the configuration in
+ this older form.
+
To use ``setuptools_scm`` just modify your project's ``setup.py`` file
like this:
@@ -52,20 +113,7 @@
...,
)
- Once configured, you can access the version number in your package via
- ``pkg_resources`` (`PEP-0396 <https://www.python.org/dev/peps/pep-0396>`_). For
- example:
-
- .. code:: python
-
- from pkg_resources import get_distribution, DistributionNotFound
- try:
- __version__ = get_distribution(__name__).version
- except DistributionNotFound:
- # package is not installed
- pass
-
- You can also confirm the version number locally via ``setup.py``:
+ You can confirm the version number locally via ``setup.py``:
.. code-block:: shell
@@ -78,8 +126,8 @@
not defined in ``setup.cfg``.
- ``setup.cfg``
- -------------
+ ``setup.cfg`` usage
+ -------------------
If using `setuptools 30.3.0
<https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files>`_
@@ -138,6 +186,43 @@
See `setup.py Usage`_ above for how to use this within ``setup.py``.
+ Retrieving package version at runtime
+ -------------------------------------
+
+ If you have opted not to hardcode the version number inside the package,
+ you can retrieve it at runtime from PEP-0566_ metadata using
+ ``importlib.metadata`` from the standard library
+ or the `importlib_metadata`_ backport:
+
+ .. code:: python
+
+ from importlib.metadata import version, PackageNotFoundError
+
+ try:
+ __version__ = version(__name__)
+ except PackageNotFoundError:
+ # package is not installed
+ pass
+
+ Alternatively, you can use ``pkg_resources`` which is included in
+ ``setuptools``:
+
+ .. code:: python
+
+ from pkg_resources import get_distribution, DistributionNotFound
+
+ try:
+ __version__ = get_distribution(__name__).version
+ except DistributionNotFound:
+ # package is not installed
+ pass
+
+ This does place a runtime dependency on ``setuptools``.
+
+ .. _PEP-0566: https://www.python.org/dev/peps/pep-0566/
+ .. _importlib_metadata: https://pypi.org/project/importlib-metadata/
+
+
Usage from Sphinx
-----------------
@@ -182,9 +267,9 @@
distance and clean:
``{next_version}.dev{distance}+{scm letter}{revision hash}``
no distance and not clean:
- ``{tag}+dYYYMMMDD``
+ ``{tag}+dYYYYMMDD``
distance and not clean:
- ``{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYMMMDD``
+ ``{next_version}.dev{distance}+{scm letter}{revision hash}.dYYYYMMDD``
The next version is calculated by adding ``1`` to the last numeric component of
the tag.
@@ -220,6 +305,26 @@
Git archives are not supported due to Git shortcomings
+ File finders hook makes most of MANIFEST.in unnecessary
+ -------------------------------------------------------
+
+ ``setuptools_scm`` implements a `file_finders
+ <https://setuptools.readthedocs.io/en/latest/setuptools.html#adding-support-for-revision-control-systems>`_
+ entry point which returns all files tracked by your SCM. This eliminates
+ the need for a manually constructed ``MANIFEST.in`` in most cases where this
+ would be required when not using ``setuptools_scm``, namely:
+
+ * To ensure all relevant files are packaged when running the ``sdist`` command.
+
+ * When using `include_package_data <https://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files>`_
+ to include package data as part of the ``build`` or ``bdist_wheel``.
+
+ ``MANIFEST.in`` may still be used: anything defined there overrides the hook.
+ This is mostly useful to exclude files tracked in your SCM from packages,
+ although in principle it can be used to explicitly include non-tracked files
+ too.
+
+
Configuration parameters
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm.egg-info/SOURCES.txt
^
|
@@ -2,6 +2,7 @@
LICENSE
MANIFEST.in
README.rst
+pyproject.toml
setup.cfg
setup.py
tox.ini
@@ -23,15 +24,18 @@
src/setuptools_scm.egg-info/SOURCES.txt
src/setuptools_scm.egg-info/dependency_links.txt
src/setuptools_scm.egg-info/entry_points.txt
+src/setuptools_scm.egg-info/requires.txt
src/setuptools_scm.egg-info/top_level.txt
src/setuptools_scm.egg-info/zip-safe
testing/conftest.py
+testing/play_out_381.bash
testing/runtests_travis.py
testing/test_basic_api.py
testing/test_config.py
testing/test_file_finder.py
testing/test_functions.py
testing/test_git.py
+testing/test_integration.py
testing/test_main.py
testing/test_mercurial.py
testing/test_regressions.py
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm.egg-info/entry_points.txt
^
|
@@ -5,6 +5,9 @@
[setuptools.file_finders]
setuptools_scm = setuptools_scm.integration:find_files
+ [setuptools.finalize_distribution_options]
+ setuptools_scm = setuptools_scm.integration:infer_version
+
[setuptools_scm.parse_scm]
.hg = setuptools_scm.hg:parse
.git = setuptools_scm.git:parse
|
[-]
[+]
|
Added |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm.egg-info/requires.txt
^
|
@@ -0,0 +1,3 @@
+
+[toml]
+toml
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/__init__.py
^
|
@@ -5,7 +5,12 @@
import os
import warnings
-from .config import Configuration
+from .config import (
+ Configuration,
+ DEFAULT_VERSION_SCHEME,
+ DEFAULT_LOCAL_SCHEME,
+ DEFAULT_TAG_REGEX,
+)
from .utils import function_has_arg, string_types
from .version import format_version, meta
from .discover import iter_matching_entrypoints
@@ -116,12 +121,12 @@
def get_version(
root=".",
- version_scheme="guess-next-dev",
- local_scheme="node-and-date",
+ version_scheme=DEFAULT_VERSION_SCHEME,
+ local_scheme=DEFAULT_LOCAL_SCHEME,
write_to=None,
write_to_template=None,
relative_to=None,
- tag_regex=None,
+ tag_regex=DEFAULT_TAG_REGEX,
fallback_version=None,
fallback_root=".",
parse=None,
@@ -134,30 +139,24 @@
root of the repository by supplying ``__file__``.
"""
- config = Configuration()
- config.root = root
- config.fallback_root = fallback_root
- config.version_scheme = version_scheme
- config.local_scheme = local_scheme
- config.write_to = write_to
- config.write_to_template = write_to_template
- config.relative_to = relative_to
- config.tag_regex = tag_regex
- config.fallback_version = fallback_version
- config.parse = parse
- config.git_describe_command = git_describe_command
+ config = Configuration(**locals())
+ return _get_version(config)
+
+def _get_version(config):
parsed_version = _do_parse(config)
if parsed_version:
version_string = format_version(
- parsed_version, version_scheme=version_scheme, local_scheme=local_scheme
+ parsed_version,
+ version_scheme=config.version_scheme,
+ local_scheme=config.local_scheme,
)
dump_version(
- root=root,
+ root=config.root,
version=version_string,
- write_to=write_to,
- template=write_to_template,
+ write_to=config.write_to,
+ template=config.write_to_template,
)
return version_string
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/config.py
^
|
@@ -7,7 +7,8 @@
from .utils import trace
DEFAULT_TAG_REGEX = r"^(?:[\w-]+-)?(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]+)(?:\+.*)?$"
-DEFAULT_VERSION_SCHEME = "version_scheme"
+DEFAULT_VERSION_SCHEME = "guess-next-dev"
+DEFAULT_LOCAL_SCHEME = "node-and-date"
def _check_tag_regex(value):
@@ -39,32 +40,34 @@
class Configuration(object):
""" Global configuration model """
- _root = None
- version_scheme = None
- local_scheme = None
- write_to = None
- write_to_template = None
- fallback_version = None
- _relative_to = None
- parse = None
- _tag_regex = None
- _absolute_root = None
-
- def __init__(self, relative_to=None, root="."):
+ def __init__(
+ self,
+ relative_to=None,
+ root=".",
+ version_scheme=DEFAULT_VERSION_SCHEME,
+ local_scheme=DEFAULT_LOCAL_SCHEME,
+ write_to=None,
+ write_to_template=None,
+ tag_regex=DEFAULT_TAG_REGEX,
+ fallback_version=None,
+ fallback_root=".",
+ parse=None,
+ git_describe_command=None,
+ ):
# TODO:
self._relative_to = relative_to
self._root = "."
self.root = root
- self.version_scheme = DEFAULT_VERSION_SCHEME
- self.local_scheme = "node-and-date"
- self.write_to = ""
- self.write_to_template = None
- self.fallback_version = None
- self.fallback_root = "."
- self.parse = None
- self.tag_regex = DEFAULT_TAG_REGEX
- self.git_describe_command = None
+ self.version_scheme = version_scheme
+ self.local_scheme = local_scheme
+ self.write_to = write_to
+ self.write_to_template = write_to_template
+ self.fallback_version = fallback_version
+ self.fallback_root = fallback_root
+ self.parse = parse
+ self.tag_regex = tag_regex
+ self.git_describe_command = git_describe_command
@property
def fallback_root(self):
@@ -105,3 +108,16 @@
@tag_regex.setter
def tag_regex(self, value):
self._tag_regex = _check_tag_regex(value)
+
+ @classmethod
+ def from_file(cls, name="pyproject.toml"):
+ """
+ Read Configuration from pyproject.toml (or similar).
+ Raises exceptions when file is not found or toml is
+ not installed or the file has invalid format or does
+ not contain the [tool.setuptools_scm] section.
+ """
+ with open(name) as strm:
+ defn = __import__("toml").load(strm)
+ section = defn.get("tool", {})["setuptools_scm"]
+ return cls(**section)
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/file_finder.py
^
|
@@ -31,10 +31,9 @@
# directory not in scm, don't walk it's content
dirnames[:] = []
continue
- if (
- os.path.islink(dirpath)
- and not os.path.relpath(realdirpath, realpath).startswith(os.pardir)
- ):
+ if os.path.islink(dirpath) and not os.path.relpath(
+ realdirpath, realpath
+ ).startswith(os.pardir):
# a symlink to a directory not outside path:
# we keep it in the result and don't walk its content
res.append(os.path.join(path, os.path.relpath(dirpath, path)))
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/file_finder_git.py
^
|
@@ -28,16 +28,16 @@
def _git_interpret_archive(fd, toplevel):
- tf = tarfile.open(fileobj=fd, mode="r|*")
- git_files = set()
- git_dirs = {toplevel}
- for member in tf.getmembers():
- name = os.path.normcase(member.name).replace("/", os.path.sep)
- if member.type == tarfile.DIRTYPE:
- git_dirs.add(name)
- else:
- git_files.add(name)
- return git_files, git_dirs
+ with tarfile.open(fileobj=fd, mode="r|*") as tf:
+ git_files = set()
+ git_dirs = {toplevel}
+ for member in tf.getmembers():
+ name = os.path.normcase(member.name).replace("/", os.path.sep)
+ if member.type == tarfile.DIRTYPE:
+ git_dirs.add(name)
+ else:
+ git_files.add(name)
+ return git_files, git_dirs
def _git_ls_files_and_dirs(toplevel):
@@ -46,7 +46,11 @@
cmd = ["git", "archive", "--prefix", toplevel + os.path.sep, "HEAD"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, cwd=toplevel)
try:
- return _git_interpret_archive(proc.stdout, toplevel)
+ try:
+ return _git_interpret_archive(proc.stdout, toplevel)
+ finally:
+ # ensure we avoid resource warnings by cleaning up the process
+ proc.terminate()
except Exception:
if proc.wait() != 0:
log.exception("listing git files failed - pretending there aren't any")
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/git.py
^
|
@@ -65,7 +65,7 @@
def warn_on_shallow(wd):
"""experimental, may change at any time"""
if wd.is_shallow():
- warnings.warn('"%s" is shallow and may cause errors' % (wd.path,))
+ warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))
def fetch_on_shallow(wd):
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/hg.py
^
|
@@ -15,9 +15,7 @@
# ignore commits that only modify .hgtags and nothing else:
" and (merge() or file('re:^(?!\\.hgtags).*$'))"
" and not tag({tag!r}))" # ignore the tagged commit itself
- ).format(
- tag=tag
- )
+ ).format(tag=tag)
if tag != "0.0":
commits = do(
["hg", "log", "-r", revset, "--template", "{node|short}"],
@@ -71,7 +69,12 @@
def get_latest_normalizable_tag(root):
# Gets all tags containing a '.' (see #229) from oldest to newest
cmd = [
- "hg", "log", "-r", "ancestors(.) and tag('re:\\.')", "--template", "{tags}\n"
+ "hg",
+ "log",
+ "-r",
+ "ancestors(.) and tag('re:\\.')",
+ "--template",
+ "{tags}\n",
]
outlines = do(cmd, root).split()
if not outlines:
@@ -81,7 +84,7 @@
def get_graph_distance(root, rev1, rev2="."):
- cmd = ["hg", "log", "-q", "-r", "%s::%s" % (rev1, rev2)]
+ cmd = ["hg", "log", "-q", "-r", "{}::{}".format(rev1, rev2)]
out = do(cmd, root)
return len(out.strip().splitlines()) - 1
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/integration.py
^
|
@@ -1,8 +1,8 @@
from pkg_resources import iter_entry_points
from .version import _warn_if_setuptools_outdated
-from .utils import do
-from . import get_version
+from .utils import do, trace_exception
+from . import _get_version, Configuration
def version_keyword(dist, keyword, value):
@@ -13,8 +13,8 @@
value = {}
if getattr(value, "__call__", None):
value = value()
-
- dist.metadata.version = get_version(**value)
+ config = Configuration(**value)
+ dist.metadata.version = _get_version(config)
def find_files(path=""):
@@ -28,3 +28,21 @@
if res:
return res
return []
+
+
+def _args_from_toml(name="pyproject.toml"):
+ # todo: more sensible config initialization
+ # move this elper back to config and unify it with the code from get_config
+
+ with open(name) as strm:
+ defn = __import__("toml").load(strm)
+ return defn.get("tool", {})["setuptools_scm"]
+
+
+def infer_version(dist):
+
+ try:
+ config = Configuration.from_file()
+ except Exception:
+ return trace_exception()
+ dist.metadata.version = _get_version(config)
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/utils.py
^
|
@@ -10,6 +10,7 @@
import os
import io
import platform
+import traceback
DEBUG = bool(os.environ.get("SETUPTOOLS_SCM_DEBUG"))
@@ -19,12 +20,37 @@
string_types = (str,) if PY3 else (str, unicode) # noqa
+def no_git_env(env):
+ # adapted from pre-commit
+ # Too many bugs dealing with environment variables and GIT:
+ # https://github.com/pre-commit/pre-commit/issues/300
+ # In git 2.6.3 (maybe others), git exports GIT_WORK_TREE while running
+ # pre-commit hooks
+ # In git 1.9.1 (maybe others), git exports GIT_DIR and GIT_INDEX_FILE
+ # while running pre-commit hooks in submodules.
+ # GIT_DIR: Causes git clone to clone wrong thing
+ # GIT_INDEX_FILE: Causes 'error invalid object ...' during commit
+ for k, v in env.items():
+ if k.startswith("GIT_"):
+ trace(k, v)
+ return {
+ k: v
+ for k, v in env.items()
+ if not k.startswith("GIT_")
+ or k in ("GIT_EXEC_PATH", "GIT_SSH", "GIT_SSH_COMMAND")
+ }
+
+
def trace(*k):
if DEBUG:
print(*k)
sys.stdout.flush()
+def trace_exception():
+ DEBUG and traceback.print_exc()
+
+
def ensure_stripped_str(str_or_bytes):
if isinstance(str_or_bytes, str):
return str_or_bytes.strip()
@@ -43,7 +69,6 @@
def _popen_pipes(cmd, cwd):
-
return subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
@@ -51,7 +76,8 @@
cwd=str(cwd),
env=_always_strings(
dict(
- os.environ,
+ no_git_env(os.environ),
+ # os.environ,
# try to disable i18n
LC_ALL="C",
LANGUAGE="",
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/src/setuptools_scm/version.py
^
|
@@ -34,11 +34,11 @@
result = {
"version": match.group(key),
- "prefix": match.group(0)[:match.start(key)],
- "suffix": match.group(0)[match.end(key):],
+ "prefix": match.group(0)[: match.start(key)],
+ "suffix": match.group(0)[match.end(key) :],
}
- trace("tag '%s' parsed to %s" % (tag, result))
+ trace("tag '{}' parsed to {}".format(tag, result))
return result
@@ -89,7 +89,7 @@
tagdict = _parse_version_tag(tag, config)
if not isinstance(tagdict, dict) or not tagdict.get("version", None):
- warnings.warn("tag %r no version found" % (tag,))
+ warnings.warn("tag {!r} no version found".format(tag))
return None
version = tagdict["version"]
@@ -97,7 +97,9 @@
if tagdict.get("suffix", ""):
warnings.warn(
- "tag %r will be stripped of its suffix '%s'" % (tag, tagdict["suffix"])
+ "tag {!r} will be stripped of its suffix '{}'".format(
+ tag, tagdict["suffix"]
+ )
)
if VERSION_CLASS is not None:
@@ -122,7 +124,6 @@
class ScmVersion(object):
-
def __init__(
self,
tag_version,
|
[-]
[+]
|
Added |
setuptools_scm-3.4.3.tar.gz/testing/play_out_381.bash
^
|
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+set -euxo pipefail
+
+rm -rf y z home venv tmp
+
+[ ! -d black ] && git clone https://github.com/psf/black
+export SETUPTOOLS_SCM_DEBUG=1
+export PRE_COMMIT_HOME="$PWD/home"
+export TMPDIR="$PWD/tmp"
+
+git init y
+git init z
+git -C z commit --allow-empty -m 'commit!'
+git -C y submodule add "$PWD/z"
+cat > "$PWD/y/.git/modules/z/hooks/pre-commit" <<EOF
+#!/usr/bin/env bash
+virtualenv "$PWD/venv"
+"$PWD/venv/bin/pip" install -e "$1"
+"$PWD/venv/bin/pip" install --no-clean "$PWD/black"
+EOF
+chmod +x "$PWD/y/.git/modules/z/hooks/pre-commit"
+cd y/z
+git commit -m "test"
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/runtests_travis.py
^
|
@@ -1,4 +1,3 @@
-
from subprocess import call
import os
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/test_basic_api.py
^
|
@@ -98,7 +98,6 @@
def test_parse_plain_fails(recwarn):
-
def parse(root):
return "tricked you"
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/test_config.py
^
|
@@ -1,5 +1,7 @@
-from setuptools_scm.config import Configuration
+from __future__ import unicode_literals
+from setuptools_scm.config import Configuration
+import re
import pytest
@@ -18,3 +20,15 @@
match = config.tag_regex.match(tag)
version = match.group("version")
assert version == expected_version
+
+
+def test_config_from_pyproject(tmpdir):
+ fn = tmpdir / "pyproject.toml"
+ fn.write_text("[tool.setuptools_scm]\n", encoding="utf-8")
+ assert Configuration.from_file(str(fn))
+
+
+def test_config_regex_init():
+ tag_regex = re.compile(r"v(\d+)")
+ conf = Configuration(tag_regex=tag_regex)
+ assert conf.tag_regex is tag_regex
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/test_file_finder.py
^
|
@@ -48,9 +48,8 @@
(inwd.cwd / "CamelFile").ensure(file=True)
(inwd.cwd / "file2").ensure(file=True)
inwd.add_and_commit()
- assert (
- set(find_files())
- == _sep({"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"})
+ assert set(find_files()) == _sep(
+ {"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"}
)
@@ -73,9 +72,9 @@
def test_symlink_file(inwd):
(inwd.cwd / "adir" / "file1link").mksymlinkto("../file1")
inwd.add_and_commit()
- assert (
- set(find_files("adir")) == _sep({"adir/filea", "adir/file1link"}) # -> ../file1
- )
+ assert set(find_files("adir")) == _sep(
+ {"adir/filea", "adir/file1link"}
+ ) # -> ../file1
@pytest.mark.skipif(
@@ -130,8 +129,8 @@
subdir.ensure(dir=True)
(subdir / "xfile").ensure(file=True)
inwd.add_and_commit()
- assert (
- set(find_files("adir")) == _sep({"adir/filea", "adir/emptysubdir/subdir/xfile"})
+ assert set(find_files("adir")) == _sep(
+ {"adir/filea", "adir/emptysubdir/subdir/xfile"}
)
@@ -142,18 +141,15 @@
(inwd.cwd / "adir" / "datalink").mksymlinkto("../data")
(inwd.cwd / "adir" / "filealink").mksymlinkto("filea")
inwd.add_and_commit()
- assert (
- set(find_files())
- == _sep(
- {
- "file1",
- "adir/datalink", # -> ../data
- "adir/filealink", # -> filea
- "adir/filea",
- "bdir/fileb",
- "data/datafile",
- }
- )
+ assert set(find_files()) == _sep(
+ {
+ "file1",
+ "adir/datalink", # -> ../data
+ "adir/filealink", # -> filea
+ "adir/filea",
+ "bdir/fileb",
+ "data/datafile",
+ }
)
@@ -164,16 +160,13 @@
inwd.add_and_commit()
(inwd.cwd / "adir" / "datalink").mksymlinkto("../data")
(inwd.cwd / "adir" / "filealink").mksymlinkto("filea")
- assert (
- set(find_files())
- == _sep(
- {
- "file1",
- "adir/filea",
- # adir/datalink and adir/afilelink not included
- # because the symlink themselves are not in scm
- "bdir/fileb",
- "data/datafile",
- }
- )
+ assert set(find_files()) == _sep(
+ {
+ "file1",
+ "adir/filea",
+ # adir/datalink and adir/afilelink not included
+ # because the symlink themselves are not in scm
+ "bdir/fileb",
+ "data/datafile",
+ }
)
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/test_functions.py
^
|
@@ -16,7 +16,6 @@
class MockTime(object):
-
def __format__(self, *k):
return "time"
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/test_git.py
^
|
@@ -10,7 +10,8 @@
@pytest.fixture
-def wd(wd):
+def wd(wd, monkeypatch):
+ monkeypatch.delenv("HOME", raising=False)
wd("git init")
wd("git config user.email test@example.com")
wd('git config user.name "a test"')
@@ -115,6 +116,16 @@
assert today.strftime(".d%Y%m%d") in wd.version
+@pytest.mark.issue(193)
+def test_git_worktree_support(wd, tmpdir):
+ wd.commit_testfile()
+ worktree = tmpdir.join("work_tree")
+ wd("git worktree add -b work-tree %s" % worktree)
+
+ res = do([sys.executable, "-m", "setuptools_scm", "ls"], cwd=worktree)
+ assert str(worktree) in res
+
+
@pytest.fixture
def shallow_wd(wd, tmpdir):
wd.commit_testfile()
@@ -218,6 +229,15 @@
assert wd.get_version(
tag_regex=r"^apache-arrow-([\.0-9]+)$",
git_describe_command="git describe --dirty --tags --long --exclude *js* ",
- ).startswith(
- "0.11.2"
- )
+ ).startswith("0.11.2")
+
+
+@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/381")
+def test_gitdir(monkeypatch, wd):
+ """
+ """
+ wd.commit_testfile()
+ normal = wd.version
+ # git hooks set this and break subsequent setuptools_scm unless we clean
+ monkeypatch.setenv("GIT_DIR", __file__)
+ assert wd.version == normal
|
[-]
[+]
|
Added |
setuptools_scm-3.4.3.tar.gz/testing/test_integration.py
^
|
@@ -0,0 +1,38 @@
+import sys
+
+import pytest
+
+from setuptools_scm.utils import do
+
+
+@pytest.fixture
+def wd(wd):
+ wd("git init")
+ wd("git config user.email test@example.com")
+ wd('git config user.name "a test"')
+ wd.add_command = "git add ."
+ wd.commit_command = "git commit -m test-{reason}"
+ return wd
+
+
+def test_pyproject_support(tmpdir, monkeypatch):
+ pytest.importorskip("toml")
+ monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
+ pkg = tmpdir.ensure("package", dir=42)
+ pkg.join("pyproject.toml").write(
+ """[tool.setuptools_scm]
+fallback_version = "12.34"
+"""
+ )
+ pkg.join("setup.py").write("__import__('setuptools').setup()")
+ res = do((sys.executable, "setup.py", "--version"), pkg)
+ assert res == "12.34"
+
+
+def test_pyproject_support_with_git(tmpdir, monkeypatch, wd):
+ monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
+ pkg = tmpdir.join("wd")
+ pkg.join("pyproject.toml").write("""[tool.setuptools_scm]""")
+ pkg.join("setup.py").write("__import__('setuptools').setup()")
+ res = do((sys.executable, "setup.py", "--version"), pkg)
+ assert res == "0.1.dev0"
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/testing/test_mercurial.py
^
|
@@ -16,7 +16,9 @@
archival_mapping = {
"1.0": {"tag": "1.0"},
"1.1.dev3+h000000000000": {
- "latesttag": "1.0", "latesttagdistance": "3", "node": "0" * 20
+ "latesttag": "1.0",
+ "latesttagdistance": "3",
+ "node": "0" * 20,
},
"0.0": {"node": "0" * 20},
"1.2.2": {"tag": "release-1.2.2"},
|
[-]
[+]
|
Changed |
setuptools_scm-3.4.3.tar.gz/tox.ini
^
|
@@ -2,6 +2,7 @@
envlist=py{27,34,35,36,37,38}-test,flake8,check_readme,py{27,37}-selfcheck
[pytest]
+testpaths=testing
filterwarnings=error
markers=
issue(id): reference to github issue
@@ -9,6 +10,7 @@
[flake8]
max-complexity = 10
max-line-length = 88
+ignore=E203,W503
exclude=
.git,
.tox,
@@ -25,9 +27,12 @@
test: False
deps=
pytest
+ setuptools >= 42
commands=
test: py.test []
selfcheck: python setup.py --version
+extras =
+ toml
[testenv:flake8]
skip_install=True
|