Skip to content

Commit be5e924

Browse files
committed
Default to Python 3.6 instead of 3.7
1 parent 1a5d1d6 commit be5e924

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

src/Conda.jl

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ function _installer_url()
128128
elseif Compat.Sys.islinux()
129129
res *= "Linux"
130130
elseif Compat.Sys.iswindows()
131-
if MINICONDA_VERSION == "3"
132-
# Quick fix for:
133-
# * https://github.com/JuliaLang/IJulia.jl/issues/739
134-
# * https://github.com/ContinuumIO/anaconda-issues/issues/10082
135-
# * https://github.com/conda/conda/issues/7789
136-
res = "https://repo.continuum.io/miniconda/Miniconda$(MINICONDA_VERSION)-4.5.4-"
137-
end
138131
res *= "Windows"
139132
else
140133
error("Unsuported OS.")
@@ -147,6 +140,17 @@ end
147140
"Suppress progress bar in continuous integration environments"
148141
_quiet() = get(ENV, "CI", "false") == "true" ? `-q` : ``
149142

143+
"""
144+
Python version to be used when `MINICONDA_VERSION == "3"`. As it
145+
takes time for conda packages to be registered after new Python is
146+
released, it is useful to delay updating Python interpreter.
147+
See: https://github.com/JuliaPy/Conda.jl/issues/127
148+
149+
Note that https://github.com/JuliaPy/Conda.jl/issues/125 must be
150+
resolved before bumping this to 3.7.
151+
"""
152+
const _default_python3 = "python=3.6"
153+
150154
"Install miniconda if it hasn't been installed yet; _install_conda(true) installs Conda even if it has already been installed."
151155
function _install_conda(env::Environment, force::Bool=false)
152156
if force || !isfile(Conda.conda)
@@ -168,6 +172,10 @@ function _install_conda(env::Environment, force::Bool=false)
168172
run(Cmd(`$installer /S /AddToPath=0 /RegisterPython=0 /D=$PREFIX`, windows_verbatim=true))
169173
end
170174
Conda.add_channel("defaults")
175+
if MINICONDA_VERSION == "3"
176+
add(_default_python3, env)
177+
pin(_default_python3, env)
178+
end
171179
# Update conda because conda 4.0 is needed and miniconda download installs only 3.9
172180
runconda(`update $(_quiet()) -y conda`)
173181
end
@@ -287,4 +295,36 @@ function rm_channel(channel::AbstractString, env::Environment=ROOTENV)
287295
runconda(`config --remove channels $channel --force`, env)
288296
end
289297

298+
"""
299+
Conda.pin(sepc, [env])
300+
301+
Pin version of given package. Use `Conda.free` to unpin the package.
302+
303+
# Examples
304+
```
305+
julia> Conda.pin("matplotlib<3")
306+
julia> Conda.pin("pandas=0.23")
307+
julia> Conda.pin("defaults::numpy")
308+
```
309+
"""
310+
function pin(spec::AbstractString, env::Environment=ROOTENV)
311+
runconda(`config --add pinned_packages $spec`, env)
312+
end
313+
314+
"""
315+
Conda.free(sepc, [env])
316+
317+
Remove `spec` from `pinned_packages` configuration.
318+
319+
# Examples
320+
```
321+
julia> Conda.free("matplotlib<3")
322+
julia> Conda.free("pandas=0.23")
323+
julia> Conda.free("defaults::numpy")
324+
```
325+
"""
326+
function free(spec::AbstractString, env::Environment=ROOTENV)
327+
runconda(`config --remove pinned_packages $spec`, env)
328+
end
329+
290330
end

test/runtests.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using Compat.Test
55

66
exe = Compat.Sys.iswindows() ? ".exe" : ""
77

8+
is_fresh = !isdir(Conda.PYTHONDIR)
89
Conda.update()
910

1011
env = :test_conda_jl
@@ -14,7 +15,11 @@ rm(Conda.prefix(env); force=true, recursive=true)
1415
Conda.add("curl", env)
1516

1617
@testset "Install Python package" begin
17-
Conda.add("python=3.6", env) # 3.7 doesn't work on Windows at the moment
18+
# Conda.pin below is redundant and `Conda.add("python=3.6", env)`
19+
# is actually enough. The intention is to check the case where
20+
# `pin` is called before `add`.
21+
Conda.pin("python=3.6", env) # 3.7 doesn't work on Windows at the moment
22+
Conda.add("python", env)
1823
pythonpath = joinpath(Conda.python_dir(env), "python" * exe)
1924
@test isfile(pythonpath)
2025

@@ -40,6 +45,10 @@ pythonpath = joinpath(Conda.PYTHONDIR, "python" * exe)
4045
@test isfile(pythonpath)
4146
pyversion = read(`$pythonpath -c "import sys; print(sys.version)"`, String)
4247
@test pyversion[1:1] == Conda.MINICONDA_VERSION
48+
if is_fresh && Conda.MINICONDA_VERSION == 3
49+
@test startswith(pyversion, "3.6")
50+
@test_throws Exception Conda.add("python=3.7")
51+
end
4352

4453
Conda.add_channel("foo", env)
4554
@test Conda.channels(env) == ["foo", "defaults"]

0 commit comments

Comments
 (0)