-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.py
97 lines (90 loc) · 3.24 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import gzip
from importlib.machinery import SourceFileLoader
import os
from setuptools import setup, find_packages
import sys
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
model_dir = os.path.join("birdvoxdetect", "models")
model_names = [
"birdvoxdetect-v03_T-1800_trial-37_network_epoch-023",
"birdvoxdetect-v03_trial-12_network_epoch-068",
"birdvoxdetect_empty", # for unit tests
]
weight_files = ["birdvoxactivate.pkl"] + [
"{}.h5".format(model_name) for model_name in model_names
]
base_url = "https://github.com/BirdVox/birdvoxdetect/raw/models/"
if len(sys.argv) > 1 and sys.argv[1] == "sdist":
# exclude the weight files in sdist
weight_files = []
else:
if not os.path.exists(model_dir):
os.makedirs(model_dir)
for weight_file in weight_files:
weight_path = os.path.join(model_dir, weight_file)
if not os.path.isfile(weight_path):
compressed_file = weight_file + ".gz"
compressed_path = os.path.join(model_dir, compressed_file)
if not os.path.isfile(compressed_file):
print("Downloading weight file {} ...".format(compressed_file))
urlretrieve(base_url + compressed_file, compressed_path)
print("Decompressing ...")
with gzip.open(compressed_path, "rb") as source:
with open(weight_path, "wb") as target:
target.write(source.read())
print("Decompression complete")
os.remove(compressed_path)
print("Removing compressed file")
version = SourceFileLoader(
"birdvoxdetect.version", os.path.join("birdvoxdetect", "version.py")
).load_module()
with open("README.md") as file:
long_description = file.read()
setup(
name="birdvoxdetect",
version=version.version,
description="Bioacoustic monitoring of nocturnal bird migration",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/BirdVox/birdvoxdetect",
author="Vincent Lostanlen, Justin Salamon, Andrew Farnsworth, "
+ "Steve Kelling, and Juan Pablo Bello",
author_email="[email protected]",
packages=find_packages(),
entry_points={
"console_scripts": ["birdvoxdetect=birdvoxdetect.cli:main"],
},
license="MIT",
classifiers=[
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Topic :: Multimedia :: Sound/Audio :: Analysis",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
],
keywords="tfrecord",
project_urls={
"Source": "https://github.com/BirdVox/birdvoxdetect",
"Tracker": "https://github.com/BirdVox/birdvoxdetect/issues",
},
install_requires=[
"birdvoxclassify>=0.3",
"scikit-learn==0.21.2",
],
extras_require={
"docs": [
"sphinx==1.2.3", # autodoc was broken in 1.3.1
"sphinxcontrib-napoleon",
"sphinx_rtd_theme",
"numpydoc",
],
"tests": [],
},
package_data={
"birdvoxdetect": [os.path.join("models", fname) for fname in weight_files]
},
)