update versioneer to 0.28
This commit is contained in:
parent
35f5cdc005
commit
8dbb3fce4e
2 changed files with 184 additions and 119 deletions
|
|
@ -5,8 +5,9 @@
|
|||
# directories (produced by setup.py build) will contain a much shorter file
|
||||
# that just contains the computed version number.
|
||||
|
||||
# This file is released into the public domain. Generated by
|
||||
# versioneer-0.22 (https://github.com/python-versioneer/python-versioneer)
|
||||
# This file is released into the public domain.
|
||||
# Generated by versioneer-0.28
|
||||
# https://github.com/python-versioneer/python-versioneer
|
||||
|
||||
"""Git implementation of _version.py."""
|
||||
|
||||
|
|
@ -248,19 +249,18 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
runner = functools.partial(runner, env=env)
|
||||
|
||||
_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
|
||||
hide_stderr=True)
|
||||
hide_stderr=not verbose)
|
||||
if rc != 0:
|
||||
if verbose:
|
||||
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_ARGS],
|
||||
cwd=root)
|
||||
describe_out, rc = runner(GITS, [
|
||||
"describe", "--tags", "--dirty", "--always", "--long",
|
||||
"--match", f"{tag_prefix}[[:digit:]]*"
|
||||
], cwd=root)
|
||||
# --long was added in git-1.5.5
|
||||
if describe_out is None:
|
||||
raise NotThisMethod("'git describe' failed")
|
||||
|
|
@ -349,8 +349,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
else:
|
||||
# HEX: no tags
|
||||
pieces["closest-tag"] = None
|
||||
count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
|
||||
pieces["distance"] = int(count_out) # total number of commits
|
||||
out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root)
|
||||
pieces["distance"] = len(out.split()) # total number of commits
|
||||
|
||||
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||
date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
|
||||
|
|
@ -446,7 +446,7 @@ def render_pep440_pre(pieces):
|
|||
tag_version, post_version = pep440_split_post(pieces["closest-tag"])
|
||||
rendered = tag_version
|
||||
if post_version is not None:
|
||||
rendered += ".post%d.dev%d" % (post_version+1, pieces["distance"])
|
||||
rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"])
|
||||
else:
|
||||
rendered += ".post0.dev%d" % (pieces["distance"])
|
||||
else:
|
||||
|
|
|
|||
281
versioneer.py
281
versioneer.py
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
# Version: 0.22
|
||||
# Version: 0.28
|
||||
|
||||
"""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, 3.10 and pypy3
|
||||
* License: Public Domain (Unlicense)
|
||||
* 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/setuptools-based
|
||||
This is a tool for managing a recorded version number in 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
|
||||
|
|
@ -23,10 +23,38 @@ system, and maybe making new tarballs.
|
|||
|
||||
## Quick Install
|
||||
|
||||
Versioneer provides two installation modes. The "classic" vendored mode installs
|
||||
a copy of versioneer into your repository. The experimental build-time dependency mode
|
||||
is intended to allow you to skip this step and simplify the process of upgrading.
|
||||
|
||||
### Vendored mode
|
||||
|
||||
* `pip install versioneer` to somewhere in your $PATH
|
||||
* add a `[versioneer]` section to your setup.cfg (see [Install](INSTALL.md))
|
||||
* run `versioneer install` in your source tree, commit the results
|
||||
* Verify version information with `python setup.py version`
|
||||
* A [conda-forge recipe](https://github.com/conda-forge/versioneer-feedstock) is
|
||||
available, so you can also use `conda install -c conda-forge versioneer`
|
||||
* add a `[tool.versioneer]` section to your `pyproject.toml` or a
|
||||
`[versioneer]` section to your `setup.cfg` (see [Install](INSTALL.md))
|
||||
* Note that you will need to add `tomli; python_version < "3.11"` to your
|
||||
build-time dependencies if you use `pyproject.toml`
|
||||
* run `versioneer install --vendor` in your source tree, commit the results
|
||||
* verify version information with `python setup.py version`
|
||||
|
||||
### Build-time dependency mode
|
||||
|
||||
* `pip install versioneer` to somewhere in your $PATH
|
||||
* A [conda-forge recipe](https://github.com/conda-forge/versioneer-feedstock) is
|
||||
available, so you can also use `conda install -c conda-forge versioneer`
|
||||
* add a `[tool.versioneer]` section to your `pyproject.toml` or a
|
||||
`[versioneer]` section to your `setup.cfg` (see [Install](INSTALL.md))
|
||||
* add `versioneer` (with `[toml]` extra, if configuring in `pyproject.toml`)
|
||||
to the `requires` key of the `build-system` table in `pyproject.toml`:
|
||||
```toml
|
||||
[build-system]
|
||||
requires = ["setuptools", "versioneer[toml]"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
```
|
||||
* run `versioneer install --no-vendor` in your source tree, commit the results
|
||||
* verify version information with `python setup.py version`
|
||||
|
||||
## Version Identifiers
|
||||
|
||||
|
|
@ -231,9 +259,10 @@ resolve it.
|
|||
To upgrade your project to a new release of Versioneer, do the following:
|
||||
|
||||
* install the new Versioneer (`pip install -U versioneer` or equivalent)
|
||||
* edit `setup.cfg`, if necessary, to include any new configuration settings
|
||||
indicated by the release notes. See [UPGRADING](./UPGRADING.md) for details.
|
||||
* re-run `versioneer install` in your source tree, to replace
|
||||
* edit `setup.cfg` and `pyproject.toml`, if necessary,
|
||||
to include any new configuration settings indicated by the release notes.
|
||||
See [UPGRADING](./UPGRADING.md) for details.
|
||||
* re-run `versioneer install --[no-]vendor` in your source tree, to replace
|
||||
`SRC/_version.py`
|
||||
* commit any changed files
|
||||
|
||||
|
|
@ -263,9 +292,8 @@ number of intermediate scripts.
|
|||
|
||||
To make Versioneer easier to embed, all its code is dedicated to the public
|
||||
domain. The `_version.py` that it creates is also in the public domain.
|
||||
Specifically, both are released under the Creative Commons "Public Domain
|
||||
Dedication" license (CC0-1.0), as described in
|
||||
https://creativecommons.org/publicdomain/zero/1.0/ .
|
||||
Specifically, both are released under the "Unlicense", as described in
|
||||
https://unlicense.org/.
|
||||
|
||||
[pypi-image]: https://img.shields.io/pypi/v/versioneer.svg
|
||||
[pypi-url]: https://pypi.python.org/pypi/versioneer/
|
||||
|
|
@ -287,9 +315,19 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Callable, Dict
|
||||
import functools
|
||||
|
||||
have_tomllib = True
|
||||
if sys.version_info >= (3, 11):
|
||||
import tomllib
|
||||
else:
|
||||
try:
|
||||
import tomli as tomllib
|
||||
except ImportError:
|
||||
have_tomllib = False
|
||||
|
||||
|
||||
class VersioneerConfig:
|
||||
"""Container for Versioneer configuration parameters."""
|
||||
|
|
@ -326,7 +364,7 @@ def get_root():
|
|||
my_path = os.path.realpath(os.path.abspath(__file__))
|
||||
me_dir = os.path.normcase(os.path.splitext(my_path)[0])
|
||||
vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0])
|
||||
if me_dir != vsr_dir:
|
||||
if me_dir != vsr_dir and "VERSIONEER_PEP518" not in globals():
|
||||
print("Warning: build in %s is using versioneer.py from %s"
|
||||
% (os.path.dirname(my_path), versioneer_py))
|
||||
except NameError:
|
||||
|
|
@ -340,22 +378,32 @@ def get_config_from_root(root):
|
|||
# configparser.NoSectionError (if it lacks a [versioneer] section), or
|
||||
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
|
||||
# the top of versioneer.py for instructions on writing your setup.cfg .
|
||||
setup_cfg = os.path.join(root, "setup.cfg")
|
||||
parser = configparser.ConfigParser()
|
||||
with open(setup_cfg, "r") as cfg_file:
|
||||
parser.read_file(cfg_file)
|
||||
VCS = parser.get("versioneer", "VCS") # mandatory
|
||||
root = Path(root)
|
||||
pyproject_toml = root / "pyproject.toml"
|
||||
setup_cfg = root / "setup.cfg"
|
||||
section = None
|
||||
if pyproject_toml.exists() and have_tomllib:
|
||||
try:
|
||||
with open(pyproject_toml, 'rb') as fobj:
|
||||
pp = tomllib.load(fobj)
|
||||
section = pp['tool']['versioneer']
|
||||
except (tomllib.TOMLDecodeError, KeyError):
|
||||
pass
|
||||
if not section:
|
||||
parser = configparser.ConfigParser()
|
||||
with open(setup_cfg) as cfg_file:
|
||||
parser.read_file(cfg_file)
|
||||
parser.get("versioneer", "VCS") # raise error if missing
|
||||
|
||||
# Dict-like interface for non-mandatory entries
|
||||
section = parser["versioneer"]
|
||||
section = parser["versioneer"]
|
||||
|
||||
cfg = VersioneerConfig()
|
||||
cfg.VCS = VCS
|
||||
cfg.VCS = section['VCS']
|
||||
cfg.style = section.get("style", "")
|
||||
cfg.versionfile_source = section.get("versionfile_source")
|
||||
cfg.versionfile_build = section.get("versionfile_build")
|
||||
cfg.tag_prefix = section.get("tag_prefix")
|
||||
if cfg.tag_prefix in ("''", '""'):
|
||||
if cfg.tag_prefix in ("''", '""', None):
|
||||
cfg.tag_prefix = ""
|
||||
cfg.parentdir_prefix = section.get("parentdir_prefix")
|
||||
cfg.verbose = section.get("verbose")
|
||||
|
|
@ -430,8 +478,9 @@ LONG_VERSION_PY['git'] = r'''
|
|||
# directories (produced by setup.py build) will contain a much shorter file
|
||||
# that just contains the computed version number.
|
||||
|
||||
# This file is released into the public domain. Generated by
|
||||
# versioneer-0.22 (https://github.com/python-versioneer/python-versioneer)
|
||||
# This file is released into the public domain.
|
||||
# Generated by versioneer-0.28
|
||||
# https://github.com/python-versioneer/python-versioneer
|
||||
|
||||
"""Git implementation of _version.py."""
|
||||
|
||||
|
|
@ -673,19 +722,18 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
runner = functools.partial(runner, env=env)
|
||||
|
||||
_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
|
||||
hide_stderr=True)
|
||||
hide_stderr=not verbose)
|
||||
if rc != 0:
|
||||
if verbose:
|
||||
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_ARGS],
|
||||
cwd=root)
|
||||
describe_out, rc = runner(GITS, [
|
||||
"describe", "--tags", "--dirty", "--always", "--long",
|
||||
"--match", f"{tag_prefix}[[:digit:]]*"
|
||||
], cwd=root)
|
||||
# --long was added in git-1.5.5
|
||||
if describe_out is None:
|
||||
raise NotThisMethod("'git describe' failed")
|
||||
|
|
@ -774,8 +822,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
else:
|
||||
# HEX: no tags
|
||||
pieces["closest-tag"] = None
|
||||
count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
|
||||
pieces["distance"] = int(count_out) # total number of commits
|
||||
out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root)
|
||||
pieces["distance"] = len(out.split()) # total number of commits
|
||||
|
||||
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||
date = runner(GITS, ["show", "-s", "--format=%%ci", "HEAD"], cwd=root)[0].strip()
|
||||
|
|
@ -871,7 +919,7 @@ def render_pep440_pre(pieces):
|
|||
tag_version, post_version = pep440_split_post(pieces["closest-tag"])
|
||||
rendered = tag_version
|
||||
if post_version is not None:
|
||||
rendered += ".post%%d.dev%%d" %% (post_version+1, pieces["distance"])
|
||||
rendered += ".post%%d.dev%%d" %% (post_version + 1, pieces["distance"])
|
||||
else:
|
||||
rendered += ".post0.dev%%d" %% (pieces["distance"])
|
||||
else:
|
||||
|
|
@ -1196,19 +1244,18 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
runner = functools.partial(runner, env=env)
|
||||
|
||||
_, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
|
||||
hide_stderr=True)
|
||||
hide_stderr=not verbose)
|
||||
if rc != 0:
|
||||
if verbose:
|
||||
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_ARGS],
|
||||
cwd=root)
|
||||
describe_out, rc = runner(GITS, [
|
||||
"describe", "--tags", "--dirty", "--always", "--long",
|
||||
"--match", f"{tag_prefix}[[:digit:]]*"
|
||||
], cwd=root)
|
||||
# --long was added in git-1.5.5
|
||||
if describe_out is None:
|
||||
raise NotThisMethod("'git describe' failed")
|
||||
|
|
@ -1297,8 +1344,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
else:
|
||||
# HEX: no tags
|
||||
pieces["closest-tag"] = None
|
||||
count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
|
||||
pieces["distance"] = int(count_out) # total number of commits
|
||||
out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root)
|
||||
pieces["distance"] = len(out.split()) # total number of commits
|
||||
|
||||
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||
date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
|
||||
|
|
@ -1310,7 +1357,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
|
|||
return pieces
|
||||
|
||||
|
||||
def do_vcs_install(manifest_in, versionfile_source, ipy):
|
||||
def do_vcs_install(versionfile_source, ipy):
|
||||
"""Git-specific installation logic for Versioneer.
|
||||
|
||||
For Git, this means creating/changing .gitattributes to mark _version.py
|
||||
|
|
@ -1319,17 +1366,18 @@ def do_vcs_install(manifest_in, versionfile_source, ipy):
|
|||
GITS = ["git"]
|
||||
if sys.platform == "win32":
|
||||
GITS = ["git.cmd", "git.exe"]
|
||||
files = [manifest_in, versionfile_source]
|
||||
files = [versionfile_source]
|
||||
if ipy:
|
||||
files.append(ipy)
|
||||
try:
|
||||
my_path = __file__
|
||||
if my_path.endswith(".pyc") or my_path.endswith(".pyo"):
|
||||
my_path = os.path.splitext(my_path)[0] + ".py"
|
||||
versioneer_file = os.path.relpath(my_path)
|
||||
except NameError:
|
||||
versioneer_file = "versioneer.py"
|
||||
files.append(versioneer_file)
|
||||
if "VERSIONEER_PEP518" not in globals():
|
||||
try:
|
||||
my_path = __file__
|
||||
if my_path.endswith((".pyc", ".pyo")):
|
||||
my_path = os.path.splitext(my_path)[0] + ".py"
|
||||
versioneer_file = os.path.relpath(my_path)
|
||||
except NameError:
|
||||
versioneer_file = "versioneer.py"
|
||||
files.append(versioneer_file)
|
||||
present = False
|
||||
try:
|
||||
with open(".gitattributes", "r") as fobj:
|
||||
|
|
@ -1372,7 +1420,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
|
|||
|
||||
|
||||
SHORT_VERSION_PY = """
|
||||
# This file was generated by 'versioneer.py' (0.22) from
|
||||
# This file was generated by 'versioneer.py' (0.28) 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.
|
||||
|
|
@ -1501,7 +1549,7 @@ def render_pep440_pre(pieces):
|
|||
tag_version, post_version = pep440_split_post(pieces["closest-tag"])
|
||||
rendered = tag_version
|
||||
if post_version is not None:
|
||||
rendered += ".post%d.dev%d" % (post_version+1, pieces["distance"])
|
||||
rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"])
|
||||
else:
|
||||
rendered += ".post0.dev%d" % (pieces["distance"])
|
||||
else:
|
||||
|
|
@ -1753,7 +1801,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.
|
||||
|
|
@ -1775,11 +1823,8 @@ def get_cmdclass(cmdclass=None):
|
|||
|
||||
cmds = {} if cmdclass is None else cmdclass.copy()
|
||||
|
||||
# we add "version" to both distutils and setuptools
|
||||
try:
|
||||
from setuptools import Command
|
||||
except ImportError:
|
||||
from distutils.core import Command
|
||||
# we add "version" to setuptools
|
||||
from setuptools import Command
|
||||
|
||||
class cmd_version(Command):
|
||||
description = "report generated version string"
|
||||
|
|
@ -1802,7 +1847,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
|
||||
|
|
@ -1817,13 +1862,14 @@ def get_cmdclass(cmdclass=None):
|
|||
# then does setup.py bdist_wheel, or sometimes setup.py install
|
||||
# setup.py egg_info -> ?
|
||||
|
||||
# pip install -e . and setuptool/editable_wheel will invoke build_py
|
||||
# but the build_py command is not expected to copy any files.
|
||||
|
||||
# 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):
|
||||
|
|
@ -1831,6 +1877,10 @@ def get_cmdclass(cmdclass=None):
|
|||
cfg = get_config_from_root(root)
|
||||
versions = get_versions()
|
||||
_build_py.run(self)
|
||||
if getattr(self, "editable_mode", False):
|
||||
# During editable installs `.py` and data files are
|
||||
# not copied to build_lib
|
||||
return
|
||||
# now locate _version.py in the new build/ directory and replace
|
||||
# it with an updated value
|
||||
if cfg.versionfile_build:
|
||||
|
|
@ -1842,10 +1892,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):
|
||||
|
|
@ -1861,8 +1909,15 @@ def get_cmdclass(cmdclass=None):
|
|||
return
|
||||
# now locate _version.py in the new build/ directory and replace
|
||||
# it with an updated value
|
||||
if not cfg.versionfile_build:
|
||||
return
|
||||
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
|
||||
|
|
@ -1900,7 +1955,10 @@ def get_cmdclass(cmdclass=None):
|
|||
del cmds["build_py"]
|
||||
|
||||
if 'py2exe' in sys.modules: # py2exe enabled?
|
||||
from py2exe.distutils_buildexe import py2exe as _py2exe
|
||||
try:
|
||||
from py2exe.setuptools_buildexe import py2exe as _py2exe
|
||||
except ImportError:
|
||||
from py2exe.distutils_buildexe import py2exe as _py2exe
|
||||
|
||||
class cmd_py2exe(_py2exe):
|
||||
def run(self):
|
||||
|
|
@ -1924,13 +1982,48 @@ def get_cmdclass(cmdclass=None):
|
|||
})
|
||||
cmds["py2exe"] = cmd_py2exe
|
||||
|
||||
# sdist farms its file list building out to egg_info
|
||||
if 'egg_info' in cmds:
|
||||
_egg_info = cmds['egg_info']
|
||||
else:
|
||||
from setuptools.command.egg_info import egg_info as _egg_info
|
||||
|
||||
class cmd_egg_info(_egg_info):
|
||||
def find_sources(self):
|
||||
# egg_info.find_sources builds the manifest list and writes it
|
||||
# in one shot
|
||||
super().find_sources()
|
||||
|
||||
# Modify the filelist and normalize it
|
||||
root = get_root()
|
||||
cfg = get_config_from_root(root)
|
||||
self.filelist.append('versioneer.py')
|
||||
if cfg.versionfile_source:
|
||||
# There are rare cases where versionfile_source might not be
|
||||
# included by default, so we must be explicit
|
||||
self.filelist.append(cfg.versionfile_source)
|
||||
self.filelist.sort()
|
||||
self.filelist.remove_duplicates()
|
||||
|
||||
# The write method is hidden in the manifest_maker instance that
|
||||
# generated the filelist and was thrown away
|
||||
# We will instead replicate their final normalization (to unicode,
|
||||
# and POSIX-style paths)
|
||||
from setuptools import unicode_utils
|
||||
normalized = [unicode_utils.filesys_decode(f).replace(os.sep, '/')
|
||||
for f in self.filelist.files]
|
||||
|
||||
manifest_filename = os.path.join(self.egg_info, 'SOURCES.txt')
|
||||
with open(manifest_filename, 'w') as fobj:
|
||||
fobj.write('\n'.join(normalized))
|
||||
|
||||
cmds['egg_info'] = cmd_egg_info
|
||||
|
||||
# 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):
|
||||
|
|
@ -2055,42 +2148,10 @@ def do_setup():
|
|||
print(" %s doesn't exist, ok" % ipy)
|
||||
ipy = None
|
||||
|
||||
# Make sure both the top-level "versioneer.py" and versionfile_source
|
||||
# (PKG/_version.py, used by runtime code) are in MANIFEST.in, so
|
||||
# they'll be copied into source distributions. Pip won't be able to
|
||||
# install the package without this.
|
||||
manifest_in = os.path.join(root, "MANIFEST.in")
|
||||
simple_includes = set()
|
||||
try:
|
||||
with open(manifest_in, "r") as f:
|
||||
for line in f:
|
||||
if line.startswith("include "):
|
||||
for include in line.split()[1:]:
|
||||
simple_includes.add(include)
|
||||
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'
|
||||
# lines is safe, though.
|
||||
if "versioneer.py" not in simple_includes:
|
||||
print(" appending 'versioneer.py' to MANIFEST.in")
|
||||
with open(manifest_in, "a") as f:
|
||||
f.write("include versioneer.py\n")
|
||||
else:
|
||||
print(" 'versioneer.py' already in MANIFEST.in")
|
||||
if cfg.versionfile_source not in simple_includes:
|
||||
print(" appending versionfile_source ('%s') to MANIFEST.in" %
|
||||
cfg.versionfile_source)
|
||||
with open(manifest_in, "a") as f:
|
||||
f.write("include %s\n" % cfg.versionfile_source)
|
||||
else:
|
||||
print(" versionfile_source already in MANIFEST.in")
|
||||
|
||||
# Make VCS-specific changes. For git, this means creating/changing
|
||||
# .gitattributes to mark _version.py for export-subst keyword
|
||||
# substitution.
|
||||
do_vcs_install(manifest_in, cfg.versionfile_source, ipy)
|
||||
do_vcs_install(cfg.versionfile_source, ipy)
|
||||
return 0
|
||||
|
||||
|
||||
|
|
@ -2131,10 +2192,14 @@ def scan_setup_py():
|
|||
return errors
|
||||
|
||||
|
||||
def setup_command():
|
||||
"""Set up Versioneer and exit with appropriate error code."""
|
||||
errors = do_setup()
|
||||
errors += scan_setup_py()
|
||||
sys.exit(1 if errors else 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cmd = sys.argv[1]
|
||||
if cmd == "setup":
|
||||
errors = do_setup()
|
||||
errors += scan_setup_py()
|
||||
if errors:
|
||||
sys.exit(1)
|
||||
setup_command()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue