From f5b0ce7d21c7a820fcce2bb902467cf2700006bf Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Mon, 30 Mar 2026 18:40:54 +0200 Subject: [PATCH 1/2] Fix get_editable_install_dir for non-editable install --- mpas_analysis/__main__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mpas_analysis/__main__.py b/mpas_analysis/__main__.py index 155b5d824..1cd665b8d 100644 --- a/mpas_analysis/__main__.py +++ b/mpas_analysis/__main__.py @@ -943,6 +943,9 @@ def get_editable_install_dir(package_name): direct_url = Distribution.from_name(package_name).read_text( 'direct_url.json') + if direct_url is None: + return None + contents = json.loads(direct_url) pkg_is_editable = contents.get("dir_info", {}).get("editable", False) if pkg_is_editable and 'url' in contents: From a910bf71b9383fad233a8099dd8b1d69e4ab258f Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Mon, 30 Mar 2026 18:41:21 +0200 Subject: [PATCH 2/2] Add a unit test to make sure the fix works --- mpas_analysis/test/test_main.py | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 mpas_analysis/test/test_main.py diff --git a/mpas_analysis/test/test_main.py b/mpas_analysis/test/test_main.py new file mode 100644 index 000000000..5270ec47c --- /dev/null +++ b/mpas_analysis/test/test_main.py @@ -0,0 +1,36 @@ +# This software is open source software available under the BSD-3 license. +# +# Copyright (c) 2022 Triad National Security, LLC. All rights reserved. +# Copyright (c) 2022 Lawrence Livermore National Security, LLC. All rights +# reserved. +# Copyright (c) 2022 UT-Battelle, LLC. All rights reserved. +# +# Additional copyright and license information can be found in the LICENSE file +# distributed with this code, or at +# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE +""" +Regression tests for helpers in ``mpas_analysis.__main__``. +""" + +import os +from unittest.mock import Mock, patch + +from mpas_analysis.test import TestCase + + +# Importing mpas_analysis.__main__ triggers matplotlib imports in some test +# environments, so use a writable cache directory. +os.environ.setdefault('MPLCONFIGDIR', '/tmp/matplotlib') + +import mpas_analysis.__main__ as main + + +class TestMain(TestCase): + def test_get_editable_install_dir_without_direct_url(self): + distribution = Mock() + distribution.read_text.return_value = None + + with patch.object(main.Distribution, 'from_name', + return_value=distribution): + self.assertEqual(main.get_editable_install_dir('mpas_analysis'), + None)