Skip to content

spack.repo.PATH: fix lazy constructor#50777

Merged
tgamblin merged 1 commit intodevelopfrom
hs/fix/repo-constructor
Jun 3, 2025
Merged

spack.repo.PATH: fix lazy constructor#50777
tgamblin merged 1 commit intodevelopfrom
hs/fix/repo-constructor

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Jun 3, 2025

Fixes two regressions introduced in #50650.

Regression 1

spack.repo.PATH is constructed either in spack.main or through a singleton in spack.repo. Those initialization functions were out of sync; the latter used a named constructor that was not updated as part of #50650. That broke Spack on macOS where sub-processes instantiate spack.repo.PATH with the singleton.

Now both spack.main and spack.repo use RepoPath.from_config consistently.

Regression 2

When spack.repo.PATH was instantiated from spack.main it no longer received overrides from packages.yaml config.


Additionally, allow Spack to be run without any package repo configured, this is at least useful this week.

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) labels Jun 3, 2025
@haampie haampie force-pushed the hs/fix/repo-constructor branch 2 times, most recently from 85c6c29 to 9738117 Compare June 3, 2025 16:28
spack.repo.PATH is constructed either in:

1. spack.main.setup_main_options (entrypoint of Spack)
2. or spack.repo.PATH.__getattr__ (singleton, in sub-processes that
   don't run main)

The latter was using an old named constructor of RepoPath, which had
regressed.
@haampie haampie force-pushed the hs/fix/repo-constructor branch from 9738117 to 44628bb Compare June 3, 2025 16:37
@haampie haampie requested a review from Copilot June 3, 2025 17:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses two regressions in repository construction by unifying the initialization of spack.repo.PATH using descriptors instead of legacy paths and by ensuring that package overrides from packages.yaml are properly applied.

  • Updates test cases to use RepoDescriptors instead of legacy path lists.
  • Replaces the use of from_paths with from_descriptors in RepoPath construction and adjusts related function signatures.
  • Revises command and repo modules to pass required parameters (cache and overrides) for repository construction.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/spack/spack/test/repo.py Updated tests to use descriptors and validate both Repo and RepoPath.
lib/spack/spack/test/cmd/repo.py Adjusted initialization and construction to pass cache and overrides.
lib/spack/spack/repo.py Replaced from_paths with from_descriptors and updated construct method signatures.
lib/spack/spack/main.py Simplified repo enabling by using RepoPath.from_config.
lib/spack/spack/cmd/repo.py Updated repo commands to supply required cache parameter in construct calls.
Comments suppressed due to low confidence (3)

lib/spack/spack/repo.py:671

  • Consider updating the docstring for 'from_descriptors' to clearly document the purpose and usage of the new 'fetch' and 'overrides' parameters, to help users transitioning from the deprecated 'from_paths'.
def from_descriptors(descriptors: "RepoDescriptors", cache: spack.util.file_cache.FileCache, overrides: Optional[Dict[str, Any]] = None) -> "RepoPath":

lib/spack/spack/test/repo.py:291

  • [nitpick] Consider splitting tests for 'Repo' and 'RepoPath' into separate test cases to isolate and more precisely diagnose any issues arising from the unified construction logic.
def test_all_package_names(self, mock_test_cache):

lib/spack/spack/test/cmd/repo.py:263

  • Ensure that all call sites for 'initialize' and 'construct' consistently pass a valid 'cache' instance, and consider adding inline comments or tests to verify that the new parameters are handled correctly across different repositories.
def initialize(self, fetch=True, git=None) -> None:

@haampie haampie added the hotfix label Jun 3, 2025
Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One change request, otherwise LGTM

Comment thread lib/spack/spack/repo.py
@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Jun 3, 2025

We agreed to restore unloadable repositories-as-errors in a later (but very soon) PR and to merge this for now.

@tgamblin tgamblin merged commit e5db72c into develop Jun 3, 2025
33 of 34 checks passed
@tgamblin tgamblin deleted the hs/fix/repo-constructor branch June 3, 2025 20:50
kshea21 pushed a commit to kshea21/spack that referenced this pull request Jun 18, 2025
spack.repo.PATH is constructed either in:

1. spack.main.setup_main_options (entrypoint of Spack)
2. or spack.repo.PATH.__getattr__ (singleton, in sub-processes that
   don't run main)

The latter was using an old named constructor of RepoPath, which had
regressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality hotfix stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants