Pkg.add with a URL

Is there some reason why we have to do

Pkg.add(PackageSpec(url="https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl"))

instead of

Pkg.add("https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl")

? Couldn’t this conversion happen inside add?

PackageSpec allows encapsulating more information i.e. branches, commits etc. I believe a method for just the link is too little and programatically is not a big deal adding the wrapper around.

We can do

]add https://github.com/PetrKryslUCSD/FinEtoolsHeatDiff.jl#master

Surely it wouldn’t be a big deal to do the parsing inside the add function?

Its an architectural choice … Modularity and flexibility are improved by keeping parsers outside the add; this allows for a multitude of pkg add formats (i.e. a complicated parser) while simplifying the add functions code (at least in theory :wink: ):

Examples

  pkg> add Example
  pkg> add Example@0.5
  pkg> add Example#master
  pkg> add Example#c37b675
  pkg> add https://github.com/JuliaLang/Example.jl#master
  pkg> add git@github.com:JuliaLang/Example.jl.git
  pkg> add Example=7876af07-990d-54b4-ab0e-23690620f79a

It would be a pretty big deal.

But with Add a more concise way to call the API functions by KristofferC · Pull Request #1358 · JuliaLang/Pkg.jl · GitHub you will (if we merge it) be able to write

Pkg.add(url = "http:...")

which is a bit more convenient.

6 Likes

I see. Fair enough. Thanks.