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

DM-33934: Add option to include all EUPS packages in report #117

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/DM-33934.api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add parameter to `~lsst.utils.packages.getEnvironmentPackages` to return all EUPS packages rather than just those that are locally setup.
15 changes: 13 additions & 2 deletions python/lsst/utils/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,16 @@ def getPythonPackages() -> Dict[str, str]:


@lru_cache(maxsize=1)
def getEnvironmentPackages() -> Dict[str, str]:
def getEnvironmentPackages(include_all: bool = False) -> Dict[str, str]:
"""Get products and their versions from the environment.

Parameters
----------
include_all : `bool`
If `False` only returns locally-setup packages. If `True` all set
up packages are returned with a version that includes any associated
non-current tags.

Returns
-------
packages : `dict`
Expand All @@ -165,7 +172,7 @@ def getEnvironmentPackages() -> Dict[str, str]:
We use EUPS to determine the version of certain products (those that don't
provide a means to determine the version any other way) and to check if
uninstalled packages are being used. We only report the product/version
for these packages.
for these packages unless ``include_all`` is `True`.
"""
try:
from eups import Eups
Expand Down Expand Up @@ -193,6 +200,10 @@ def getEnvironmentPackages() -> Dict[str, str]:
# is clean).
for prod in products:
if not prod.version.startswith(Product.LocalVersionPrefix):
if include_all:
tags = {t for t in prod.tags if t != "current"}
tag_msg = " (" + " ".join(tags) + ")" if tags else ""
packages[prod.name] = prod.version + tag_msg
continue
ver = prod.version

Expand Down