forked from thanethomson/statik
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup.py: Parse git+ links in requirements.txt
Fixes thanethomson#97
- Loading branch information
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
import os.path | ||
from setuptools import setup | ||
|
||
DEPENDENCY_LINKS = [] | ||
|
||
|
||
def read_file(filename): | ||
full_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), filename) | ||
|
@@ -17,6 +19,36 @@ def read_file(filename): | |
return lines | ||
|
||
|
||
def read_requirements(filename): | ||
""" | ||
Parse a requirements file. | ||
Accepts vcs+ links, and places the URL into | ||
`DEPENDENCY_LINKS`. | ||
:return: list of str for each package | ||
""" | ||
data = [] | ||
for line in read_file(filename): | ||
line = line.strip() | ||
if not line or line.startswith('#'): | ||
continue | ||
|
||
if '+' in line[:4]: | ||
repo_link, egg_name = line.split('#egg=') | ||
if not egg_name: | ||
raise ValueError('Unknown requirement: {0}' | ||
.format(line)) | ||
|
||
DEPENDENCY_LINKS.append(line) | ||
|
||
line = egg_name | ||
|
||
data.append(line) | ||
|
||
return data | ||
|
||
|
||
def get_version(): | ||
pattern = re.compile(r"__version__ = \"(?P<version>[0-9.a-zA-Z-]+)\"") | ||
for line in read_file(os.path.join("statik", "__init__.py")): | ||
|
@@ -26,6 +58,8 @@ def get_version(): | |
raise ValueError("Cannot extract version number for Statik") | ||
|
||
|
||
install_requires = read_requirements('requirements.txt') | ||
|
||
setup( | ||
name="statik", | ||
version=get_version(), | ||
|
@@ -34,7 +68,8 @@ def get_version(): | |
author="Thane Thomson", | ||
author_email="[email protected]", | ||
url="https://getstatik.com", | ||
install_requires=[r.strip() for r in read_file("requirements.txt") if len(r.strip()) > 0], | ||
install_requires=install_requires, | ||
dependency_links=DEPENDENCY_LINKS, | ||
entry_points={ | ||
'console_scripts': [ | ||
'statik = statik.cmdline:main', | ||
|