Is there concept of dev dependencies in Pkg?

Is there a good write up that explains things in decent detail you could recommend?

1 Like

How about the original source?
https://julialang.github.io/Pkg.jl/v1/

2 Likes

It doesn’t really outline workflow to use
would this still be recommended workflow Add package to `project.toml` when needed only for testing?

For developing a (new) package it does outline a workflow and recommends PkgTemplates.jl:
https://julialang.github.io/Pkg.jl/v1/creating-packages/

2 Likes

This one also looks quite good:
https://tlienart.github.io/pub/julia/dev-pkg.html

And if you like videos, @ChrisRackauckas explains it in quite some detail and length :wink:

4 Likes

Thank you @oheil for great pointers! diving in :slight_smile:

2 Likes

Not sure whether this is still relevant, but beware of the differences between Packages for Julia {1.0, 1.1} and Julia {1.3 and above}:

https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1

Enjoy! :slight_smile:

2 Likes

One surprising thing from the Developing Julia Packages video is advice to not include the
Manifest.toml to the git repo :thinking: Repeatable builds tends to be a pretty important issue and in pretty much every other ecosystem the advice is pretty much the opposite…

That is recommended for packages, so that they are tested with versions offered by the resolver in CI. For projects, of course include a manifest.

3 Likes

Cool thank you for clarification makes sense

According to Pkg.jl documentations, there seems to be a new version of doing dev dependencies for julia above 1.2:
Test-specific-dependencies-in-Julia-1.2-and-above
This seems only work for ] test command.
But by doing so, how can I have a dev environment which I can use interactively? I wish I can have a dev environment which has access to MyPackage and all test dependencies, that’s where you do the developing all the time right?

If I activate the MyPackage environment, I have no access to these test dependencies, but if I activate ./test environment, I don’t have access to MyPackage.
And it seems that adding test dependencies in [extras] and [targets] is ignored right now, if I do any Pkg operations, things in extras will be removed from MyPackages’s Manifest.toml. So I lost access to all of these test dependencies in MyPackage environment.

So what’s the right way of setting environment for developing with proper test dependencies?

I just found I have access to packages installed in global environment, should this be isolated by design?
Do people just install packages to global environment as dev dependencies when developing their package?

2 Likes

You can create a test Project.toml, you just need to remove Test from [targets]. See also Using test/Project.toml - #4 by peterlane