Skip to content

Setting (and loading) preferences for "sub-packages" with shared Manifest #78

@NHDaly

Description

@NHDaly

At RelationalAI, we have organized our large mono-repo codebase using "sub-packages," a newly supported pattern in Pkg (since 1.9) where the codebase is split into several packages, and the top-level project dev's those subpackages.
In each subpackage, we set the manifest = field in that subpackage's Project.toml to point back to the parent Manifest, like manifest = "../../Manifest.toml".

The structure looks something like this:

Project.toml
Manifest.toml
src/
    - ...
test/
    - ...
packages/
    - PkgA/
        - Project.toml    # Links to the top-level manifest via `manifest = "../../Manifest.toml"`
        - src/
        - test/

This has worked quite well for us! If you have the top-level project activated, you can run Pkg.test("PkgA") to test the subpackage. If you are developing on that package, you can have either the top-level or the sub-package activated and using PkgA works as expected. If you want to change dependencies, you can ]activate packages/PkgA, then ]add dep or whatever, and the dependencies are instantiated in the top-level shared Manifest.

But we're starting to use Preferences.jl a bit, and we're seeing some issues. If you create a LocalPreferences.toml file in the top-level package, then the preferences are picked up by using PkgA. But if you run Pkg.test("PkgA"), or ReTestItems.runtests("packages/PkgA"), the preferences are not picked up. If you put the LocalPreferences file only in the package itself, it works for testing, but they aren't picked up for normal development.


I would like to propose teaching Preferences.jl (or is it Base.get_preferences()?) to automatically look for the preferences file next to the activate Manifest.toml, not just next to the current Project.toml.

This would make Preferences work well with this "sub-packages" pattern, much like the rest of Pkg has been made to work.

Does that seem acceptable to you all?
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions