Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ before_script:
branches:
only:
- master
- staging
- trying
- /^release-.*/
- /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags

stages:
- name: test
# test only on bors trying and bors staging, and run master with linux/nightly for coverage
if: branch IN (trying, staging) OR (branch = master AND os = linux AND env(TRAVIS_JULIA_VERSION) = nightly)
- name: docs
# build docs on bors trying, bors staging, master and for tags
if: branch IN (trying, staging) OR (branch = master AND type = push) OR tag IS present
# build docs on master and for tags
if: (branch = master AND type = push) OR tag IS present

script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
Expand All @@ -45,10 +42,10 @@ jobs:
- julia --project -e 'using Pkg; Pkg.activate("docs"); Pkg.instantiate(); Pkg.develop(PackageSpec(path = pwd()))'
- julia --project=docs --color=yes docs/make.jl pdf
after_success: skip
- name: TOML (Julia 1.0)
- name: TOML (Julia 1.3)
stage: test
os: linux
julia: 1.0
julia: 1.3
script:
- julia --project=ext/TOML -e 'using Pkg; Pkg.test()'
after_success: skip
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ platform:

branches:
only:
- staging
- trying
- master
- /^release-.*/
- /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags

notifications:
Expand Down
10 changes: 8 additions & 2 deletions docs/src/basedocs.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
```@meta
EditURL = "https://github.com/JuliaLang/Pkg.jl/blob/master/docs/src/basedocs.md"
```

# Pkg

Pkg is Julia's builtin package manager, and handles operations
such as installing, updating and removing packages.

!!! note
What follows is a very brief introduction to Pkg. It is highly
recommended to read the full manual, which is available here:
What follows is a very brief introduction to Pkg. For more
information on `Project.toml` files, `Manifest.toml` files, package
version compatibility (`[compat]`), environments, registries, etc.,
it is highly recommended to read the full manual, which is available here:
[https://julialang.github.io/Pkg.jl/v1/](https://julialang.github.io/Pkg.jl/v1/).

```@eval
Expand Down
26 changes: 23 additions & 3 deletions docs/src/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ Example = "1.2, 2"
```
will result in `[1.2.0, 3.0.0)`.

### Pre-1.0 behavior

While the semver specification says that all versions with a major version of 0 (versions before 1.0.0) are incompatible
with each other, we have decided to only apply that for when both the major and minor versions are zero. In other words,
0.0.1 and 0.0.2 are considered incompatible. When the minor version is not zero, versions with the same minor versions
are considered compatible, i.e. the two versions 0.2.1 and 0.2.3 are considered compatible. Versions with a major version
of 0 and different minor versions are not considered compatible, so the version 0.3.0 might have breaking changes from
0.2.0. To that end, the `[compat]` entry:

```julia
[compat]
Example = "0.0.1"
```

results in a versionbound on `Example` as [0.0.1, 0.02) (which is equivalent to only the version 0.0.1), while the `[compat]` entry:

```julia
[compat]
Example = "0.2"
```

results in a versionbound on Example as [0.2.0, 0.3.0), (which is equivalent to all versions starting with 0.2).

### Caret specifiers

A caret specifier allows upgrade that would be compatible according to semver.
Expand All @@ -49,9 +72,6 @@ PkgF = "^0.0" # [0.0.0, 0.1.0)
PkgG = "^0" # [0.0.0, 1.0.0)
```

While the semver specification says that all versions with a major version of 0 are incompatible with each other, we have made that choice that
a version given as `0.a.b` is considered compatible with `0.a.c` if `a != 0` and `c >= b`.

### Tilde specifiers

A tilde specifier provides more limited upgrade possibilities. When specifying major, minor
Expand Down
5 changes: 2 additions & 3 deletions docs/src/creating-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ This file is executed when the package is loaded.

!!! note
If you have an *existing* package from an older version of Julia (using a `REQUIRE`
file rather than `Project.toml`), then you can generate a `Project.toml` file by running the
[`gen_project.jl`](https://github.com/JuliaLang/Pkg.jl/blob/master/bin/gen_project.jl)
script with `julia gen_project.jl` in the development directory of your package.
file rather than `Project.toml`), then you can generate a `Project.toml` file by first creating a [`gen_project.jl`](https://github.com/JuliaLang/Pkg.jl/blob/934f8b71eb436da6d2bdb30ccfc80e5e11891c5b/bin/gen_project.jl)
file in your desired package (create a new file called `gen_project.jl` and then paste in the code from [here](https://github.com/JuliaLang/Pkg.jl/blob/934f8b71eb436da6d2bdb30ccfc80e5e11891c5b/bin/gen_project.jl)). Next, navigate to the development directory of your package and then run the script with `julia gen_project.jl` from the terminal.
This has to be done (once) before a new release can be registered for an older package.
(Delete `REQUIRE` and commit the resulting `Project.toml` after checking it for
correctness and adding a `version = "..."` line.)
Expand Down
10 changes: 9 additions & 1 deletion src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ end

instantiate(; kwargs...) = instantiate(Context(); kwargs...)
function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
update_registry::Bool=true, verbose::Bool=false, kwargs...)
update_registry::Bool=true, verbose::Bool=false,
platform::Platform=platform_key_abi(), kwargs...)
Context!(ctx; kwargs...)
if (!isfile(ctx.env.manifest_file) && manifest == nothing) || manifest == false
up(ctx; update_registry=update_registry)
Expand All @@ -732,7 +733,10 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
" Otherwise, remove `$name` with `Pkg.rm(\"$name\")`.",
" Finally, run `Pkg.instantiate()` again.")
end
# Download artifacts for this here package before fast-exiting
Operations.download_artifacts([dirname(ctx.env.manifest_file)]; platform=platform, verbose=verbose)
Operations.is_instantiated(ctx) && return

Types.update_registries(ctx)
pkgs = PackageSpec[]
Operations.load_all_deps!(ctx, pkgs)
Expand All @@ -749,6 +753,10 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
mkpath(sourcepath)
mv(tmp_source, sourcepath; force=true)
end

# Ensure artifacts are installed for the dependent packages, and finally this overall project
Operations.download_artifacts(pkgs; platform=platform, verbose=verbose)

new_apply = Operations.download_source(ctx, pkgs)
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose=verbose)
end
Expand Down
61 changes: 53 additions & 8 deletions src/Artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -777,17 +777,19 @@ Ensures an artifact is installed, downloading it via the download information st
"""
function ensure_artifact_installed(name::String, artifacts_toml::String;
platform::Platform = platform_key_abi(),
pkg_uuid::Union{Base.UUID,Nothing}=nothing)
meta = artifact_meta(name, artifacts_toml; pkg_uuid=pkg_uuid)
pkg_uuid::Union{Base.UUID,Nothing}=nothing,
verbose::Bool = false)
meta = artifact_meta(name, artifacts_toml; pkg_uuid=pkg_uuid, platform=platform)
if meta === nothing
error("Cannot locate artifact '$(name)' in '$(artifacts_toml)'")
end

return ensure_artifact_installed(name, meta, artifacts_toml; platform=platform)
return ensure_artifact_installed(name, meta, artifacts_toml; platform=platform, verbose=verbose)
end

function ensure_artifact_installed(name::String, meta::Dict, artifacts_toml::String;
platform::Platform = platform_key_abi())
platform::Platform = platform_key_abi(),
verbose::Bool = false)
hash = SHA1(meta["git-tree-sha1"])

if !artifact_exists(hash)
Expand All @@ -801,7 +803,7 @@ function ensure_artifact_installed(name::String, meta::Dict, artifacts_toml::Str
for entry in meta["download"]
url = entry["url"]
tarball_hash = entry["sha256"]
if download_artifact(hash, url, tarball_hash)
if download_artifact(hash, url, tarball_hash; verbose=verbose)
return artifact_path(hash)
end
end
Expand All @@ -816,7 +818,8 @@ end
ensure_all_artifacts_installed(artifacts_toml::String;
platform = platform_key_abi(),
pkg_uuid = nothing,
include_lazy = false)
include_lazy = false,
verbose = false)

Installs all non-lazy artifacts from a given `(Julia)Artifacts.toml` file. `package_uuid` must
be provided to properly support overrides from `Overrides.toml` entries in depots.
Expand All @@ -826,7 +829,8 @@ If `include_lazy` is set to `true`, then lazy packages will be installed as well
function ensure_all_artifacts_installed(artifacts_toml::String;
platform::Platform = platform_key_abi(),
pkg_uuid::Union{Nothing,Base.UUID} = nothing,
include_lazy::Bool = false)
include_lazy::Bool = false,
verbose::Bool = false)
if !isfile(artifacts_toml)
return
end
Expand All @@ -845,8 +849,49 @@ function ensure_all_artifacts_installed(artifacts_toml::String;
end

# Otherwise, let's try and install it!
ensure_artifact_installed(name, meta, artifacts_toml; platform=platform)
ensure_artifact_installed(name, meta, artifacts_toml; platform=platform, verbose=verbose)
end
end

"""
extract_all_hashes(artifacts_toml::String;
platform = platform_key_abi(),
pkg_uuid = nothing,
include_lazy = false)

Extract all hashes from a given `(Julia)Artifacts.toml` file. `package_uuid` must
be provided to properly support overrides from `Overrides.toml` entries in depots.

If `include_lazy` is set to `true`, then lazy packages will be installed as well.
"""
function extract_all_hashes(artifacts_toml::String;
platform::Platform = platform_key_abi(),
pkg_uuid::Union{Nothing,Base.UUID} = nothing,
include_lazy::Bool = false)
hashes = Base.SHA1[]
if !isfile(artifacts_toml)
return hashes
end

artifact_dict = load_artifacts_toml(artifacts_toml; pkg_uuid=pkg_uuid)

for name in keys(artifact_dict)
# Get the metadata about this name for the requested platform
meta = artifact_meta(name, artifact_dict, artifacts_toml; platform=platform)

# If there are no instances of this name for the desired platform, skip it
meta === nothing && continue

# If it's a lazy one and we aren't including lazy ones, skip
if get(meta, "lazy", false) && !include_lazy
continue
end

# Otherwise, add it to the list!
push!(hashes, Base.SHA1(meta["git-tree-sha1"]))
end

return hashes
end


Expand Down
Loading