Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Aug 12, 2022
1 parent acbebe5 commit 6af4b5f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def update_to(self, b=1, bsize=1, tsize=None):

# extract dic
filename = "dic.tar.gz"
print('Downloading: "{}"'.format(_DICT_URL))
print(f'Downloading: "{_DICT_URL}"')
with _TqdmUpTo(
unit="B",
unit_scale=True,
Expand All @@ -189,7 +189,7 @@ def update_to(self, b=1, bsize=1, tsize=None):
) as t: # all optional kwargs
urlretrieve(_DICT_URL, filename, reporthook=t.update_to)
t.total = t.n
print("Extracting tar file {}".format(filename))
print(f"Extracting tar file {filename}")
with tarfile.open(filename, mode="r|gz") as f:
f.extractall(path="./")
os.remove(filename)
Expand Down Expand Up @@ -235,7 +235,7 @@ def update_to(self, b=1, bsize=1, tsize=None):
ext_modules = [
Extension(
name="pyopenjtalk.openjtalk",
sources=[join("pyopenjtalk", "openjtalk" + ext)] + all_src,
sources=[join("pyopenjtalk", f"openjtalk{ext}")] + all_src,
include_dirs=[np.get_include()] + include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
Expand All @@ -253,13 +253,14 @@ def update_to(self, b=1, bsize=1, tsize=None):
)
]


# Extension for HTSEngine backend
htsengine_src_top = join("lib", "hts_engine_API", "src")
all_htsengine_src = glob(join(htsengine_src_top, "lib", "*.c"))
ext_modules += [
Extension(
name="pyopenjtalk.htsengine",
sources=[join("pyopenjtalk", "htsengine" + ext)] + all_htsengine_src,
sources=[join("pyopenjtalk", f"htsengine{ext}")] + all_htsengine_src,
include_dirs=[np.get_include(), join(htsengine_src_top, "include")],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
Expand All @@ -273,6 +274,7 @@ def update_to(self, b=1, bsize=1, tsize=None):
)
]


# Adapted from https://github.com/pytorch/pytorch
cwd = os.path.dirname(os.path.abspath(__file__))
if os.getenv("PYOPENJTALK_BUILD_VERSION"):
Expand All @@ -284,7 +286,7 @@ def update_to(self, b=1, bsize=1, tsize=None):
.decode("ascii")
.strip()
)
version += "+" + sha[:7]
version += f"+{sha[:7]}"
except subprocess.CalledProcessError:
pass
except IOError: # FileNotFoundError for python 3
Expand All @@ -299,10 +301,10 @@ def run(self):
@staticmethod
def create_version_file():
global version, cwd
print("-- Building version " + version)
print(f"-- Building version {version}")
version_path = os.path.join(cwd, "pyopenjtalk", "version.py")
with open(version_path, "w") as f:
f.write("__version__ = '{}'\n".format(version))
f.write(f"__version__ = '{version}'\n")


class develop(setuptools.command.develop.develop):
Expand Down Expand Up @@ -334,7 +336,7 @@ def run(self):
cmdclass=cmdclass,
install_requires=[
"numpy >= 1.20.0",
"cython >= " + min_cython_ver,
f"cython >= {min_cython_ver}",
"six",
"tqdm",
],
Expand Down

0 comments on commit 6af4b5f

Please sign in to comment.