@@ -10,87 +10,7 @@ import Conda, Libdl
1010
1111struct  UseCondaPython <:  Exception  end 
1212
13- # ########################################################################
14- 
15- pyvar (python:: AbstractString , mod:: AbstractString , var:: AbstractString ) =  chomp (read (pythonenv (` $python  -c "import $mod ; print($mod .$var )"` 
16- 
17- pyconfigvar (python:: AbstractString , var:: AbstractString ) =  pyvar (python, " distutils.sysconfig" " get_config_var('$var ')" 
18- pyconfigvar (python, var, default) =  let  v =  pyconfigvar (python, var)
19-     v ==  " None" ?  default :  v
20- end 
21- 
22- pysys (python:: AbstractString , var:: AbstractString ) =  pyvar (python, " sys" 
23- 
24- # ########################################################################
25- 
26- const  dlprefix =  Sys. iswindows () ?  " " :  " lib" 
27- 
28- #  print out extra info to help with remote debugging
29- const  PYCALL_DEBUG_BUILD =  " yes" ==  get (ENV , " PYCALL_DEBUG_BUILD" " no" 
30- 
31- function  exec_find_libpython (python:: AbstractString , options)
32-     #  Do not inline `@__DIR__` into the backticks to expand correctly.
33-     #  See: https://github.com/JuliaLang/julia/issues/26323
34-     script =  joinpath (@__DIR__ , " find_libpython.py" 
35-     cmd =  ` $python  $script  $options ` 
36-     if  PYCALL_DEBUG_BUILD
37-         cmd =  ` $cmd  --verbose` 
38-     end 
39-     return  readlines (pythonenv (cmd))
40- end 
41- 
42- function  show_dlopen_error (lib, e)
43-     if  PYCALL_DEBUG_BUILD
44-         println (stderr , " dlopen($lib ) ==> " 
45-         #  Using STDERR since find_libpython.py prints debugging
46-         #  messages to STDERR too.
47-     end 
48- end 
49- 
50- #  return libpython name, libpython pointer
51- function  find_libpython (python:: AbstractString )
52-     dlopen_flags =  Libdl. RTLD_LAZY| Libdl. RTLD_DEEPBIND| Libdl. RTLD_GLOBAL
53- 
54-     libpaths =  exec_find_libpython (python, ` --list-all` 
55-     for  lib in  libpaths
56-         try 
57-             return  (Libdl. dlopen (lib, dlopen_flags), lib)
58-         catch  e
59-             show_dlopen_error (lib, e)
60-         end 
61-     end 
62- 
63-     #  Try all candidate libpython names and let Libdl find the path.
64-     #  We do this *last* because the libpython in the system
65-     #  library path might be the wrong one if multiple python
66-     #  versions are installed (we prefer the one in LIBDIR):
67-     libs =  exec_find_libpython (python, ` --candidate-names` 
68-     for  lib in  libs
69-         lib =  splitext (lib)[1 ]
70-         try 
71-             libpython =  Libdl. dlopen (lib, dlopen_flags)
72-             #  Store the fullpath to libpython in deps.jl.  This makes
73-             #  it easier for users to investigate Python setup
74-             #  PyCall.jl trying to use.  It also helps PyJulia to
75-             #  compare libpython.
76-             return  (libpython, Libdl. dlpath (libpython))
77-         catch  e
78-             show_dlopen_error (lib, e)
79-         end 
80-     end 
81- 
82-     error (""" 
83-         Couldn't find libpython; check your PYTHON environment variable. 
84- 
85-         The python executable we tried was $python . 
86-         Re-building with 
87-             ENV["PYCALL_DEBUG_BUILD"] = "yes" 
88-         may provide extra information for why it failed. 
89-         """  )
90- end 
91- 
92- # ########################################################################
93- 
13+ include (" buildutils.jl" 
9414include (" depsutils.jl" 
9515
9616# ########################################################################
0 commit comments