forked from bcgov/namex
/
setup.py
73 lines (61 loc) · 1.67 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
from setuptools import setup
import os
## from namex.VERSION import __version__
def is_package(path):
return (
os.path.isdir(path) and
os.path.isfile(os.path.join(path, '__init__.py'))
)
def find_packages(path, base=""):
""" Find all packages in path """
packages = {}
for item in os.listdir(path):
dir = os.path.join(path, item)
if is_package(dir):
if base:
module_name = "%(base)s.%(item)s" % vars()
else:
module_name = item
packages[module_name] = dir
packages.update(find_packages(dir, module_name))
return packages
def read_requirements(filename):
"""
Get application requirements from
the requirements.txt file.
:return: Python requirements
:rtype: list
"""
with open(filename, 'r') as req:
requirements = req.readlines()
install_requires = [r.strip() for r in requirements if r.find('git+') != 0]
return install_requires
def read(filepath):
"""
Read the contents from a file.
:param str filepath: path to the file to be read
:return: file contents
:rtype: str
"""
with open(filepath, 'r') as f:
content = f.read()
return content
packages = find_packages(".")
REQUIREMENTS = read_requirements('requirements.txt')
setup(
name='namex',
version='0.1.1b',
packages=packages.keys(),
package_dir=packages,
include_package_data=True,
license=read('LICENSE'),
long_description=read('README.md'),
install_requires=REQUIREMENTS,
setup_requires=[
'pytest-runner',
],
tests_require=[
'pytest',
'pytest-mock'
],
)