-
Notifications
You must be signed in to change notification settings - Fork 57
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
Introduce CONDA_JL_CONDA_EXE environment variable #216
Conversation
else | ||
joinpath(bin_dir(ROOTENV), "conda") | ||
if ! @isdefined(CONDA_EXE) | ||
# We have an oudated deps.jl file that does not define CONDA_EXE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is impossible. If there's an outdated deps.jl that means there was a update of Conda.jl which means the package has to be built first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible in a few situations such as using multiple Julia installations with the same JULIA_DEPOT_PATH
and/or a modified JULIA_LOAD_PATH
. Julia will only force a rebuild if it is aware that the version changed.
For example, I did this to myself in the course of testing the package by using pkg"dev Conda"
. In this case, the Conda package was checked out in ~/.julia/dev/Conda
and the deps file at ~/.julia/dev/Conda/deps/deps.jl
was carried over between several versions as I moved between branches or I changed environments.
While we could just throw and error if we detect this condition, encouraging the user to rebuild, just doing the former calculation seems friendlier since we can just follow the old behavior here.
We see this issue with an outdated deps.jl file quite commonly with GR.jl and users will appear in support channels complaining that plotting is broken. The issues were reduced once we just started fixing the issues automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove it now, but my recommendation is to keep it for the moment and then remove it at a later time to smooth over the migration process.
Could we run the CI to see if there are any current issues? |
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
==========================================
- Coverage 91.83% 89.44% -2.39%
==========================================
Files 1 1
Lines 196 199 +3
==========================================
- Hits 180 178 -2
- Misses 16 21 +5
Continue to review full report at Codecov.
|
src/Conda.jl
Outdated
# This assumes that the conda executable will in some directory under | ||
# CONDA_EXE_PREFIX. | ||
# Ex: If CONDA_EXE="$HOME/miniforge3/bin/conda", then CONDA_EXE_PREFIX="$HOME/miniforge3" | ||
CONDA_EXE_PREFIX = conda |> dirname |> dirname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this assumption is too strong. It's possible that people use a shim script or symlink. Can you use something like conda info --json
or conda run python -c 'import sys; print(sys.executable)'
?
Nitpicks: It's strange that a local variable is all caps. I also notice that src/Conda.jl does not use |>
for unary function application. I have nothing against |>
per se, but, I think it's good to follow the style of surrounding code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkitti, why do we need a CONDA_EXE_PREFIX
when PREFIX
should work just as fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PREFIX
is determined by ROOTENV
. We cannot use this because we can no longer assume that CONDA_EXE
is in ROOTENV
.
Line 47 in f169018
const PREFIX = prefix(ROOTENV) |
We reach this line of code when the conda executable does not exist at Conda.conda
.
Thus, the objective here is to install the conda executable at the location specified by CONDA_JL_CONDA_EXE
/ CONDA_EXE
/ Conda.conda
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean when the user sets CONDA_JL_CONDA_EXE
env variable to a non-existent conda executable? In that case, we should just error in deps.jl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a check at build time. What should we do at runtime when _install_conda
is invoked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a check at build time.
Thanks
What should we do at runtime when _install_conda is invoked?
Nothing. We just use PREFIX since the if condition above is invoked only if CONDA_JL_CONDA_EXE
is not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it only invoked if CONDA_JL_CONDA_EXE
is not set? It might also be invoked if CONDA_EXE
gets deleted between build time and run time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention another point: does Conda.jl still use PREFIX
? If not, it's better to remove it or at least deprecate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an internal constant called PREFIX
, but it does not use an environmental variable called PREFIX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it only invoked if CONDA_JL_CONDA_EXE is not set? It might also be invoked if CONDA_EXE gets deleted between build time and run time.
True. I'm not sure how to handle it. If CONDA_EXE
gets deleted between build time and run time, I'm not sure if we should install it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I think it's ready to merge after CONDA_JL_CONDA_EXE
is documented in README and @stevengj looked at it.
Great. Thanks for the help. It looks like this can also be used to use
|
@stevengj , would you like to review before we merge this? |
Would anyone object to merging by the end of this week if we do not hearing anything else? |
deps/build.jl
Outdated
if haskey(ENV, "CONDA_JL_CONDA_EXE") | ||
# Check to see if CONDA_EXE is an executable file | ||
if isfile(CONDA_EXE) | ||
if uperm(CONDA_EXE) & 0x01 > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sys.isexecutable(CONDA_EXE)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I made this change in 84c662c
Thank you for the reviews. Can we merge this? |
Thanks again for studying this pull request. I would like to merge this tomorrow if I there are no further concerns. |
Here we introduce a new environment variable,
CONDA_JL_CONDA_EXE
which determines the location of theconda
executable at build time. This in turn is saved in deps.jl as the constantCONDA_EXE
. This in turn defines the constantConda.conda
. IfCONDA_EXE
does not exist due to an old deps.jl file,Conda.conda
is defined in manner prior to this PR.The default
CONDA_EXE
is defined by the following code based on ROOTENV.Conda.jl also has a method
_install_conda
which installs conda if the executable is not present. To determine thePREFIX
for this installation the following code is used:CONDA_EXE_PREFIX = conda |> dirname |> dirname
.