|
2 | 2 | # Copyright (c) Microsoft Corporation. All rights reserved.
|
3 | 3 | # ---------------------------------------------------------
|
4 | 4 |
|
5 |
| -import os |
6 |
| -from pathlib import Path |
7 |
| -from Cython.Build import cythonize |
8 |
| -from setuptools.command.sdist import sdist |
9 |
| -from setuptools import find_packages, setup, Extension |
10 |
| -import numpy |
| 5 | +from setuptools import setup, Extension |
| 6 | +import numpy as np |
11 | 7 |
|
12 | 8 | if __name__ == "__main__":
|
13 |
| - import os |
14 |
| - |
15 |
| - with Path(Path(__file__).parent, "README.md").open(encoding="utf-8") as file: |
16 |
| - long_description = file.read() |
17 |
| - |
18 |
| - def get_all_package_and_dir(directory): |
19 |
| - all_package = {} |
20 |
| - for path, _, filenames in os.walk(directory): |
21 |
| - if "__init__.py" in filenames and "test" not in path: |
22 |
| - path = "/".join(path.split("\\")) |
23 |
| - package_name = ".".join(path.split("/")[2::]) |
24 |
| - all_package[package_name] = path |
25 |
| - return all_package |
26 |
| - |
27 |
| - |
28 |
| - def package_files(directory): |
29 |
| - paths = [] |
30 |
| - for path, _, filenames in os.walk(directory): |
31 |
| - for filename in filenames: |
32 |
| - paths.append(os.path.join("..", path, filename)) |
33 |
| - return paths |
34 |
| - |
35 |
| - |
36 |
| - # extra_files = package_files("front/build") |
37 |
| - |
38 |
| - def _read_reqs(relpath): |
39 |
| - fullpath = os.path.join(os.path.dirname(__file__), relpath) |
40 |
| - with open(fullpath) as f: |
41 |
| - return [ |
42 |
| - s.strip() |
43 |
| - for s in f.readlines() |
44 |
| - if (s.strip() and not s.startswith("#")) |
45 |
| - ] |
46 |
| - |
47 |
| - try: |
48 |
| - REQUIREMENTS = _read_reqs("requirements.txt") |
49 |
| - except Exception: |
50 |
| - REQUIREMENTS = _read_reqs("anomaly_detector.egg-info/requires.txt") |
51 |
| - |
52 |
| - extensions = [ |
53 |
| - Extension("anomaly_detector.univariate._anomaly_kernel_cython", |
54 |
| - ["anomaly-detector/anomaly_detector/univariate/_anomaly_kernel_cython.c"] |
55 |
| - ) |
56 |
| - ] |
57 |
| - |
58 |
| - |
59 |
| - # cmdclass = {'build_ext': build_ext} |
60 |
| - # cmdclass.update({'build_ext': build_ext}) |
61 |
| - |
62 |
| - class CustomSdist(sdist): |
63 |
| - def run(self): |
64 |
| - # Run build_ext before sdist |
65 |
| - build_ext_cmd = self.get_finalized_command('build_ext') |
66 |
| - build_ext_cmd.inplace = 1 |
67 |
| - self.run_command('build_ext') |
68 |
| - |
69 |
| - # Use the standard behavior of sdist from the base class |
70 |
| - sdist.run(self) |
71 |
| - |
72 |
| - |
73 |
| - cmdclass = {'sdist': CustomSdist} |
74 |
| - |
75 |
| - all_package = get_all_package_and_dir("./anomaly-detector") |
76 | 9 | setup(
|
77 |
| - name="time-series-anomaly-detector", |
78 |
| - packages=list(all_package.keys()), |
79 |
| - package_dir=all_package, |
80 |
| - # ext_modules=cythonize(extensions), |
81 |
| - ext_modules=extensions, |
82 |
| - include_package_data=True, |
83 |
| - cmdclass=cmdclass, |
84 |
| - version="0.2.2", |
85 |
| - license="MIT", |
86 |
| - description="Time Series Anomaly Detection", |
87 |
| - long_description=long_description, |
88 |
| - long_description_content_type="text/markdown", |
89 |
| - author="Microsoft", |
90 |
| - |
91 |
| - url="https://github.com/microsoft/anomaly-detector", |
92 |
| - data_files=[ |
93 |
| - (".", ["README.md"]), |
94 |
| - ], |
95 |
| - keywords=["machine learning", "time series", "anomaly detection"], |
96 |
| - include_dirs=[numpy.get_include()], |
97 |
| - maintainer=["Anomaly Detector Open Source", "Microsoft"], |
98 |
| - python_requires='>=3.9.0', |
99 |
| - install_requires=REQUIREMENTS, |
100 |
| - classifiers=[ |
101 |
| - "Development Status :: 4 - Beta", |
102 |
| - "Intended Audience :: Developers", |
103 |
| - "Topic :: Scientific/Engineering :: Artificial Intelligence", |
104 |
| - "License :: OSI Approved :: MIT License", |
105 |
| - "Programming Language :: Python :: 3.9", |
106 |
| - "Programming Language :: Python :: 3.10", |
107 |
| - "Programming Language :: Python :: 3.11", |
108 |
| - ], |
| 10 | + include_dirs=[np.get_include()], |
| 11 | + ext_modules=[ |
| 12 | + Extension( |
| 13 | + "anomaly_detector.univariate._anomaly_kernel_cython", |
| 14 | + ["src/anomaly_detector/univariate/_anomaly_kernel_cython.c"], |
| 15 | + ) |
| 16 | + ] |
109 | 17 | )
|
0 commit comments