提交 1a014483 authored 作者: Michał Górny's avatar Michał Górny 提交者: Brandon T. Willard

Update versioneer to fix build_ext bug

Update the generated versioneer fixes to the current git, in order to pull a bugfix that fixes the support for calling `build_ext` prior to `build_py`. This is part of Gentoo's workflow, and the current version of generated files is requiring us to use workarounds.
上级 45642af3
......@@ -6,7 +6,7 @@
# that just contains the computed version number.
# This file is released into the public domain. Generated by
# versioneer-0.21 (https://github.com/python-versioneer/python-versioneer)
# versioneer-0.23.dev0 (https://github.com/python-versioneer/python-versioneer)
"""Git implementation of _version.py."""
......@@ -16,6 +16,7 @@ import re
import subprocess
import sys
from typing import Callable, Dict
import functools
def get_keywords():
......@@ -73,6 +74,14 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
"""Call the given command(s)."""
assert isinstance(commands, list)
process = None
popen_kwargs = {}
if sys.platform == "win32":
# This hides the console window if pythonw.exe is used
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
popen_kwargs["startupinfo"] = startupinfo
for command in commands:
try:
dispcmd = str([command] + args)
......@@ -80,7 +89,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
process = subprocess.Popen([command] + args, cwd=cwd, env=env,
stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr
else None))
else None), **popen_kwargs)
break
except OSError:
e = sys.exc_info()[1]
......@@ -228,10 +237,15 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
version string, meaning we're inside a checked out source tree.
"""
GITS = ["git"]
TAG_PREFIX_REGEX = "*"
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]
TAG_PREFIX_REGEX = r"\*"
# GIT_DIR can interfere with correct operation of Versioneer.
# It may be intended to be passed to the Versioneer-versioned project,
# but that should not change where we get our version from.
env = os.environ.copy()
env.pop("GIT_DIR", None)
runner = functools.partial(runner, env=env)
_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
......@@ -240,12 +254,12 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
print("Directory %s not under git control" % root)
raise NotThisMethod("'git rev-parse --git-dir' returned error")
MATCH_ARGS = ["--match", "%s*" % tag_prefix] if tag_prefix else []
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match",
"%s%s" % (tag_prefix, TAG_PREFIX_REGEX)],
"--always", "--long", *MATCH_ARGS],
cwd=root)
# --long was added in git-1.5.5
if describe_out is None:
......
# Version: 0.21
# Version: 0.23.dev0
"""The Versioneer - like a rocketeer, but for versions.
......@@ -9,12 +9,12 @@ The Versioneer
* like a rocketeer, but for versions!
* https://github.com/python-versioneer/python-versioneer
* Brian Warner
* License: Public Domain
* Compatible with: Python 3.6, 3.7, 3.8, 3.9 and pypy3
* License: Public Domain (CC0-1.0)
* Compatible with: Python 3.7, 3.8, 3.9, 3.10 and pypy3
* [![Latest Version][pypi-image]][pypi-url]
* [![Build Status][travis-image]][travis-url]
This is a tool for managing a recorded version number in distutils-based
This is a tool for managing a recorded version number in distutils/setuptools-based
python projects. The goal is to remove the tedious and error-prone "update
the embedded version string" step from your release process. Making a new
release should be as easy as recording a new tag in your version-control
......@@ -288,6 +288,7 @@ import re
import subprocess
import sys
from typing import Callable, Dict
import functools
class VersioneerConfig:
......@@ -384,6 +385,14 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
"""Call the given command(s)."""
assert isinstance(commands, list)
process = None
popen_kwargs = {}
if sys.platform == "win32":
# This hides the console window if pythonw.exe is used
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
popen_kwargs["startupinfo"] = startupinfo
for command in commands:
try:
dispcmd = str([command] + args)
......@@ -391,7 +400,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
process = subprocess.Popen([command] + args, cwd=cwd, env=env,
stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr
else None))
else None), **popen_kwargs)
break
except OSError:
e = sys.exc_info()[1]
......@@ -422,7 +431,7 @@ LONG_VERSION_PY['git'] = r'''
# that just contains the computed version number.
# This file is released into the public domain. Generated by
# versioneer-0.21 (https://github.com/python-versioneer/python-versioneer)
# versioneer-0.23.dev0 (https://github.com/python-versioneer/python-versioneer)
"""Git implementation of _version.py."""
......@@ -432,6 +441,7 @@ import re
import subprocess
import sys
from typing import Callable, Dict
import functools
def get_keywords():
......@@ -489,6 +499,14 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
"""Call the given command(s)."""
assert isinstance(commands, list)
process = None
popen_kwargs = {}
if sys.platform == "win32":
# This hides the console window if pythonw.exe is used
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
popen_kwargs["startupinfo"] = startupinfo
for command in commands:
try:
dispcmd = str([command] + args)
......@@ -496,7 +514,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
process = subprocess.Popen([command] + args, cwd=cwd, env=env,
stdout=subprocess.PIPE,
stderr=(subprocess.PIPE if hide_stderr
else None))
else None), **popen_kwargs)
break
except OSError:
e = sys.exc_info()[1]
......@@ -644,10 +662,15 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
version string, meaning we're inside a checked out source tree.
"""
GITS = ["git"]
TAG_PREFIX_REGEX = "*"
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]
TAG_PREFIX_REGEX = r"\*"
# GIT_DIR can interfere with correct operation of Versioneer.
# It may be intended to be passed to the Versioneer-versioned project,
# but that should not change where we get our version from.
env = os.environ.copy()
env.pop("GIT_DIR", None)
runner = functools.partial(runner, env=env)
_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
......@@ -656,12 +679,12 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
print("Directory %%s not under git control" %% root)
raise NotThisMethod("'git rev-parse --git-dir' returned error")
MATCH_ARGS = ["--match", "%%s*" %% tag_prefix] if tag_prefix else []
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match",
"%%s%%s" %% (tag_prefix, TAG_PREFIX_REGEX)],
"--always", "--long", *MATCH_ARGS],
cwd=root)
# --long was added in git-1.5.5
if describe_out is None:
......@@ -1162,10 +1185,15 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
version string, meaning we're inside a checked out source tree.
"""
GITS = ["git"]
TAG_PREFIX_REGEX = "*"
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]
TAG_PREFIX_REGEX = r"\*"
# GIT_DIR can interfere with correct operation of Versioneer.
# It may be intended to be passed to the Versioneer-versioned project,
# but that should not change where we get our version from.
env = os.environ.copy()
env.pop("GIT_DIR", None)
runner = functools.partial(runner, env=env)
_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
......@@ -1174,12 +1202,12 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
print("Directory %s not under git control" % root)
raise NotThisMethod("'git rev-parse --git-dir' returned error")
MATCH_ARGS = ["--match", "%s*" % tag_prefix] if tag_prefix else []
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match",
"%s%s" % (tag_prefix, TAG_PREFIX_REGEX)],
"--always", "--long", *MATCH_ARGS],
cwd=root)
# --long was added in git-1.5.5
if describe_out is None:
......@@ -1344,7 +1372,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
SHORT_VERSION_PY = """
# This file was generated by 'versioneer.py' (0.21) from
# This file was generated by 'versioneer.py' (0.23.dev0) from
# revision-control system data, or from the parent directory name of an
# unpacked source archive. Distribution tarballs contain a pre-generated copy
# of this file.
......@@ -1725,7 +1753,7 @@ def get_version():
def get_cmdclass(cmdclass=None):
"""Get the custom setuptools/distutils subclasses used by Versioneer.
"""Get the custom setuptools subclasses used by Versioneer.
If the package uses a different cmdclass (e.g. one from numpy), it
should be provide as an argument.
......@@ -1747,8 +1775,8 @@ def get_cmdclass(cmdclass=None):
cmds = {} if cmdclass is None else cmdclass.copy()
# we add "version" to both distutils and setuptools
from distutils.core import Command
# we add "version" to setuptools
from setuptools import Command
class cmd_version(Command):
description = "report generated version string"
......@@ -1771,7 +1799,7 @@ def get_cmdclass(cmdclass=None):
print(" error: %s" % vers["error"])
cmds["version"] = cmd_version
# we override "build_py" in both distutils and setuptools
# we override "build_py" in setuptools
#
# most invocation pathways end up running build_py:
# distutils/build -> build_py
......@@ -1789,10 +1817,8 @@ def get_cmdclass(cmdclass=None):
# we override different "build_py" commands for both environments
if 'build_py' in cmds:
_build_py = cmds['build_py']
elif "setuptools" in sys.modules:
from setuptools.command.build_py import build_py as _build_py
else:
from distutils.command.build_py import build_py as _build_py
from setuptools.command.build_py import build_py as _build_py
class cmd_build_py(_build_py):
def run(self):
......@@ -1811,10 +1837,8 @@ def get_cmdclass(cmdclass=None):
if 'build_ext' in cmds:
_build_ext = cmds['build_ext']
elif "setuptools" in sys.modules:
from setuptools.command.build_ext import build_ext as _build_ext
else:
from distutils.command.build_ext import build_ext as _build_ext
from setuptools.command.build_ext import build_ext as _build_ext
class cmd_build_ext(_build_ext):
def run(self):
......@@ -1832,6 +1856,11 @@ def get_cmdclass(cmdclass=None):
# it with an updated value
target_versionfile = os.path.join(self.build_lib,
cfg.versionfile_build)
if not os.path.exists(target_versionfile):
print(f"Warning: {target_versionfile} does not exist, skipping "
"version update. This can happen if you are running build_ext "
"without first running build_py.")
return
print("UPDATING %s" % target_versionfile)
write_to_version_file(target_versionfile, versions)
cmds["build_ext"] = cmd_build_ext
......@@ -1896,10 +1925,8 @@ def get_cmdclass(cmdclass=None):
# we override different "sdist" commands for both environments
if 'sdist' in cmds:
_sdist = cmds['sdist']
elif "setuptools" in sys.modules:
from setuptools.command.sdist import sdist as _sdist
else:
from distutils.command.sdist import sdist as _sdist
from setuptools.command.sdist import sdist as _sdist
class cmd_sdist(_sdist):
def run(self):
......@@ -2039,8 +2066,8 @@ def do_setup():
except OSError:
pass
# That doesn't cover everything MANIFEST.in can do
# (http://docs.python.org/2/distutils/sourcedist.html#commands), so
# it might give some false negatives. Appending redundant 'include'
# (https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands),
# so it might give some false negatives. Appending redundant 'include'
# lines is safe, though.
if "versioneer.py" not in simple_includes:
print(" appending 'versioneer.py' to MANIFEST.in")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论