From b6f2ab71aebb294c4cd252f8a86094ec77818ca6 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 9 Dec 2025 18:29:04 +0100 Subject: [PATCH 1/3] Don't install test package This results in a top-level Python package called "test". As this isn't namespaced to easybuild it can cause issues with other Python packages and shouldn't be installed. --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 6cdff71f56..077c296708 100644 --- a/setup.py +++ b/setup.py @@ -77,7 +77,6 @@ def find_rel_test(): "easybuild.tools.module_naming_scheme", "easybuild.tools.package", "easybuild.tools.package.package_naming_scheme", "easybuild.tools.py2vs3", "easybuild.tools.repository", "easybuild.tools.tomllib", "easybuild.tools.tomllib.tomli", "easybuild.tools._toml_writer", - "test.framework", "test", ] # Verify the above list is complete, if setuptools is installed @@ -86,7 +85,7 @@ def find_rel_test(): except ImportError: pass else: - packages = set(setuptools.find_packages()) + packages = set(setuptools.find_packages(exclude=["test", "test.*"])) easybuild_packages_set = set(easybuild_packages) if easybuild_packages_set != packages: # Warning only From fa756c2d26eb89502699011f0605b7beca60479e Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 10 Dec 2025 09:03:12 +0100 Subject: [PATCH 2/3] Copy test folder before running test suite on CI When we no longer install the test package AND want to run outside the source tree (to test the installed easybuild package) we need to retrieve the test package first. --- .github/workflows/unit_tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index b4cd8ff4e6..2a177d321d 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -25,7 +25,7 @@ jobs: build: needs: setup runs-on: ${{matrix.os || 'ubuntu-24.04'}} - env: + env: JOB_OS: ${{matrix.os || 'ubuntu-24.04'}} strategy: matrix: @@ -193,6 +193,9 @@ jobs: # run tests *outside* of checked out easybuild-framework directory, # to ensure we're testing installed version (see previous step) cd $HOME + # Copy test folder first as that module is NOT installed. Could be run from source tree but we want to test the installed package + cp -r $GITHUB_WORKSPACE/test . + # initialize environment for modules tool if [ -f $HOME/moduleshome ]; then export MODULESHOME=$(cat $HOME/moduleshome); fi source $(cat $HOME/mod_init) From fd77d3560b14f50ce693744314d0fb2884614c73 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 10 Dec 2025 11:19:45 +0100 Subject: [PATCH 3/3] Adapt tests for running outside source dir We need to use `$PYTHONPATH` instead of `topdir` to include the framework package in the GC3Pie test. When testing copies of framework files we need to handle the case where some might not be available and try hard to find the source dir. --- test/framework/filetools.py | 44 +++++++++++++++++++++------------ test/framework/parallelbuild.py | 4 +-- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/test/framework/filetools.py b/test/framework/filetools.py index 8eb5f452cf..78868c970c 100644 --- a/test/framework/filetools.py +++ b/test/framework/filetools.py @@ -3657,32 +3657,44 @@ def test_copy_framework_files(self): topdir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) test_files = [ - os.path.join('easybuild', 'tools', 'filetools.py'), - os.path.join('test', 'framework', 'modules.py'), - os.path.join('test', 'framework', 'sandbox', 'sources', 'toy', 'toy-0.0.tar.gz'), + (topdir, os.path.join('test', 'framework', 'modules.py')), + (topdir, os.path.join('test', 'framework', 'sandbox', 'sources', 'toy', 'toy-0.0.tar.gz')), ] - expected_entries = ['easybuild', 'test'] + expected_entries = ['test'] # test/framework/modules.py is not new - expected_new = [True, False, True] + expected_new = [False, True] - # we include setup.py conditionally because it may not be there, + # CI might copy the test folder, so find source dir + possible_dirs = [topdir, + os.environ.get('GITHUB_WORKSPACE', ''), + # Fallback: If we are run from the source dir without being installed + os.getcwd(), + ] + os.environ.get('PYTHONPATH', '').split(':') # Or at least have it in PYTHONPATH + + # we include those conditionally because it may not be there, # for example when running the tests on an actual easybuild-framework instalation, # as opposed to when running from a repository checkout... # setup.py is an important test case, since it has no parent directory # (it's straight in the easybuild-framework directory) - setup_py = 'setup.py' - if os.path.exists(os.path.join(topdir, setup_py)): - test_files.append(os.path.join(setup_py)) - expected_entries.append(setup_py) - expected_new.append(True) + try: + srcdir = next(d for d in possible_dirs if os.path.basename(d) == 'easybuild-framework' and + os.path.exists(os.path.join(d, 'easybuild', 'framework'))) + except StopIteration: + print(f"Running on installation without source, skipping parts of the checks\nTried: {possible_dirs}") + else: + setup_py = 'setup.py' + filetools_py = os.path.join('easybuild', 'tools', 'filetools.py') + test_files.extend([(srcdir, setup_py), (srcdir, filetools_py)]) + expected_entries.extend([setup_py, 'easybuild']) + expected_new.extend([True, True]) # files being copied are expected to be in a directory named 'easybuild-framework', # so we need to make sure that's the case here as well (may not be in workspace dir on Travis from example) framework_dir = os.path.join(self.test_prefix, 'easybuild-framework') - for test_file in test_files: - ft.copy_file(os.path.join(topdir, test_file), os.path.join(framework_dir, test_file)) + for root, test_file in test_files: + ft.copy_file(os.path.join(root, test_file), os.path.join(framework_dir, test_file)) - test_paths = [os.path.join(framework_dir, f) for f in test_files] + test_paths = [os.path.join(framework_dir, f) for _root, f in test_files] res = ft.copy_framework_files(test_paths, target_dir) @@ -3690,8 +3702,8 @@ def test_copy_framework_files(self): self.assertEqual(sorted(res.keys()), ['new', 'paths_in_repo']) - for idx, test_file in enumerate(test_files): - orig_path = os.path.join(topdir, test_file) + for idx, (root, test_file) in enumerate(test_files): + orig_path = os.path.join(root, test_file) copied_path = os.path.join(target_dir, test_file) self.assertExists(copied_path) diff --git a/test/framework/parallelbuild.py b/test/framework/parallelbuild.py index 0c821dd882..c820e68047 100644 --- a/test/framework/parallelbuild.py +++ b/test/framework/parallelbuild.py @@ -261,9 +261,9 @@ def test_build_easyconfigs_in_parallel_gc3pie(self): ec_file = os.path.join(topdir, 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb') easyconfigs = process_easyconfig(ec_file) ordered_ecs = resolve_dependencies(easyconfigs, self.modtool) - topdir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) test_easyblocks_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sandbox') - cmd = "PYTHONPATH=%s:%s:$PYTHONPATH eb %%(spec)s -df" % (topdir, test_easyblocks_path) + pythonpath = ':'.join((os.environ.get('PYTHONPATH', ''), test_easyblocks_path)) + cmd = f"PYTHONPATH={pythonpath} eb %(spec)s -df" with self.mocked_stdout_stderr(): build_easyconfigs_in_parallel(cmd, ordered_ecs, prepare_first=False)