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

RFC: Customizable priorities for source building #334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,43 @@ The package declares 1 dependencies.
- BinDeps.Yum package gettext-libs (can't provide)
- Autotools Build
```

# Special settings

At startup, BinDeps checks whether `sudo` is installed on the system, since it's used
for installing from package managers.
To disable the check *and* the use of `sudo`, set an environment variable
`JULIA_BINDEPS_USE_SUDO` equal to `false`.
Setting this variable to `true` will also disable the check but will assume that `sudo`
is available.

Some users may prefer to build all dependencies from source rather than using any
available binaries or installing from package managers.
To enable this, set an environment variable `JULIA_BINDEPS_BUILD_SOURCE` equal to one
of the following values:

* `always`: Entirely **disable** installation from any providers other than `BuildProcess`.
Note that depending how a particular package is set up, you may not be able to install
it at all if it doesn't provide a method for building from source. Use this option with
caution.

* `prefer`: Build from source if a `BuildProcess` is available, otherwise use other
available providers.

* `never`: Entirely **disable** building from source. This means that packages that only
specify `BuildProcess` providers will not be installable. This option is not generally
recommended unless no build tools are available or installable on your system. Again,
use with caution.

* `default`: Allow building from source with the default priority level. This is the same
as not specifying this variable at all.

Note that this applies to `BuildProcess` only; `SimpleBuild` is always enabled.

These settings are checked every time BinDeps starts up, so to have them persist across
sessions, you can add entries like this to your .juliarc.jl file:

```julia
ENV["JULIA_BINDEPS_USE_SUDO"] = "false"
ENV["JULIA_BINDEPS_BUILD_SOURCE"] = "prefer"
```
30 changes: 24 additions & 6 deletions src/BinDeps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -574,18 +574,36 @@ function glibc_version()
ismatch(Base.VERSION_REGEX, v) ? VersionNumber(v) : nothing
end

const has_sudo = Ref{Bool}(false)
const build_source = Ref{String}("default")

function __init__()
# install from package managers with sudo
has_sudo[] = if haskey(ENV, "JULIA_BINDEPS_USE_SUDO")
ENV["JULIA_BINDEPS_USE_SUDO"] == "true"
else
try
success(`sudo -V`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you build a new system image with this line as is? i can not. like so:

$ cat ~/userimg.jl 
using BinDeps

julia> include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
julia> build_sysimg("/Users/arthurb/sys.ji", "native", "/Users/arthurb/userimg.jl")

$ julia -J /Users/arthurb/sys.ji.dylib

signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
Segmentation fault: 11

works though if i simply replace this line with true

catch err
false
end
end

# preference for building from source
build_source[] = let opt = get(ENV, "JULIA_BINDEPS_BUILD_SOURCE", "default")
if !in(opt, ["default", "always", "never", "prefer"])
error("Unrecognized value '$opt' for environment variable JULIA_BINDEPS_BUILD_SOURCE")
end
opt
end
end

include("dependencies.jl")
include("debug.jl")
include("show.jl")


# deprecations

@Base.deprecate_binding shlib_ext Libdl.dlext

const has_sudo = Ref{Bool}(false)
function __init__()
has_sudo[] = try success(`sudo -V`) catch err false end
end

end
33 changes: 24 additions & 9 deletions src/dependencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,16 +722,31 @@ function check_system_handle!(ret,dep,handle)
end

# Default installation method
defaults = if Compat.Sys.isbsd()
[Binaries, PackageManager, SystemPaths, BuildProcess]
elseif Compat.Sys.islinux() && glibc_version === nothing # non-glibc
[PackageManager, SystemPaths, BuildProcess]
elseif Compat.Sys.islinux() # glibc
[PackageManager, SystemPaths, Binaries, BuildProcess]
elseif Compat.Sys.iswindows()
[Binaries, PackageManager, SystemPaths]
defaults = if build_source[] == "always"
[BuildProcess]
else
[SystemPaths, BuildProcess]
d = if Compat.Sys.isapple()
[Binaries, PackageManager, SystemPaths, BuildProcess]
elseif Compat.Sys.islinux() && glibc_version() === nothing
[PackageManager, SystemPaths, BuildProcess]
elseif Compat.Sys.islinux() || Compat.Sys.isbsd()
[PackageManager, SystemPaths, Binaries, BuildProcess]
elseif Compat.Sys.iswindows()
[Binaries, PackageManager, SystemPaths]
else
[SystemPaths, BuildProcess]
end
if build_source[] in ["never", "prefer"]
# Remove BuildProcess
for (i, p) in enumerate(d)
p == BuildProcess && deleteat!(d, i)
end
end
if build_source[] == "prefer"
# Put it back in front
unshift!(d, BuildProcess)
end
d
end

function applicable(dep::LibraryDependency)
Expand Down