-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.py
99 lines (85 loc) · 3.27 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
from setuptools import setup, find_packages
SETUP_DIR = os.path.dirname(os.path.realpath(__file__))
EGG_RE = re.compile('#egg=([^#@\n]+)')
readme = open(os.path.join(SETUP_DIR, 'DESCRIPTION.rst')).read()
history = open(
os.path.join(
SETUP_DIR, 'HISTORY.rst')).read().replace('.. :changelog:', '')
def handle_requirement_line(line, requirements, dependency_links):
"""Add line to given requirements and dependency_links lists.
Parse a line from a requirements file, adding entries to the given
requirements or dependency_links lists if appropriate.
"""
line = line.strip()
if not line or line.startswith('#'):
pass
elif line.startswith('-e'):
# We parse these into two stanzas for setuptools.
# We place the requested egg in install_requires and
# place its URI in dependency_links.
dependency_link = line[len('-e'):].lstrip()
egg_search = EGG_RE.search(dependency_link)
if egg_search is None:
raise ValueError(
'dependency link %s has no #egg=<egg-name> part' %
dependency_link)
else:
requirements.append(egg_search.group(1))
dependency_links.append(dependency_link)
else:
requirements.append(line)
# NOTE: requirements retrieved from repos instead of PyPI will not be included
requirements = []
dependency_links = []
with open(os.path.join(SETUP_DIR, 'requirements.txt'), 'r') as file_:
for line in file_:
handle_requirement_line(line, requirements, dependency_links)
# NOTE: recommended to install these in your environment eg. via pip before
# running tests; else they may not be installed to a preferred location.
test_requirements = []
if os.path.isfile('test_requirements.txt'):
with open(os.path.join(SETUP_DIR, 'test_requirements.txt'), 'r') as file_:
for line in file_:
handle_requirement_line(line, test_requirements, dependency_links)
def recurse_data_files(path):
"""Return a list of files for given path.
:param str path: Directory path
:returns: All file paths in given path
:rtype: list
"""
matches = []
for root, dirnames, filenames in os.walk(path):
matches.append(root + '/*')
return matches
setup(
name='datagrid_gtk3',
version='0.1.5',
license='MIT',
description='MVC framework for working with the GTK3 TreeView widget.',
long_description=readme + '\n\n' + history,
author='NowSecure',
author_email='[email protected]',
url='https://github.com/nowsecure/datagrid-gtk3',
packages=find_packages(),
package_dir={'datagrid_gtk3':
'datagrid_gtk3'},
package_data={'datagrid_gtk3': recurse_data_files('data')},
include_package_data=True,
# data_files=[('/destination/path', ['file1', file2']),]
# NOTE: ^^^ any files that need to be installed outside the pkg dir
# include_data_files=True,
install_requires=requirements,
dependency_links=dependency_links,
zip_safe=False,
keywords='mvc sqlite gtk gtk3 grid',
classifiers=[
'Natural Language :: English',
"Programming Language :: Python :: 2",
],
test_suite='datagrid_gtk3.tests',
tests_require=test_requirements
)