-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
executable file
·94 lines (73 loc) · 2.23 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
#! /usr/bin/env python
import os
import re
import site
import sys
from distutils import sysconfig
from setuptools import find_packages, setup
SKIP_REQUIREMENT = (
"git+",
)
def is_venv():
real, base = map(lambda arg: hasattr(sys, arg),
["real_prefix", "base_prefix"])
return real or base and base != sys.prefix
def get_site():
func = getattr(site, "getsitepackages", None)
if func:
return func()[0]
return sysconfig.get_python_lib()
def read(fpath):
check = os.path.isfile
path = os.path.join(os.path.dirname(__file__), fpath)
if not check(path):
path = fpath
if not check(path):
return None
with open(path) as stream:
return stream.read()
def skip_requirement(line):
for skip in SKIP_REQUIREMENT:
if skip in line:
return True
return False
def get_requirements(path="requirements.txt"):
data = read(path)
lines = []
if not data:
return lines
for line in data.splitlines():
line = line.strip()
if not line or line.startswith("#") or skip_requirement(line):
continue
if line.startswith("-r"):
new_path = line[2:].strip()
lines.extend(get_requirements(path=new_path))
continue
lines.append(line)
return lines
def get_data_files(source, files, use_source=False):
destination = (source if use_source else
os.path.join(get_site(), source))
paths = [os.path.join(source, name) for name in files]
return destination, paths
UNIX = bool(re.search(r"linux|darwin", sys.platform))
VENV = is_venv()
PIP = "--single-version-externally-managed" in sys.argv
LOCAL = PIP and any(map(lambda arg: arg.startswith("--home"), sys.argv))
USE_SOURCE = not UNIX or LOCAL or (VENV and not PIP)
setup(
name="morseus",
version="0.5.2",
description="Morse signals translator.",
long_description=read("README.md") or "",
url="https://github.com/cmin764/morseus",
license="MIT",
author="Cosmin Poieana",
author_email="[email protected]",
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=get_requirements(),
test_suite="tests",
)