-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optional dependencies support for pip, pipenv and setuptools. (#…
…234) * feat: add suport for optional dependencies * feat: added tests for optional dependencies * feat: addres PR comments
- Loading branch information
1 parent
d391221
commit e8a7063
Showing
13 changed files
with
1,140 additions
and
85 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
from collections import namedtuple | ||
|
||
|
||
DepsManagerItem = namedtuple( | ||
'DepsManagerItem', ['package_manager', 'file'] | ||
) | ||
|
||
|
||
# TODO: When support for Python 2.7 - 3.3 will be removed, use Enums instead | ||
# of namedtuple, this is just a workaround to support Python2.7 syntax. | ||
class DepsManager: | ||
PIP = DepsManagerItem(package_manager="pip", file="requirements.txt") | ||
PIPENV = DepsManagerItem(package_manager="pipenv", file="Pipfile") | ||
SETUPTOOLS = DepsManagerItem(package_manager="setuptools", file="setup.py") | ||
|
||
@classmethod | ||
def discover(cls, requirements_file_path): | ||
"""Establishes the dependency manager based on the used files""" | ||
if os.path.basename(requirements_file_path) == 'Pipfile': | ||
return cls.PIPENV | ||
if os.path.basename(requirements_file_path) == 'setup.py': | ||
return cls.SETUPTOOLS | ||
|
||
return cls.PIP |
Oops, something went wrong.