Skip to content

Commit 2819398

Browse files
authored
Merge pull request #1 from galaxie500/TimeSeriesScaleMeanMaxVariance
Add compile.py
2 parents e7eaea5 + 2b98526 commit 2819398

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ __pycache__/
1616
env/
1717
build/
1818
develop-eggs/
19-
dist/
19+
#dist/
2020
downloads/
2121
eggs/
2222
.eggs/
14.6 MB
Binary file not shown.

tslearn/compile.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# coding: utf-8
2+
import os
3+
import fnmatch
4+
import sysconfig
5+
from setuptools import setup, find_packages
6+
from setuptools.command.build_py import build_py as _build_py
7+
from Cython.Build import cythonize
8+
9+
EXCLUDE_FILES = [
10+
'tslearn/main.py'
11+
]
12+
13+
14+
def get_ext_paths(root_dir, exclude_files):
15+
"""get filepaths for compilation"""
16+
paths = []
17+
18+
for root, dirs, files in os.walk(root_dir):
19+
for filename in files:
20+
if os.path.splitext(filename)[1] != '.py':
21+
continue
22+
23+
file_path = os.path.join(root, filename)
24+
if file_path in exclude_files:
25+
continue
26+
27+
paths.append(file_path)
28+
return paths
29+
30+
31+
class build_py(_build_py):
32+
33+
def find_package_modules(self, package, package_dir):
34+
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
35+
modules = super().find_package_modules(package, package_dir)
36+
filtered_modules = []
37+
for (pkg, mod, filepath) in modules:
38+
if os.path.exists(filepath.replace('.py', ext_suffix)):
39+
continue
40+
filtered_modules.append((pkg, mod, filepath, ))
41+
return filtered_modules
42+
43+
44+
setup(
45+
name='tslearn',
46+
version='0.0.0',
47+
packages=find_packages(),
48+
ext_modules=cythonize(
49+
get_ext_paths('tslearn', EXCLUDE_FILES),
50+
compiler_directives={'language_level': 3}
51+
),
52+
cmdclass={
53+
'build_py':build_py
54+
}
55+
)
56+
57+
# to compile working directory to wheel
58+
#$ python setup.py bdist_wheel
59+
#$ unzip tslearn-0.0.0-cp38-cp38-linux_x86_64.whl

0 commit comments

Comments
 (0)