Skip to content

Commit d061303

Browse files
committed
Fix dependencies of package
1 parent 2d4839e commit d061303

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

setup.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
from setuptools import setup, find_packages
22
import ucoinpy
3+
import os
4+
import re
35

6+
def which(program):
7+
"""
8+
Detect whether or not a program is installed.
9+
Thanks to http://stackoverflow.com/a/377028/70191
10+
"""
11+
def is_exe(fpath):
12+
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
13+
14+
fpath, _ = os.path.split(program)
15+
if fpath:
16+
if is_exe(program):
17+
return program
18+
else:
19+
for path in os.environ['PATH'].split(os.pathsep):
20+
exe_file = os.path.join(path, program)
21+
if is_exe(exe_file):
22+
return exe_file
23+
24+
return None
25+
26+
EDITABLE_REQUIREMENT = re.compile(r'^-e (?P<link>(?P<vcs>git|svn|hg|bzr).+#egg=(?P<package>.+)-(?P<version>\d(?:\.\d)*))$')
27+
28+
install_requires = []
29+
dependency_links = []
30+
31+
for requirement in (l.strip() for l in open('requirements.txt')):
32+
match = EDITABLE_REQUIREMENT.match(requirement)
33+
if match:
34+
assert which(match.group('vcs')) is not None, \
35+
"VCS '%(vcs)s' must be installed in order to install %(link)s" % match.groupdict()
36+
install_requires.append("%(package)s==%(version)s" % match.groupdict())
37+
dependency_links.append(match.group('link'))
38+
else:
39+
install_requires.append(requirement)
40+
441
setup(
542
name='ucoinpy',
643

@@ -15,7 +52,7 @@
1552
description="A python implementation of [uCoin](https://github.com/ucoin-io/ucoin) API",
1653

1754
long_description=open('README.md').read(),
18-
55+
1956
# Active la prise en compte du fichier MANIFEST.in
2057
include_package_data=True,
2158
url='https://github.com/ucoin-io/ucoin-python-api',
@@ -30,6 +67,8 @@
3067
"Programming Language :: Python :: 3.4",
3168
"Topic :: Communications",
3269
],
70+
install_requires=install_requires,
71+
dependency_links=dependency_links
3372

3473

3574
)

0 commit comments

Comments
 (0)