Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional changes to setup.py to support older versions of setuptools #1225

Merged
merged 1 commit into from
May 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import os
import sys

from pkg_resources import parse_requirements
import pkg_resources

from setuptools import find_packages
from setuptools import setup

Expand All @@ -38,6 +39,25 @@
sys.exit(1)


def parse_requirements_from_file(path):
"""Parses requirements from a requirements file.

Args:
path (str): path to the requirements file.

Yields:
pkg_resources.Requirement: package resource requirement.
"""
with open(path, 'r') as file_object:
file_contents = file_object.read()
for req in pkg_resources.parse_requirements(file_contents):
try:
requirement = str(req.req)
except AttributeError:
requirement = str(req)
yield requirement


timesketch_version = '20200507'

timesketch_description = (
Expand Down Expand Up @@ -73,10 +93,6 @@
include_package_data=True,
zip_safe=False,
entry_points={'console_scripts': ['tsctl=timesketch.tsctl:main']},
install_requires=[str(req.req) for req in parse_requirements(
'requirements.txt',
)],
tests_require=[str(req.req) for req in parse_requirements(
'test_requirements.txt',
)],
install_requires=parse_requirements_from_file('requirements.txt'),
tests_require=parse_requirements_from_file('test_requirements.txt'),
)