Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pkg.jl and CompatHelper.jl write [sources] section differently on v1.11 #504

Open
agdestein opened this issue Sep 10, 2024 · 0 comments
Open

Comments

@agdestein
Copy link

agdestein commented Sep 10, 2024

On Julia v1.11, the following code

using Pkg

showtoml(project) = println(read(joinpath(project, "Project.toml"), String))

project = "project"
mkdir(project)
Pkg.activate(project)
Pkg.add("CompatHelper")

# Create two packages and `dev` them to get the UUIDs
Pkg.generate(joinpath(project, "SomePackage"))
Pkg.generate(joinpath(project, "AnotherPackage"))
Pkg.develop([
    PackageSpec(; path = joinpath(project, "SomePackage")),
    PackageSpec(; path = joinpath(project, "AnotherPackage")),
])

showtoml(project)

creates an environment with this Project.toml:

[deps]
AnotherPackage = "70b51dde-ff63-4d56-bd06-f5c077573a96"
CompatHelper = "aa819f21-2bde-4658-8897-bab36330d9b7"
SomePackage = "3c4efd53-1385-4fe4-b6f1-2e1dbb823624"

Julia v1.11 allows for manually adding a [sources] section to automate the Pkg.develop part, which is useful for monorepos:

open(joinpath(project, "Project.toml"), "a") do io
    println(io)
    println(io, "[sources]")
    println(io, "SomePackage = {path = \"SomePackage\"}")
    println(io, "AnotherPackage = {path = \"AnotherPackage\"}")
end
showtoml(project)
[deps]
AnotherPackage = "70b51dde-ff63-4d56-bd06-f5c077573a96"
CompatHelper = "aa819f21-2bde-4658-8897-bab36330d9b7"
SomePackage = "3c4efd53-1385-4fe4-b6f1-2e1dbb823624"

[sources]
SomePackage = {path = "SomePackage"}
AnotherPackage = {path = "AnotherPackage"}

CompatHelper.jl will split this into separate sections
(see e.g. this PR)

using CompatHelper

# I think CompatHelper.main() is doing something like this
CompatHelper.modify_project_toml("SomePackage", project, "0.1", false)
showtoml(project)
[deps]
AnotherPackage = "30d7d2c7-f9c0-4ce7-8ffa-160e2f9efd03"
CompatHelper = "aa819f21-2bde-4658-8897-bab36330d9b7"
SomePackage = "e796d48f-4455-4818-ba38-a7fd70694e68"

[sources.AnotherPackage]
path = "AnotherPackage"

[sources.SomePackage]
path = "SomePackage"

[compat]
SomePackage = "0.1"

On the other hand, doing Pkg.jl operations takes it back:

Pkg.add("LinearAlgebra")
showtoml(project)
[deps]
AnotherPackage = "30d7d2c7-f9c0-4ce7-8ffa-160e2f9efd03"
CompatHelper = "aa819f21-2bde-4658-8897-bab36330d9b7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SomePackage = "e796d48f-4455-4818-ba38-a7fd70694e68"

[sources]
AnotherPackage = {path = "AnotherPackage"}
SomePackage = {path = "SomePackage"}

[compat]
SomePackage = "0.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant