Commit 4d325499 authored by Julien Puydt's avatar Julien Puydt

New upstream version 3.3.3

parent f8d442a2
......@@ -22,6 +22,9 @@ python:
- '3.4'
- '3.5'
- '3.6'
- '3.7'
- '3.8-dev'
dist: xenial # needed for 3.7+
env:
- TOXENV=py-test
......@@ -62,40 +65,28 @@ jobs:
<<: *pypi
distributions: "sdist bdist_wheel"
- <<: *deploy
- &bdist_egg
<<: *deploy
name: "python eggs 2.7"
python: '2.7'
deploy:
<<: *pypi
distributions: "bdist_egg"
- <<: *deploy
- <<: *bdist_egg
name: "python eggs 3.4"
python: '3.4'
deploy:
<<: *pypi
distributions: "bdist_egg"
- <<: *deploy
- <<: *bdist_egg
name: "python eggs 3.5"
python: '3.5'
deploy:
<<: *pypi
distributions: "bdist_egg"
- <<: *deploy
- <<: *bdist_egg
name: "python eggs 3.6"
python: '3.6'
deploy:
<<: *pypi
distributions: "bdist_egg"
# - <<: *eggs
# name: "python eggs 3.7"
# python: '3.7'
# deploy:
# <<: *pypi
# distributions: "bdist_egg"
- <<: *bdist_egg
name: "python eggs 3.7"
python: '3.7'
- <<: *bdist_egg
name: "python eggs 3.8"
python: '3.8-dev'
cache:
directories:
......
v3.3.3
======
* add eggs for python3.7 and 3.8 to the deploy
v3.3.2
======
* fix #335 - fix python3.8 support and add builds for up to python3.8
v3.3.1
======
* fix #333 (regression from #198) - use a specific fallback root when calling fallbacks. Remove old
hack that resets the root when fallback entrypoints are present.
v3.3.0
======
* fix #198 by adding the ``fallback_version`` option, which sets the version to be used when everything else fails.
v3.2.0
======
......
......@@ -99,8 +99,8 @@ However, ``use_scm_version`` must still be placed in ``setup.py``. For example:
.. important::
Ensure neither the ``[metadata] version`` option nor the ``[egg_info]``
section are not defined, as these will interfere with ``setuptools_scm``.
Ensure neither the ``[metadata]`` ``version`` option nor the ``[egg_info]``
section are defined, as these will interfere with ``setuptools_scm``.
You may also need to define a ``pyproject.toml`` file (`PEP-0518
<https://www.python.org/dev/peps/pep-0518>`_) to ensure you have the required
......@@ -253,12 +253,6 @@ The currently supported configuration keys are:
repository to point ``setuptools_scm`` at the root of the repository by
supplying ``__file__``.
:parse:
A function that will be used instead of the discovered SCM for parsing the
version.
Use with caution, this is a function for advanced use, and you should be
familiar with the ``setuptools_scm`` internals to use it.
:tag_regex:
A Python regex string to extract the version part from any SCM tag.
The regex needs to contain three named groups prefix, version and suffix,
......@@ -267,6 +261,18 @@ The currently supported configuration keys are:
Defaults to the value of ``setuptools_scm.config.DEFAULT_TAG_REGEX``
(see `config.py <src/setuptools_scm/config.py>`_).
: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
unset (the default), setuptools_scm will error if it fails to detect the
version.
:parse:
A function that will be used instead of the discovered SCM for parsing the
version.
Use with caution, this is a function for advanced use, and you should be
familiar with the ``setuptools_scm`` internals to use it.
:git_describe_command:
This command will be used instead the default ``git describe`` command.
Use with caution, this is a function for advanced use, and you should be
......
......@@ -76,6 +76,7 @@ arguments = dict(
.hg_archival.txt = setuptools_scm.hg:parse_archival
PKG-INFO = setuptools_scm.hacks:parse_pkginfo
pip-egg-info = setuptools_scm.hacks:parse_pip_egg_info
setup.py = setuptools_scm.hacks:fallback_version
[setuptools_scm.files_command]
.hg = setuptools_scm.file_finder_hg:hg_find_files
......
......@@ -31,12 +31,12 @@ def version_from_scm(root):
config = Configuration()
config.root = root
# TODO: Is it API?
return _version_from_entrypoint(config, "setuptools_scm.parse_scm")
return _version_from_entrypoints(config)
def _call_entrypoint_fn(config, fn):
def _call_entrypoint_fn(root, config, fn):
if function_has_arg(fn, "config"):
return fn(config.absolute_root, config=config)
return fn(root, config=config)
else:
warnings.warn(
"parse functions are required to provide a named argument"
......@@ -44,12 +44,18 @@ def _call_entrypoint_fn(config, fn):
category=PendingDeprecationWarning,
stacklevel=2,
)
return fn(config.absolute_root)
return fn(root)
def _version_from_entrypoint(config, entrypoint):
for ep in iter_matching_entrypoints(config.absolute_root, entrypoint):
version = _call_entrypoint_fn(config, ep.load())
def _version_from_entrypoints(config, fallback=False):
if fallback:
entrypoint = "setuptools_scm.parse_scm_fallback"
root = config.fallback_root
else:
entrypoint = "setuptools_scm.parse_scm"
root = config.absolute_root
for ep in iter_matching_entrypoints(root, entrypoint):
version = _call_entrypoint_fn(root, config, ep.load())
if version:
return version
......@@ -81,20 +87,16 @@ def _do_parse(config):
return meta(tag=pretended, preformatted=True, config=config)
if config.parse:
parse_result = _call_entrypoint_fn(config, config.parse)
parse_result = _call_entrypoint_fn(config.absolute_root, config, config.parse)
if isinstance(parse_result, string_types):
raise TypeError(
"version parse result was a string\nplease return a parsed version"
)
version = parse_result or _version_from_entrypoint(
config, "setuptools_scm.parse_scm_fallback"
)
version = parse_result or _version_from_entrypoints(config, fallback=True)
else:
# include fallbacks after dropping them from the main entrypoint
version = _version_from_entrypoint(
config, "setuptools_scm.parse_scm"
) or _version_from_entrypoint(
config, "setuptools_scm.parse_scm_fallback"
version = _version_from_entrypoints(config) or _version_from_entrypoints(
config, fallback=True
)
if version:
......@@ -120,6 +122,8 @@ def get_version(
write_to_template=None,
relative_to=None,
tag_regex=None,
fallback_version=None,
fallback_root=".",
parse=None,
git_describe_command=None,
):
......@@ -132,12 +136,14 @@ def get_version(
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
......
......@@ -44,6 +44,7 @@ class Configuration(object):
local_scheme = None
write_to = None
write_to_template = None
fallback_version = None
_relative_to = None
parse = None
_tag_regex = None
......@@ -59,10 +60,20 @@ class Configuration(object):
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
@property
def fallback_root(self):
return self._fallback_root
@fallback_root.setter
def fallback_root(self, value):
self._fallback_root = os.path.abspath(value)
@property
def absolute_root(self):
return self._absolute_root
......
......@@ -22,3 +22,8 @@ def parse_pip_egg_info(root, config=None):
if not items:
return
return parse_pkginfo(os.path.join(pipdir, items[0]), config=config)
def fallback_version(root, config=None):
if config.fallback_version is not None:
return meta(config.fallback_version, preformatted=True, config=config)
......@@ -2,7 +2,6 @@ from pkg_resources import iter_entry_points
from .version import _warn_if_setuptools_outdated
from .utils import do
from .discover import iter_matching_entrypoints
from . import get_version
......@@ -14,12 +13,7 @@ def version_keyword(dist, keyword, value):
value = {}
if getattr(value, "__call__", None):
value = value()
# this piece of code is a hack to counter the mistake in root finding
matching_fallbacks = iter_matching_entrypoints(
".", "setuptools_scm.parse_scm_fallback"
)
if any(matching_fallbacks):
value.pop("root", None)
dist.metadata.version = get_version(**value)
......
......@@ -100,7 +100,8 @@ def function_has_arg(fn, argname):
if PY2:
argspec = inspect.getargspec(fn).args
else:
argspec = inspect.getfullargspec(fn).args
argspec = inspect.signature(fn).parameters
return argname in argspec
......
......@@ -63,7 +63,7 @@ class Wd(object):
__tracebackhide__ = True
from setuptools_scm import get_version
version = get_version(root=str(self.cwd), **kw)
version = get_version(root=str(self.cwd), fallback_root=str(self.cwd), **kw)
print(version)
return version
......
import os
import sys
import py
import pytest
......@@ -22,8 +23,9 @@ def test_data_from_mime(tmpdir):
assert res == {"name": "test", "revision": "1"}
def test_version_from_pkginfo(wd):
def test_version_from_pkginfo(wd, monkeypatch):
wd.write("PKG-INFO", "Version: 0.1")
assert wd.version == "0.1"
# replicate issue 167
......@@ -56,6 +58,18 @@ def test_root_parameter_pass_by(monkeypatch, tmpdir):
setuptools_scm.get_version(root=tmpdir.strpath)
def test_fallback(tmpdir, monkeypatch):
monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
p = tmpdir.ensure("sub/package", dir=1)
p.join("setup.py").write(
"""from setuptools import setup
setup(use_scm_version={"fallback_version": "12.34"})
"""
)
res = do((sys.executable, "setup.py", "--version"), p)
assert res == "12.34"
@pytest.mark.parametrize(
"version", ["1.0", "1.2.3.dev1+ge871260", "1.2.3.dev15+ge871260.d20180625", "2345"]
)
......
import sys
from setuptools_scm import integration
from setuptools_scm.utils import do
from setuptools_scm import git
......@@ -29,6 +31,19 @@ def test_parse_describe_output(given, tag, number, node, dirty):
assert parsed == (tag, number, node, dirty)
def test_root_relative_to(tmpdir, wd, monkeypatch):
monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
p = wd.cwd.ensure("sub/package", dir=1)
p.join("setup.py").write(
"""from setuptools import setup
setup(use_scm_version={"root": "../..",
"relative_to": __file__})
"""
)
res = do((sys.executable, "setup.py", "--version"), p)
assert res == "0.1.dev0"
@pytest.mark.issue("https://github.com/pypa/setuptools_scm/issues/298")
def test_file_finder_no_history(wd, caplog):
file_list = git_find_files(str(wd.cwd))
......
......@@ -29,7 +29,7 @@ def test_pkginfo_noscmroot(tmpdir, monkeypatch):
do("git init", p.dirpath())
res = do((sys.executable, "setup.py", "--version"), p)
assert res == "1.0"
assert res == "0.1.dev0"
def test_pip_egg_info(tmpdir, monkeypatch):
......@@ -43,10 +43,10 @@ def test_pip_egg_info(tmpdir, monkeypatch):
)
with pytest.raises(LookupError):
get_version(root=p.strpath)
get_version(root=p.strpath, fallback_root=p.strpath)
p.ensure("pip-egg-info/random.egg-info/PKG-INFO").write("Version: 1.0")
assert get_version(root=p.strpath) == "1.0"
assert get_version(root=p.strpath, fallback_root=p.strpath) == "1.0"
@pytest.mark.issue(164)
......
[tox]
envlist=py{27,34,35,36,37}-test,flake8,check_readme,py{27,37}-selfcheck
envlist=py{27,34,35,36,37,38}-test,flake8,check_readme,py{27,37}-selfcheck
[pytest]
filterwarnings=error
markers=
issue(id): reference to github issue
[flake8]
max-complexity = 10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment