Skip to content

Commit

Permalink
setup.py: Parse git+ links in requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Dec 5, 2018
1 parent 52e0da5 commit 7256e56
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ SQLAlchemy==1.2.12
Unidecode==1.0.22
watchdog==0.9.0
paramiko==2.4.2
git+https://github.com/kx-chen/netlify_deployer.git
git+https://github.com/kx-chen/netlify_deployer.git#egg=netlify_uploader
37 changes: 36 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")):
Expand All @@ -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(),
Expand All @@ -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',
Expand Down

0 comments on commit 7256e56

Please sign in to comment.