-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
115 lines (103 loc) · 3.69 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# -*- coding=utf-8 -*-
import sys
import os
import logging
import setuptools
long_description = ""
with open("README.md", "r") as fd:
for line in fd:
# remove github badges
if not line.startswith("[!["):
long_description += line
def package_to_path(package):
"""
Convert a package (as found by setuptools.find_packages)
e.g. "foo.bar" to usable path
e.g. "foo/bar"
No idea if this works on windows
"""
return package.replace('.', '/')
def find_subdirectories(package):
"""
Get the subdirectories within a package
This will include resources (non-submodules) and submodules
"""
try:
subdirectories = next(os.walk(package_to_path(package)))[1]
except StopIteration:
subdirectories = []
return subdirectories
def subdir_findall(dir, subdir):
"""
Find all files in a subdirectory and return paths relative to dir
This is similar to (and uses) setuptools.findall
However, the paths returned are in the form needed for package_data
"""
strip_n = len(dir.split('/'))
path = '/'.join((dir, subdir))
return ['/'.join(s.split('/')[strip_n:]) for s in setuptools.findall(path)]
def find_package_data(packages):
"""
For a list of packages, find the package_data
This function scans the subdirectories of a package and considers all
non-submodule subdirectories as resources, including them in
the package_data
Returns a dictionary suitable for setup(package_data=<result>)
"""
skip_tests = True
package_data = {}
for package in packages:
package_data[package] = []
for subdir in find_subdirectories(package):
if '.'.join((package, subdir)) in packages: # skip submodules
logging.debug("skipping submodule %s/%s" % (package, subdir))
continue
if skip_tests and (subdir == 'tests'): # skip tests
logging.debug("skipping tests %s/%s" % (package, subdir))
continue
package_data[package] += subdir_findall(package_to_path(package), subdir)
return package_data
# ----------- Override defaults here ----------------
packages = None
package_name = None
package_data = None
if packages is None:
packages = setuptools.find_packages()
if len(packages) == 0:
raise Exception("No valid packages found")
if package_name is None:
package_name = packages[0]
if package_data is None:
package_data = find_package_data(packages)
setuptools.setup(
name="paddy",
long_description=long_description,
long_description_content_type="text/markdown",
version="0.2.3",
author="Armen Beck",
author_email="[email protected]",
description="Optimize hyperparameters using the Paddy field algorithm",
keywords="paddyfield optimization hyperparameter model selection",
url="http://github.com/chopralab/paddy",
packages=packages,
zip_safe=False,
install_requires=['scipy', 'future', 'numpy', 'matplotlib'],
tests_require=['pandas'],
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
"Topic :: Software Development",
]
)