From 1b30c6fa3943f7b86d7aefee213fa516b23dca28 Mon Sep 17 00:00:00 2001 From: Filippo Vicentini Date: Tue, 18 Jan 2022 19:24:44 +0100 Subject: [PATCH] fix conda revert changes fix cng fix python version --- .github/workflows/aot.yml | 2 +- Project.toml | 2 +- PyPreferences.jl/src/core.jl | 17 ++++++++--------- PyPreferences.jl/src/python_utils.jl | 3 +++ src/pyinit.jl | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/aot.yml b/.github/workflows/aot.yml index 836d2ee1..6f1ecb68 100644 --- a/.github/workflows/aot.yml +++ b/.github/workflows/aot.yml @@ -16,7 +16,7 @@ jobs: os: - ubuntu-latest architecture: [x64] - python-version: ['3.x'] + python-version: ['3.9'] julia-version: - '1.6' - '1' diff --git a/Project.toml b/Project.toml index 5d737931..9c243702 100644 --- a/Project.toml +++ b/Project.toml @@ -15,8 +15,8 @@ VersionParsing = "81def892-9a0e-5fdd-b105-ffc91e053289" [compat] Conda = "1" -VersionParsing = "1" MacroTools = "0.4, 0.5" +VersionParsing = "1" julia = "1.6" [extras] diff --git a/PyPreferences.jl/src/core.jl b/PyPreferences.jl/src/core.jl index 846e0579..72db2727 100644 --- a/PyPreferences.jl/src/core.jl +++ b/PyPreferences.jl/src/core.jl @@ -1,5 +1,5 @@ using ..PyPreferences: PyPreferences -using .PythonUtils: find_libpython, python_version_of, pythonhome_of +using .PythonUtils: find_libpython, python_version_of, pythonhome_of, conda_python_fullpath using Preferences: @set_preferences!, @load_preference, @delete_preferences! @@ -23,7 +23,7 @@ function set(prefs::PythonPreferences) if prefs.python === nothing @delete_preferences!("python") else - @set_preferences!("python" => get_python_fullpath(prefs.python)) + @set_preferences!("python" => prefs.python) end if prefs.inprocess @set_preferences!("inprocess" => prefs.inprocess) @@ -53,13 +53,12 @@ function _load_python_preferences() #isempty(rawprefs) && return nothing # default value - if !_inprocess && !_conda && _python === nothing - _python = get_python_fullpath(get_default_python()) - @info "Setting default Python interpreter to $(_python)" - return set(python=_python) - else - return PythonPreferences(_python, _inprocess, _conda) - end + # if !_inprocess && !_conda && _python === nothing + # _python = get_python_fullpath(get_default_python()) + # @info "Setting default Python interpreter to $(_python)" + # return set(python=_python) + # end + return PythonPreferences(_python, _inprocess, _conda) end function load_pypreferences_code() diff --git a/PyPreferences.jl/src/python_utils.jl b/PyPreferences.jl/src/python_utils.jl index 72a79e4a..a1c1b4f9 100644 --- a/PyPreferences.jl/src/python_utils.jl +++ b/PyPreferences.jl/src/python_utils.jl @@ -2,6 +2,9 @@ using Libdl: Libdl using VersionParsing: vparse using Conda: Conda +conda_python_fullpath() = + abspath(Conda.PYTHONDIR, "python" * (Sys.iswindows() ? ".exe" : "")) + # Fix the environment for running `python`, and setts IO encoding to UTF-8. # If cmd is the Conda python, then additionally removes all PYTHON* and # CONDA* environment variables. diff --git a/src/pyinit.jl b/src/pyinit.jl index 30d31006..35e735b6 100644 --- a/src/pyinit.jl +++ b/src/pyinit.jl @@ -98,7 +98,7 @@ function python_cmd(args::Cmd = ``; end function find_libpython(python::AbstractString) - script = joinpath(@__DIR__, "..", "deps", "find_libpython.py") + script = joinpath(@__DIR__, "..", "PyPreferences.jl", "src", "find_libpython.py") cmd = python_cmd(`$script`; python = python) try return read(cmd, String)