Skip to content

Commit eb5d9ea

Browse files
committed
It makes BigBashView more resilient to Python updates.
1 parent 2ee7f3c commit eb5d9ea

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

bigbashview/usr/lib/bbv/bigbashview.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919

20+
import sys
21+
import glob
22+
23+
def _enable_python_version_fallback():
24+
"""
25+
Append site-packages from other python versions to sys.path
26+
to allow importing modules not yet available in the current version.
27+
"""
28+
# glob pattern for site-packages
29+
# We assume standard linux paths: /usr/lib/pythonX.Y/site-packages
30+
paths = glob.glob('/usr/lib/python3.*/site-packages')
31+
32+
current_version_path = f"/usr/lib/python{sys.version_info.major}.{sys.version_info.minor}/site-packages"
33+
34+
for path in paths:
35+
if path == current_version_path:
36+
continue
37+
38+
if path not in sys.path:
39+
# Append to end of path to use as fallback
40+
sys.path.append(path)
41+
42+
_enable_python_version_fallback()
43+
2044
from bbv.main import Main
2145

2246
if __name__ == "__main__":

0 commit comments

Comments
 (0)