Skip to content

Commit

Permalink
Fix dll names for FT/debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Oct 24, 2024
1 parent e65f8ff commit 6a0f8fe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python: ['3.13t']
java: ['8', '11', '17', '21', '23']
steps:
- uses: actions/checkout@v4
Expand All @@ -45,10 +46,11 @@ jobs:

- uses: astral-sh/setup-uv@v3
- run: |
uv python install 3.13t
uv venv --python 3.13t
uv python install ${{ matrix.python }}
uv venv --python ${{ matrix.python }}
source .venv/bin/activate
uv pip install pip
echo $JAVA_HOME
echo PATH=$PATH >> $GITHUB_ENV
- run: pip install "setuptools < 72"
Expand Down
30 changes: 22 additions & 8 deletions jpyutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
# This way importing jpyutil does not interfere with logging in other modules
logger = logging.getLogger('jpyutil')
# Get log level from environment variable JPY_LOG_LEVEL. Default to INFO
os.environ['JPY_LOG_LEVEL'] = 'DEBUG'
log_level = os.getenv('JPY_LOG_LEVEL', 'INFO')
try:
logger.setLevel(getattr(logging, log_level))
Expand Down Expand Up @@ -303,18 +304,17 @@ def _find_python_dll_file(fail=False):
logger.debug("Searching for Python shared library file")

# Prepare list of search directories

search_dirs = [sys.prefix]

installed_base = sysconfig.get_config_var('installed_base')
if installed_base:
search_dirs.append(os.path.join(installed_base, "lib"))

extra_search_dirs = [sysconfig.get_config_var(name) for name in PYTHON_LIB_DIR_CONFIG_VAR_NAMES]
for extra_dir in extra_search_dirs:
if extra_dir and extra_dir not in search_dirs and os.path.exists(extra_dir):
search_dirs.append(extra_dir)

if platform.system() == 'Windows':
extra_search_dirs = _get_existing_subdirs(search_dirs, "DLLs")
search_dirs = extra_search_dirs + search_dirs

multi_arch_sub_dir = sysconfig.get_config_var('multiarchsubdir')
if multi_arch_sub_dir:
while multi_arch_sub_dir.startswith('/'):
Expand All @@ -326,18 +326,32 @@ def _find_python_dll_file(fail=False):

# Prepare list of possible library file names

# account for Python debug builds
try:
sys.gettotalrefcount()
debug_build = True
except AttributeError:
debug_build = False

# account for Python 3.13+ with GIL disabled
dll_suffix = ''
if sys.version_info >= (3, 13):
if not sys._is_gil_enabled():
dll_suffix = 't'
dll_suffix += 'd' if debug_build else ''

vmaj = str(sys.version_info.major)
vmin = str(sys.version_info.minor)

if platform.system() == 'Windows':
versions = (vmaj + vmin, vmaj, '')
versions = (vmaj + vmin, vmaj, vmaj + vmin + dll_suffix, '')
file_names = ['python' + v + '.dll' for v in versions]
elif platform.system() == 'Darwin':
versions = (vmaj + "." + vmin, vmaj, '')
versions = (vmaj + "." + vmin, vmaj, vmaj + "." + vmin + dll_suffix, '')
file_names = ['libpython' + v + '.dylib' for v in versions] + \
['libpython' + v + '.so' for v in versions]
else:
versions = (vmaj + "." + vmin, vmaj, '')
versions = (vmaj + "." + vmin, vmaj, vmaj + "." + vmin + dll_suffix, '')
file_names = ['libpython' + v + '.so' for v in versions]

logger.debug("Potential Python shared library file names: %s" % repr(file_names))
Expand Down

0 comments on commit 6a0f8fe

Please sign in to comment.