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

WIP towards make PyCall use Conda if system python is not found #191

Merged
merged 1 commit into from
Sep 24, 2015
Merged
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
python:
- 2.6
- 2.7
- 3.2
- 3.3
Expand Down
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.3
Compat 0.7.1
Dates
Conda 0.1.6
16 changes: 16 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ environment:
- JULIAVERSION: "julialang/bin/winnt/x86/0.3/julia-0.3-latest-win32.exe"
PYTHONDIR: "C:\\Python34"
PYTHON: "C:\\Python34\\python.exe"

- JULIAVERSION: "julialang/bin/winnt/x86/0.3/julia-0.3-latest-win32.exe"
PYTHONDIR: "use_conda"
PYTHON: "use_conda"

- JULIAVERSION: "julialang/bin/winnt/x64/0.3/julia-0.3-latest-win64.exe"
PYTHONDIR: "C:\\Python27-x64"
Expand All @@ -25,6 +29,10 @@ environment:
- JULIAVERSION: "julialang/bin/winnt/x64/0.3/julia-0.3-latest-win64.exe"
PYTHONDIR: "C:\\Python34-x64"
PYTHON: "C:\\Python34-x64\\python.exe"

- JULIAVERSION: "julialang/bin/winnt/x64/0.3/julia-0.3-latest-win64.exe"
PYTHONDIR: "use_conda"
PYTHON: "use_conda"

# Nightlies
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
Expand All @@ -38,6 +46,10 @@ environment:
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
PYTHONDIR: "C:\\Python34"
PYTHON: "C:\\Python34\\python.exe"

- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
PYTHONDIR: "use_conda"
PYTHON: "use_conda"

- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
PYTHONDIR: "C:\\Python27-x64"
Expand All @@ -50,6 +62,10 @@ environment:
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
PYTHONDIR: "C:\\Python34-x64"
PYTHON: "C:\\Python34-x64\\python.exe"

- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"
PYTHONDIR: "use_conda"
PYTHON: "use_conda"

branches:
only:
Expand Down
20 changes: 19 additions & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
isfile("deps.jl") && rm("deps.jl")

using Compat
import Conda

PYTHONIOENCODING = get(ENV, "PYTHONIOENCODING", nothing)
PYTHONHOME = get(ENV, "PYTHONHOME", nothing)
Expand Down Expand Up @@ -121,7 +122,22 @@ end
# need to be able to get the version before Python is initialized
Py_GetVersion(libpy) = bytestring(ccall(Libdl.dlsym(libpy, :Py_GetVersion), Ptr{UInt8}, ()))

const python = get(ENV, "PYTHON", "python")
use_conda = false
const python = try
let py = get(ENV, "PYTHON", "python"), vers = convert(VersionNumber, pyconfigvar(py,"VERSION","0.0"))
if vers < v"2.7"
error("Python version $vers < 2.7 is not supported")
end
py
end
catch e1
info( "No system-wide Python was found; got the following error:\n",
"$e1\nusing the Python distribution in the Conda package")
use_conda = true
Conda.add("numpy")
abspath(Conda.PYTHONDIR, "python" * (@windows? ".exe" : ""))
end

const (libpython, libpy_name) = find_libpython(python)
const programname = pysys(python, "executable")

Expand Down Expand Up @@ -181,6 +197,8 @@ open("deps.jl", "w") do f
const pyprogramname = $pystring("$(escape_string(programname))")
const pyversion_build = $(repr(pyversion))
const PYTHONHOME = $pystring("$(escape_string(get(ENV, "PYTHONHOME", "")))")
"Returns a boolean of whether the Python distribtion in the Conda package is used"
const use_conda = $use_conda

const PyUnicode_AsUTF8String = :$PyUnicode_AsUTF8String
const PyUnicode_DecodeUTF8 = :$PyUnicode_DecodeUTF8
Expand Down