Skip to content

Commit

Permalink
Added install_requires to setup.py log2timeline#515 (log2timeline#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Aug 21, 2021
1 parent 7f0cfb4 commit 9b4ab35
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include ACKNOWLEDGEMENTS AUTHORS LICENSE README
include dependencies.ini run_tests.py utils/__init__.py utils/dependencies.py
include utils/check_dependencies.py
include requirements.txt test_requirements.txt
exclude .gitignore
exclude *.pyc
recursive-include config *
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.test_data.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include ACKNOWLEDGEMENTS AUTHORS LICENSE README
include dependencies.ini run_tests.py utils/__init__.py utils/dependencies.py
include utils/check_dependencies.py
include requirements.txt test_requirements.txt
exclude .gitignore
exclude *.pyc
recursive-include config *
Expand Down
27 changes: 27 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
"""Installation and deployment script."""

import pkg_resources
import sys

try:
Expand Down Expand Up @@ -156,6 +157,30 @@ def _make_spec_file(self):
return python_spec_file


def parse_requirements_from_file(path):
"""Parses requirements from a requirements file.
Args:
path (str): path to the requirements file.
Yields:
str: name and optional version information of the required package.
"""
with open(path, 'r') as file_object:
file_contents = file_object.read()

for requirement in pkg_resources.parse_requirements(file_contents):
try:
name = str(requirement.req)
except AttributeError:
name = str(requirement)

if name.startswith('pip '):
continue

yield name


dfvfs_description = (
'Digital Forensics Virtual File System (dfVFS).')

Expand Down Expand Up @@ -200,4 +225,6 @@ def _make_spec_file(self):
('share/doc/dfvfs', [
'ACKNOWLEDGEMENTS', 'AUTHORS', 'LICENSE', 'README']),
],
install_requires=parse_requirements_from_file('requirements.txt'),
tests_require=parse_requirements_from_file('test_requirements.txt'),
)

0 comments on commit 9b4ab35

Please sign in to comment.