-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
62 lines (56 loc) · 2.42 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
# Try to import setuptools (if it fails, the user needs that package)
try:
from setuptools import setup, find_packages
except:
# Custom error (in case user does not have setuptools)
class DependencyError(Exception): pass
raise(DependencyError("Missing python package 'setuptools'.\n pip install --user setuptools"))
import os
# Convenience function for reading information files
def read(f_name, empty_lines=False):
text = []
with open(os.path.join(package_about, f_name)) as f:
for line in f:
line = line.strip("\n")
if (not empty_lines) and (len(line.strip()) == 0): continue
if (len(line) > 0) and (line[0] == "%"): continue
text.append(line)
return text
# Go to the "about" directory in the package directory.
package_about = ""
package_name = read("package_name.txt")[0]
package_about = os.path.join(os.path.dirname(os.path.abspath(__file__)),package_name,"about")
if __name__ == "__main__":
# Read in the package description files
# ===============================================
package = package_name
version =read("version.txt")[0]
description = read("description.txt")[0]
requirements = read("requirements.txt")
keywords = read("keywords.txt")
classifiers = read("classifiers.txt")
name, email, git_username = read("author.txt")
# Translate the git requirements to proper requirements.
dependency_links = [r for r in requirements if "github.com" in r]
for r in dependency_links:
try: pkg_name = r.split("egg=")[1]
except: raise(DependencyError("GitHub repositories must specify '#egg=<package-name>' at the end."))
requirements[requirements.index(r)] = pkg_name + " @ git+https://" + r.split("://")[1]
setup(
author = name,
author_email = email,
name=package,
packages=find_packages(exclude=[]),
include_package_data=True,
install_requires=requirements,
version=version,
url = 'https://github.com/{git_username}/{package}'.format(
git_username=git_username, package=package),
download_url = 'https://github.com/{git_username}/{package}/archive/{version}.tar.gz'.format(
git_username=git_username, package=package, version=version),
description = description,
keywords = keywords,
python_requires = '>=3.6',
license='MIT',
classifiers=classifiers
)