-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
142 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
name = "DepotDelivery" | ||
uuid = "5c353f05-31b8-41b6-b09f-65e5456b8b1e" | ||
authors = ["Josh Day <[email protected]> and contributors"] | ||
version = "0.1.7" | ||
version = "0.2.0" | ||
|
||
[deps] | ||
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" | ||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | ||
|
||
[compat] | ||
Dates = "1.11.0" | ||
InteractiveUtils = "1.11.0" | ||
Pkg = "1.11.0" | ||
UUIDs = "1.11.0" | ||
julia = "1" | ||
|
||
[extras] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Pkg, Dates, UUIDs, InteractiveUtils | ||
|
||
verbose, triplet, sources, dest, precomp, offline = ARGS | ||
|
||
function get_project(path) | ||
file = joinpath(path, "Project.toml") | ||
file = isfile(file) ? file : joinpath(path, "JuliaProject.toml") | ||
isfile(file) || error("No Project.toml or JuliaProject.toml file found in `$path`.") | ||
return Pkg.Types.read_project(file) | ||
end | ||
|
||
get_project_name(path) = (p = get_project(path); isnothing(p.name) ? splitpath(path)[end] : p.name) | ||
|
||
#-----------------------------------------------------------------------------# ARGS | ||
verbose = verbose == "true" | ||
offline = offline == "true" | ||
source_dict = Dict(x => get_project_name(x) for x in abspath.(split(sources, ':'))) | ||
platform = Base.parse(Base.BinaryPlatforms.Platform, triplet) | ||
|
||
for src in keys(source_dict) | ||
isdir(src) || error("Source directory `$src` does not exist.") | ||
end | ||
isdir(dest) || mkpath(dest) | ||
|
||
verbose && @info """ | ||
Building depot | ||
- Sources: | ||
- $(join(["$v: $k" for (k,v) in source_dict], "\n - ")) | ||
- Destination: $dest | ||
- Triplet: $triplet | ||
- Platform: $platform | ||
""" | ||
|
||
spec = Dict( | ||
:datetime => Dates.now(), | ||
:versioninfo => sprint(InteractiveUtils.versioninfo), | ||
:sources => source_dict, | ||
:destination => dest, | ||
:triplet => triplet, | ||
:platform => string(platform) | ||
) | ||
|
||
#-----------------------------------------------------------------------------# populate dest | ||
ENV["JULIA_PKG_PRECOMPILE_AUTO"] = precomp == "true" ? 1 : 0 | ||
ENV["JULIA_DEPOT_PATH"] = dest | ||
DEPOT_PATH[1] = dest | ||
|
||
# PIRACY: This is more reliable than setting the `platform` keyword argument in `Pkg` functions. | ||
Base.BinaryPlatforms.HostPlatform() = platform | ||
|
||
Pkg.activate() | ||
mkpath(joinpath(dest, "dev")) | ||
for (path, name) in source_dict | ||
path = cp(path, joinpath(dest, "dev", name), force=true) | ||
proj = get_project(path) | ||
if any(isnothing, (proj.name, proj.uuid)) | ||
@info "$path is not a valid Julia project. Assigning necessary name/uuid..." | ||
proj.name = isnothing(proj.name) ? get_project_name(path) : proj.name | ||
proj.uuid = isnothing(proj.uuid) ? UUIDs.uuid4() : proj.uuid | ||
file = isfile(joinpath(path, "Project.toml")) ? "Project.toml" : "JuliaProject.toml" | ||
Pkg.Types.write_project(proj, joinpath(path, file)) | ||
end | ||
Pkg.develop(path=path) | ||
end | ||
Pkg.instantiate(; verbose) | ||
|
||
#-----------------------------------------------------------------------------# config | ||
mkpath(joinpath(dest, "config")) | ||
|
||
startup = """ | ||
# This file was automatically generated by DepotDelivery.jl | ||
# Created at: $(Dates.now()) | ||
$(offline ? "import Pkg; Pkg.offline(true)" : "") | ||
let | ||
depot = abspath(joinpath(@__DIR__, "..")) | ||
ENV["JULIA_DEPOT_PATH"] = depot # For Distributed workers | ||
DEPOT_PATH[1] = depot # For current process | ||
end | ||
@info "DepotDelivery startup: `using $(join(values(source_dict), ", "))`" | ||
using $(join(values(source_dict), ", ")) | ||
""" | ||
|
||
write(joinpath(dest, "config", "startup.jl"), startup) | ||
write(joinpath(dest, "config", "DepotDeliveryBuild.toml"), sprint(Pkg.TOML.print, spec)) | ||
|
||
print(dest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module BitFlags | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module URIs | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Unzip | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,24 @@ | ||
using DepotDelivery | ||
using Pkg | ||
using Test | ||
|
||
|
||
depot = DepotDelivery.build(joinpath(@__DIR__, "TestProject")) | ||
|
||
#-----------------------------------------------------------------------------# Single Project | ||
depot = DepotDelivery.build(joinpath(@__DIR__, "TestProject"), precompiled=false) | ||
@test !isdir(joinpath(depot, "compiled")) | ||
@test DepotDelivery.test(depot) | ||
@test DepotDelivery._check_artifacts(depot, [".dll"]) | ||
|
||
DepotDelivery.sandbox() do | ||
include(joinpath(depot, "config", "depot_startup.jl")) | ||
@test !any(x -> occursin(".julia", x), DEPOT_PATH) # Ensure DEPOT_PATH changed | ||
@test !occursin(".julia", pathof(TestProject)) | ||
@test !occursin(".julia", pathof(TestProject.HDF5)) | ||
@test !occursin(".julia", pathof(TestProject.HDF5.API.HDF5_jll)) | ||
end | ||
|
||
|
||
depot2 = DepotDelivery.build(joinpath(@__DIR__, "TestProject"), platform = Pkg.BinaryPlatforms.Windows(:x86_64)) | ||
|
||
path = joinpath(depot2, "packages", "HDF5_jll") | ||
|
||
depot = DepotDelivery.build(joinpath(@__DIR__, "TestProject"), precompiled=true) | ||
@test isdir(joinpath(depot, "compiled")) | ||
@test DepotDelivery.test(depot) | ||
|
||
#-----------------------------------------------------------------------------# Testing multiple workflows | ||
packages_list = readdir(joinpath(@__DIR__, "MultipleWorkflows/")); | ||
proj_paths = joinpath.(@__DIR__, "MultipleWorkflows/", packages_list); | ||
depot = DepotDelivery.build(proj_paths, precompiled=true) | ||
|
||
DepotDelivery.sandbox() do | ||
push!(empty!(DEPOT_PATH), depot) | ||
|
||
# Test that for every project instantiated, their dependencies exist | ||
# and the depot path does not point to the default value | ||
@testset for (proj, package) in zip(proj_paths, packages_list) | ||
Pkg.activate(proj) | ||
Pkg.instantiate() | ||
package_symbol = Symbol(package) | ||
@eval using $package_symbol | ||
package_value = eval(package_symbol) | ||
@test !occursin(".julia", pathof(package_value)) | ||
end | ||
depot = DepotDelivery.build(joinpath(@__DIR__, "TestProject"), triplet="x86_64-w64-mingw32") | ||
@test !isdir(joinpath(depot, "compiled")) | ||
@test DepotDelivery._check_artifacts(depot, [".dylib"]) | ||
|
||
# Ensure compiled folders are populated | ||
@testset for package in packages_list | ||
@test length(readdir(joinpath(depot, "compiled", "v$(VERSION.major).$(VERSION.minor)", package))) > 0 | ||
end | ||
#-----------------------------------------------------------------------------# Multiple Projects | ||
cd(joinpath(@__DIR__, "MultipleWorkflows")) do | ||
depot = DepotDelivery.build(readdir()) | ||
@test DepotDelivery.test(depot) | ||
end |