Skip to content

Commit e4663cb

Browse files
committed
Add Conda support again
1 parent 0c10f6d commit e4663cb

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/windows.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,25 @@ jobs:
101101

102102
- run: python -c 'import numpy; print(numpy)'
103103

104+
- run: python -c 'import os; print(os.environ)'
105+
104106
- run: bundle install
105107

106108
- run: rake compile
107109

108110
- run: python lib/pycall/python/investigator.py
109111

110112
- run: |
111-
rake
113+
ruby -Ilib -Iext/pycall -rpycall -e "p PyCall.sys.version"
114+
ruby -Ilib -Iext/pycall -rpycall -e "PyCall.import_module(:numpy)"
112115
env:
113116
PYTHON: python
117+
continue-on-error: true
114118
119+
- run: |
120+
echo $env:PATH
121+
rake
122+
env:
123+
PYTHON: python
124+
CONDA_DLL_SEARCH_MODIFICATION_ENABLE: 1
125+
continue-on-error: true

lib/pycall/libpython/finder.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ def find_libpython(python = nil)
4242
python, python_config = find_python_config(python)
4343
suffix = python_config[:SHLIB_SUFFIX]
4444

45+
use_conda = (ENV.fetch("CONDA_PREFIX", nil) == File.dirname(python_config[:executable]))
46+
python_home = if !ENV.key?("PYTHONHOME") || use_conda
47+
python_config[:PYTHONHOME]
48+
else
49+
ENV["PYTHONHOME"]
50+
end
51+
ENV["PYTHONHOME"] = python_home
52+
4553
candidate_paths(python_config) do |path|
4654
debug_report("Candidate: #{path}")
4755
normalized = normalize_path(path, suffix)

lib/pycall/python/investigator.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,14 @@ def _linked_libpython_windows():
7272
get_config_var("VERSION")
7373
print("VERSION: {val}".format(val=version))
7474

75-
print("version_major: {val}".format(val=sys.version_info.major))
75+
if is_windows:
76+
if hasattr(sys, "base_exec_prefix"):
77+
PYTHONHOME = sys.base_exec_prefix
78+
else:
79+
PYTHONHOME = sys.exec_prefix
80+
else:
81+
if hasattr(sys, "base_exec_prefix"):
82+
PYTHONHOME = ":".join([sys.base_prefix, sys.base_exec_prefix])
83+
else:
84+
PYTHONHOME = ":".join([sys.prefix, sys.exec_prefix])
85+
print("PYTHONHOME: {val}".format(val=PYTHONHOME))

0 commit comments

Comments
 (0)