Fix python 2.7 compat in setup.py (#11671)

* Plus minor linting / updating
This commit is contained in:
Adriane Boyd 2022-10-19 08:07:08 +02:00 committed by GitHub
parent 46234a5221
commit ca0cae2074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,7 +139,7 @@ def write_git_info_py(filename="spacy/git_info.py"):
try: try:
out = _minimal_ext_cmd(["git", "rev-parse", "--short", "HEAD"]) out = _minimal_ext_cmd(["git", "rev-parse", "--short", "HEAD"])
git_version = out.strip().decode("ascii") git_version = out.strip().decode("ascii")
except: except Exception:
pass pass
elif os.path.exists(filename): elif os.path.exists(filename):
# must be a source distribution, use existing version file # must be a source distribution, use existing version file
@ -147,7 +147,7 @@ def write_git_info_py(filename="spacy/git_info.py"):
a = open(filename, "r") a = open(filename, "r")
lines = a.readlines() lines = a.readlines()
git_version = lines[-1].split('"')[1] git_version = lines[-1].split('"')[1]
except: except Exception:
pass pass
finally: finally:
a.close() a.close()
@ -168,7 +168,7 @@ GIT_VERSION = "%(git_version)s"
def clean(path): def clean(path):
for path in path.glob("**/*"): for path in path.glob("**/*"):
if path.is_file() and path.suffix in (".so", ".cpp"): if path.is_file() and path.suffix in (".so", ".cpp"):
print(f"Deleting {path.name}") print("Deleting", path.name)
path.unlink() path.unlink()
@ -209,7 +209,7 @@ def setup_package():
ext_modules=ext_modules, ext_modules=ext_modules,
cmdclass={"build_ext": build_ext_subclass}, cmdclass={"build_ext": build_ext_subclass},
include_dirs=include_dirs, include_dirs=include_dirs,
package_data={"": ["*.pyx", "*.pxd", "*.pxi", "*.cpp"]}, package_data={"": ["*.pyx", "*.pxd", "*.pxi"]},
) )