Skip to content

Commit

Permalink
feat: optional dependencies support for pip, pipenv and setuptools. (#…
Browse files Browse the repository at this point in the history
…234)

* feat: add suport for optional dependencies

* feat: added tests for optional dependencies

* feat: addres PR comments
  • Loading branch information
MarcusArdelean authored Feb 26, 2024
1 parent d391221 commit e8a7063
Show file tree
Hide file tree
Showing 13 changed files with 1,140 additions and 85 deletions.
1 change: 1 addition & 0 deletions lib/dependencies/inspect-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function getMetaData(
// https://www.npmjs.com/package/pkg#detecting-assets-in-source-code
function createAssets() {
return [
path.join(__dirname, '../../pysrc/constants.py'),
path.join(__dirname, '../../pysrc/pip_resolve.py'),
path.join(__dirname, '../../pysrc/distPackage.py'),
path.join(__dirname, '../../pysrc/package.py'),
Expand Down
25 changes: 25 additions & 0 deletions pysrc/constants.py
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
Loading

0 comments on commit e8a7063

Please sign in to comment.