use python 3 for the eden_scm getdeps build

Summary:
EdenFS is adding a Python 3 Thrift client intended for use by other
projects, and the Mercurial Python 2 build doesn't understand Python 3
syntax files, so switch the default getdeps build to Python 3.

Reviewed By: quark-zju

Differential Revision: D23587932

fbshipit-source-id: 6f47f1605987f9b37f888d29b49a848370d2eb0e
This commit is contained in:
Chad Austin 2020-09-14 21:38:22 -07:00 committed by Facebook GitHub Bot
parent 7d230956b7
commit dca9f7bbfb
2 changed files with 32 additions and 20 deletions

View File

@ -95,7 +95,7 @@ else
endif
build:
$(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
$(PYTHON3) setup.py $(PURE) build $(COMPILERFLAG)
wheel:
FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
@ -109,7 +109,7 @@ getdepsbuild:
ln -sfn $(GETDEPS_INSTALL_DIR)/rust-shed/source/shed ../../common/rust/shed
GETDEPS_BUILD=1 \
THRIFT="$(GETDEPS_INSTALL_DIR)/fbthrift/bin/thrift1" \
$(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
$(PYTHON3) setup.py $(PURE) build $(COMPILERFLAG)
cleanbutpackages:
-$(PYTHON) setup.py clean --all # ignore errors from this command
@ -131,13 +131,13 @@ clean: cleanbutpackages
rm -rf packages
install: build
$(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
$(PYTHON3) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
install-home: build
$(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
$(PYTHON3) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
install-getdeps: getdepsbuild
GETDEPS_BUILD=1 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
GETDEPS_BUILD=1 $(PYTHON3) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
check: tests

View File

@ -71,7 +71,10 @@ if sys.version_info[0] >= 3:
libdir_escape = "unicode_escape"
def sysstr(s):
return s.decode("latin-1")
if isinstance(s, bytes):
return s.decode("latin-1")
else:
return s
else:
@ -490,7 +493,7 @@ versionhash = struct.unpack(">Q", hashlib.sha1(versionb).digest()[:8])[0]
chgcflags = ["-std=c99", "-D_GNU_SOURCE", "-DHAVE_VERSIONHASH", "-I%s" % builddir]
versionhashpath = pjoin(builddir, "versionhash.h")
write_if_changed(versionhashpath, "#define HGVERSIONHASH %sULL\n" % versionhash)
write_if_changed(versionhashpath, b"#define HGVERSIONHASH %dULL\n" % versionhash)
write_if_changed(
"edenscm/mercurial/__version__.py",
@ -498,7 +501,7 @@ write_if_changed(
[
b"# this file is autogenerated by setup.py\n"
b'version = "%s"\n' % versionb,
b"versionhash = %s\n" % versionhash,
b"versionhash = %d\n" % versionhash,
]
),
)
@ -509,7 +512,7 @@ write_if_changed(
[
b"// this file is autogenerated by setup.py\n"
b'pub static VERSION: &\'static str = "%s";\n' % versionb,
b"pub static VERSION_HASH: u64 = %s;\n" % versionhash,
b"pub static VERSION_HASH: u64 = %d;\n" % versionhash,
]
),
)
@ -797,7 +800,7 @@ class thriftasset(asset):
for thriftdest in sorted(self.sourcemap.values()):
thriftfile = pjoin(thriftdir, thriftdest)
if os.path.exists(thriftfile):
with open(thriftfile) as f:
with open(thriftfile, "rb") as f:
hasher.update(f.read())
return int(hasher.hexdigest(), 16)
@ -1632,25 +1635,25 @@ extmodules += cythonize(
"edenscmnative.clindex",
sources=["edenscmnative/clindex.pyx"],
include_dirs=include_dirs,
extra_compile_args=filter(None, [STDC99, PRODUCEDEBUGSYMBOLS]),
extra_compile_args=list(filter(None, [STDC99, PRODUCEDEBUGSYMBOLS])),
),
Extension(
"edenscmnative.patchrmdir",
sources=["edenscmnative/patchrmdir.pyx"],
include_dirs=include_dirs,
extra_compile_args=filter(None, [PRODUCEDEBUGSYMBOLS]),
extra_compile_args=list(filter(None, [PRODUCEDEBUGSYMBOLS])),
),
Extension(
"edenscmnative.traceprof",
sources=["edenscmnative/traceprof.pyx"],
include_dirs=include_dirs,
extra_compile_args=filter(None, [STDCPP11, PRODUCEDEBUGSYMBOLS]),
extra_compile_args=list(filter(None, [STDCPP11, PRODUCEDEBUGSYMBOLS])),
),
Extension(
"edenscmnative.linelog",
sources=["edenscmnative/linelog.pyx"],
include_dirs=include_dirs,
extra_compile_args=filter(None, [STDC99, PRODUCEDEBUGSYMBOLS]),
extra_compile_args=list(filter(None, [STDC99, PRODUCEDEBUGSYMBOLS])),
),
],
compiler_directives=cythonopts,
@ -1664,7 +1667,9 @@ libraries = [
"depends": ["lib/cdatapack/cdatapack.h"],
"include_dirs": ["."] + include_dirs,
"libraries": ["lz4", SHA1_LIBRARY],
"extra_args": filter(None, [STDC99, WALL, WSTRICTPROTOTYPES] + cflags),
"extra_args": list(
filter(None, [STDC99, WALL, WSTRICTPROTOTYPES] + cflags)
),
},
),
(
@ -1679,7 +1684,9 @@ libraries = [
"lib/third-party/sha1dc/ubc_check.h",
],
"include_dirs": ["lib/third-party"] + include_dirs,
"extra_args": filter(None, [STDC99, WALL, WSTRICTPROTOTYPES] + cflags),
"extra_args": list(
filter(None, [STDC99, WALL, WSTRICTPROTOTYPES] + cflags)
),
},
),
(
@ -1701,7 +1708,7 @@ if needbuildinfo:
"buildinfo",
{
"sources": [buildinfocpath],
"extra_args": filter(None, cflags + [WALL, PIC]),
"extra_args": list(filter(None, cflags + [WALL, PIC])),
},
)
]
@ -1719,7 +1726,9 @@ if not iswindows:
],
"depends": [versionhashpath],
"include_dirs": ["contrib/chg"] + include_dirs,
"extra_args": filter(None, cflags + chgcflags + [STDC99, WALL, PIC]),
"extra_args": list(
filter(None, cflags + chgcflags + [STDC99, WALL, PIC])
),
},
)
)
@ -1801,8 +1810,11 @@ for root in ("mercurial/templates",):
# unicode on Python 2 still works because it won't contain any
# non-ascii bytes and will be implicitly converted back to bytes
# when operated on.
assert isinstance(version, bytes)
setupversion = version.decode("ascii")
if isinstance(version, bytes):
setupversion = version.decode("ascii")
else:
assert isinstance(version, str)
setupversion = version
if os.name == "nt":
# Windows binary file versions for exe/dll files must have the