🐛 Fix versioneer

This commit is contained in:
Gina Häußge committed 2019-02-06 16:35:32 +01:00
1 parent fd8788dd34
commit ec689e3939
1 file changed
+17 -14
+17 -14
View File
@@ -428,9 +428,12 @@ def get_config_from_root(root):
# 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")
# TODO: find a py2 compatible solution for the configparser deprecation issues
parser = configparser.SafeConfigParser()
with io.open(setup_cfg, 'r') as f:
with io.open(setup_cfg, 'rt', encoding="utf-8") as f:
parser.readfp(f)
VCS = parser.get("versioneer", "VCS") # mandatory
def get(parser, name):
@@ -1203,7 +1206,7 @@ def git_get_keywords(versionfile_abs):
# _version.py.
keywords = {}
try:
f = io.open(versionfile_abs, 'rt')
f = io.open(versionfile_abs, 'rt', encoding="utf-8")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
@@ -1503,7 +1506,7 @@ def do_vcs_install(manifest_in, versionfile_source, ipy):
files.append(versioneer_file)
present = False
try:
f = io.open('.gitattributes', 'rt')
f = io.open('.gitattributes', 'rt', encoding="utf-8")
for line in f.readlines():
if line.strip().startswith(versionfile_source):
if "export-subst" in line.strip().split()[1:]:
@@ -1512,7 +1515,7 @@ def do_vcs_install(manifest_in, versionfile_source, ipy):
except EnvironmentError:
pass
if not present:
f = io.open('.gitattributes', 'a+')
f = io.open('.gitattributes', 'a+t', encoding="utf-8")
f.write("%s export-subst\n" % versionfile_source)
f.close()
files.append(".gitattributes")
@@ -1556,7 +1559,7 @@ def get_versions():
def versions_from_file(filename):
try:
with io.open(filename, 'r') as f:
with io.open(filename, 'rt', encoding="utf-8") as f:
contents = f.read()
except EnvironmentError:
raise NotThisMethod("unable to read _version.py")
@@ -1571,7 +1574,7 @@ def write_to_version_file(filename, versions):
os.unlink(filename)
contents = json.dumps(versions, sort_keys=True,
indent=1, separators=(",", ": "))
with io.open(filename, 'wb') as f:
with io.open(filename, 'wt', encoding="utf-8") as f:
f.write(SHORT_VERSION_PY % contents)
print("set %s to '%s'" % (filename, versions["version"]))
@@ -1984,7 +1987,7 @@ def get_cmdclass():
_build_exe.run(self)
os.unlink(target_versionfile)
with io.open(cfg.versionfile_source, 'wb') as f:
with io.open(cfg.versionfile_source, 'wt', encoding="utf-8") as f:
LONG = LONG_VERSION_PY[cfg.VCS]
f.write(LONG %
{"DOLLAR": "$",
@@ -2081,13 +2084,13 @@ def do_setup():
if isinstance(e, (EnvironmentError, configparser.NoSectionError)):
print("Adding sample versioneer config to setup.cfg",
file=sys.stderr)
with io.open(os.path.join(root, "setup.cfg"), 'a') as f:
with io.open(os.path.join(root, "setup.cfg"), 'at', encoding="utf-8") as f:
f.write(SAMPLE_CONFIG)
print(CONFIG_ERROR, file=sys.stderr)
return 1
print(" creating %s" % cfg.versionfile_source)
with io.open(cfg.versionfile_source, 'wb') as f:
with io.open(cfg.versionfile_source, 'wt', encoding="utf-8") as f:
LONG = LONG_VERSION_PY[cfg.VCS]
f.write(LONG % {"DOLLAR": "$",
"STYLE": cfg.style,
@@ -2101,13 +2104,13 @@ def do_setup():
"__init__.py")
if os.path.exists(ipy):
try:
with io.open(ipy, 'r') as f:
with io.open(ipy, 'rt', encoding="utf-8") as f:
old = f.read()
except EnvironmentError:
old = ""
if INIT_PY_SNIPPET not in old:
print(" appending to %s" % ipy)
with io.open(ipy, 'a') as f:
with io.open(ipy, 'at', encoding="utf-8") as f:
f.write(INIT_PY_SNIPPET)
else:
print(" %s unmodified" % ipy)
@@ -2135,14 +2138,14 @@ def do_setup():
# lines is safe, though.
if "versioneer.py" not in simple_includes:
print(" appending 'versioneer.py' to MANIFEST.in")
with io.open(manifest_in, 'a') as f:
with io.open(manifest_in, 'at', encoding="utf-8") 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 io.open(manifest_in, 'a') as f:
with io.open(manifest_in, 'at', encoding="utf-8") as f:
f.write("include %s\n" % cfg.versionfile_source)
else:
print(" versionfile_source already in MANIFEST.in")
@@ -2158,7 +2161,7 @@ def scan_setup_py():
found = set()
setters = False
errors = 0
with io.open("setup.py", 'r') as f:
with io.open("setup.py", 'rt', encoding="utf-8") as f:
for line in f.readlines():
if "import versioneer" in line:
found.add("import")