diff --git a/cyclonedx_py/_internal/environment.py b/cyclonedx_py/_internal/environment.py index 62af2d8d..81a5e64d 100644 --- a/cyclonedx_py/_internal/environment.py +++ b/cyclonedx_py/_internal/environment.py @@ -58,60 +58,61 @@ class EnvironmentBB(BomBuilder): @staticmethod def make_argument_parser(**kwargs: Any) -> 'ArgumentParser': - p = ArgumentParser(description='Build an SBOM from Python (virtual) environment', - **kwargs) + p = ArgumentParser( + description='Build an SBOM from Python (virtual) environment', + **kwargs) if os_name == 'nt': p.epilog = dedent("""\ Example Usage: • Build an SBOM from python environment: - > %(prog)s + > %(prog)s • Build an SBOM from a Python (virtual) environment: - > %(prog)s "...\\some\\path\\bin\\python.exe" - > %(prog)s "...\\some\\path\\.venv" - > %(prog)s "$env:VIRTUAL_ENV" - > %(prog)s %%VIRTUAL_ENV%% + > %(prog)s "...\\some\\path\\bin\\python.exe" + > %(prog)s "...\\some\\path\\.venv" + > %(prog)s "$env:VIRTUAL_ENV" + > %(prog)s %%VIRTUAL_ENV%% • Build an SBOM from specific Python environment: - > where.exe python3.9.exe - > %(prog)s "%%path-to-specific-python%%" + > where.exe python3.9.exe + > %(prog)s "%%path-to-specific-python%%" • Build an SBOM from conda Python environment: - > conda.exe run where.exe python - > %(prog)s "%%path-to-conda-python%%" + > conda.exe run where.exe python + > %(prog)s "%%path-to-conda-python%%" • Build an SBOM from Pipenv environment: - > pipenv.exe --py - > pipenv.exe --venv - > %(prog)s "%%path-to-pipenv-python%%" + > pipenv.exe --py + > pipenv.exe --venv + > %(prog)s "%%path-to-pipenv-python%%" • Build an SBOM from Poetry environment: - > poetry.exe env info --executable - > %(prog)s "%%path-to-poetry-python%%" + > poetry.exe env info --executable + > %(prog)s "%%path-to-poetry-python%%" • Build an SBOM from PDM environment: - > pdm.exe info --python - > %(prog)s "%%path-to-pdm-python%%" + > pdm.exe info --python + > %(prog)s "%%path-to-pdm-python%%" • Build an SBOM from uv environment: - > uv.exe python find - > %(prog)s "%%path-to-uv-python%%" + > uv.exe python find + > %(prog)s "%%path-to-uv-python%%" """) else: # if os_name == 'posix': p.epilog = dedent("""\ Example Usage: • Build an SBOM from python environment: - $ %(prog)s + $ %(prog)s • Build an SBOM from a Python (virtual) environment: - $ %(prog)s '.../some/path/bin/python' - $ %(prog)s '.../some/path/.venv' - $ %(prog)s "$VIRTUAL_ENV" + $ %(prog)s '.../some/path/bin/python' + $ %(prog)s '.../some/path/.venv' + $ %(prog)s "$VIRTUAL_ENV" • Build an SBOM from specific Python environment: - $ %(prog)s "$(which python3.9)" + $ %(prog)s "$(which python3.9)" • Build an SBOM from conda Python environment: - $ %(prog)s "$(conda run which python)" + $ %(prog)s "$(conda run which python)" • Build an SBOM from Pipenv environment: - $ %(prog)s "$(pipenv --py)" - $ %(prog)s "$(pipenv --venv)" + $ %(prog)s "$(pipenv --py)" + $ %(prog)s "$(pipenv --venv)" • Build an SBOM from Poetry environment: - $ %(prog)s "$(poetry env info --executable)" + $ %(prog)s "$(poetry env info --executable)" • Build an SBOM from PDM environment: - $ %(prog)s "$(pdm info --python)" + $ %(prog)s "$(pdm info --python)" • Build an SBOM from uv environment: - $ %(prog)s "$(uv python find)" + $ %(prog)s "$(uv python find)" """) p.add_argument('--PEP-639', action='store_true', diff --git a/cyclonedx_py/_internal/pipenv.py b/cyclonedx_py/_internal/pipenv.py index b740c8fc..6cbf1c56 100644 --- a/cyclonedx_py/_internal/pipenv.py +++ b/cyclonedx_py/_internal/pipenv.py @@ -50,12 +50,13 @@ class PipenvBB(BomBuilder): @staticmethod def make_argument_parser(**kwargs: Any) -> 'ArgumentParser': - p = ArgumentParser(description=dedent("""\ - Build an SBOM from Pipenv manifest. + p = ArgumentParser( + description=dedent("""\ + Build an SBOM from Pipenv manifest. - The options and switches mimic the respective ones from Pipenv CLI. - """), - **kwargs) + The options and switches mimic the respective ones from Pipenv CLI. + """), + **kwargs) # the options and switches SHALL mimic the ones from Pipenv # see also: https://pipenv.pypa.io/en/latest/configuration.html p.add_argument('--categories', diff --git a/cyclonedx_py/_internal/poetry.py b/cyclonedx_py/_internal/poetry.py index c6a5845b..d3eaa493 100644 --- a/cyclonedx_py/_internal/poetry.py +++ b/cyclonedx_py/_internal/poetry.py @@ -98,12 +98,13 @@ class PoetryBB(BomBuilder): @staticmethod def make_argument_parser(**kwargs: Any) -> 'ArgumentParser': - p = ArgumentParser(description=dedent("""\ - Build an SBOM from Poetry project. + p = ArgumentParser( + description=dedent("""\ + Build an SBOM from Poetry project. - The options and switches mimic the respective ones from Poetry CLI. - """), - **kwargs) + The options and switches mimic the respective ones from Poetry CLI. + """), + **kwargs) # the options and switches SHALL mimic the ones from Poetry, which uses comma-separated lists and multi-use p.add_argument('--without', metavar='', diff --git a/cyclonedx_py/_internal/requirements.py b/cyclonedx_py/_internal/requirements.py index dd2e5aff..0e770c9b 100644 --- a/cyclonedx_py/_internal/requirements.py +++ b/cyclonedx_py/_internal/requirements.py @@ -49,29 +49,30 @@ class RequirementsBB(BomBuilder): @staticmethod def make_argument_parser(**kwargs: Any) -> 'ArgumentParser': - p = ArgumentParser(description=dedent("""\ - Build an SBOM from Pip requirements. - - The options and switches mimic the respective ones from Pip CLI. - """), - epilog=dedent("""\ - Example Usage: - • Build an SBOM from a requirements file: - $ %(prog)s requirements-prod.txt - • Merge multiple files and build an SBOM from it: - $ cat requirements/*.txt | %(prog)s - - • Build an inventory for all installed packages: - $ python -m pip freeze --all | %(prog)s - - • Build an inventory for all installed packages in a conda environment: - $ conda run python -m pip freeze --all | %(prog)s - - • Build an inventory for installed packages in a Python (virtual) environment: - $ .../.venv/bin/python -m pip freeze --all --local --require-virtualenv |\\ - %(prog)s - - • Build an inventory from an unfrozen manifest: - $ python -m pip install -r dependencies.txt &&\\ - python -m pip freeze | %(prog)s - - """), - **kwargs) + p = ArgumentParser( + description=dedent("""\ + Build an SBOM from Pip requirements. + + The options and switches mimic the respective ones from Pip CLI. + """), + epilog=dedent("""\ + Example Usage: + • Build an SBOM from a requirements file: + $ %(prog)s requirements-prod.txt + • Merge multiple files and build an SBOM from it: + $ cat requirements/*.txt | %(prog)s - + • Build an inventory for all installed packages: + $ python -m pip freeze --all | %(prog)s - + • Build an inventory for all installed packages in a conda environment: + $ conda run python -m pip freeze --all | %(prog)s - + • Build an inventory for installed packages in a Python (virtual) environment: + $ .../.venv/bin/python -m pip freeze --all --local --require-virtualenv | \\ + %(prog)s - + • Build an inventory from an unfrozen manifest: + $ python -m pip install -r dependencies.txt && \\ + python -m pip freeze | %(prog)s - + """), + **kwargs) # the options and switches SHALL mimic the ones from Pip p.add_argument('-i', '--index-url', metavar='', diff --git a/docs/usage.rst b/docs/usage.rst index 516a3520..0c7e5c00 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -460,13 +460,13 @@ Example Usage .. code-block:: shell-session :caption: Build an inventory for installed packages in a Python (virtual) environment - $ .../.venv/bin/python -m pip freeze --all --local --require-virtualenv |\ + $ .../.venv/bin/python -m pip freeze --all --local --require-virtualenv | \ cyclonedx-py requirements - .. code-block:: shell-session :caption: Build an inventory from an unfrozen manifest - $ python -m pip install -r dependencies.txt &&\ + $ python -m pip install -r dependencies.txt && \ python -m pip freeze | cyclonedx-py requirements -