Skip to content

Commit

Permalink
Use Conda if a system wide python is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoegh committed Sep 23, 2015
1 parent 5100bd6 commit 7f2dd4f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
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.5
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 = 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.PREFIX, "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

0 comments on commit 7f2dd4f

Please sign in to comment.