Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skrink macos brew & flags (Sourcery refactored) #5

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ Temporary Items

# Linux trash folder which might appear on any partition or disk
.Trash-*
dic.tar.gz
26 changes: 13 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ def build_extensions(self):
extra_compile_args = ['-fopenmp']
extra_link_args = ['-fopenmp']
elif system == "Darwin":
os.system("brew install llvm libomp")
os.system("brew install clang-omp")
# os.environ["CPP"] = "/usr/local/opt/llvm/bin/clang"
extra_compile_args = ["-Xpreprocessor", "-fopenmp"]
extra_link_args = ["-Xpreprocessor", "-fopenmp"]
os.system('brew install libomp')
extra_compile_args = ['-Xpreprocessor', '-fopenmp']
extra_link_args = ['-L/usr/local/lib', '-lomp']
else:
extra_compile_args = ['-fopenmp']
extra_link_args = ['-fopenmp']
Expand Down Expand Up @@ -181,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}"')
Comment on lines 180 to +182
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 182-287 refactored with the following changes:

with _TqdmUpTo(
unit="B",
unit_scale=True,
Expand All @@ -191,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 @@ -237,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 @@ -255,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 @@ -275,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 @@ -286,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 @@ -301,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")
Comment on lines 302 to +307
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function build_py.create_version_file refactored with the following changes:



class develop(setuptools.command.develop.develop):
Expand Down Expand Up @@ -336,7 +336,7 @@ def run(self):
cmdclass=cmdclass,
install_requires=[
"numpy >= 1.20.0",
"cython >= " + min_cython_ver,
f"cython >= {min_cython_ver}",
Comment on lines 337 to +339
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 337-337 refactored with the following changes:

"six",
"tqdm",
],
Expand Down