Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.misc.package: Do not fail if SAGE_PKGS, SAGE_SPKG_INST do not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jun 22, 2020
1 parent 89988cf commit 2664865
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/sage/misc/package.py
Expand Up @@ -234,9 +234,17 @@ def list_packages(*pkg_types, **opts):

installed = installed_packages(exclude_pip)

pkgs = {}
SAGE_PKGS = sage.env.SAGE_PKGS
for p in os.listdir(SAGE_PKGS):
if not SAGE_PKGS:
return {}

try:
lp = os.listdir(SAGE_PKGS)
except FileNotFoundError:
return {}

pkgs = {}
for p in lp:
try:
f = open(os.path.join(SAGE_PKGS, p, "type"))
except IOError:
Expand Down Expand Up @@ -310,8 +318,13 @@ def installed_packages(exclude_pip=True):
if not exclude_pip:
installed.update(pip_installed_packages())
# Sage packages should override pip packages (Trac #23997)
installed.update(pkgname_split(pkgname)
for pkgname in os.listdir(sage.env.SAGE_SPKG_INST))
SAGE_SPKG_INST = sage.env.SAGE_SPKG_INST
if SAGE_SPKG_INST:
try:
lp = os.listdir(SAGE_SPKG_INST)
installed.update(pkgname_split(pkgname) for pkgname in lp)
except FileNotFoundError:
pass
return installed


Expand Down

0 comments on commit 2664865

Please sign in to comment.