Skip to content

Commit 1fb3ba6

Browse files
committed
refactor build process
1 parent b2b9522 commit 1fb3ba6

File tree

5 files changed

+16
-190
lines changed

5 files changed

+16
-190
lines changed

MANIFEST.in

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
recursive-include ./anomaly-detector/*.pyx
2-
recursive-include ./anomaly-detector/*.c
3-
recursive-include ./anomaly-detector/*.h
4-
recursive-include ./anomaly-detector/*.py
5-
recursive-include ./anomaly-detector/*.txt
6-
recursive-include ./anomaly-detector/anomaly_detector/univariate *
7-
include ./README.md
8-
include ./LICENSE
9-
include ./requirements.txt
10-
include ./setup.py
1+
recursive-include ./src/anomaly_detector/univariate *

README.md

+3-15
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,18 @@ Tested on
1111
## Installing from pip
1212

1313
```bash
14-
# install dependencies
15-
pip install numpy>=1.23.5 Cython
16-
17-
# then install time-series-anomaly-detector
18-
pip install time-series-anomaly-detector
14+
# install time-series-anomaly-detector
15+
pip install time-series-anomaly-detector==0.2.2
1916
```
2017

2118
## Installing from Source
2219
<!-- ## Clone the Repository -->
2320

2421
```bash
2522
git clone https://github.com/microsoft/anomaly-detector.git
26-
cd anomaly-detector
23+
pip install -e .
2724
```
2825

29-
<!-- ## Install -->
30-
31-
32-
```bash
33-
pip install -r requirements.txt
34-
python setup.py sdist bdist_wheel
35-
pip install ./dist/*.whl
36-
```
37-
3826
## Test
3927

4028
```bash

setup.py

+9-101
Original file line numberDiff line numberDiff line change
@@ -2,108 +2,16 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44

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
117

128
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")
769
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-
author_email="[email protected]",
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+
]
10917
)

src/build.py

-63
This file was deleted.

tests/uvad_test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def call_last(content):
8585

8686
return True, "Success"
8787

88+
8889
class TestFunctional(unittest.TestCase):
8990
def setUp(self):
9091
self.verificationErrors = []
@@ -118,5 +119,6 @@ def test_functional(self):
118119
except Exception as e:
119120
self.verificationErrors.append(f"{case} {ret[1]} {str(e)}")
120121

122+
121123
if __name__ == '__main__':
122-
unittest.main()
124+
unittest.main()

0 commit comments

Comments
 (0)