mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-10 13:50:08 +02:00
[python-2.7 & 3.6] Implement CTypes's find_library() for Haiku. (#1363)
Should fix #1120 for python v2.7.13 and v3.6.1.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From 77416c48c183b83a1fdf7aa4820d64df073af490 Mon Sep 17 00:00:00 2001
|
||||
From c612225170a65eb865430ced699feb7a98da7c46 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Wed, 12 Mar 2014 21:17:06 +0000
|
||||
Subject: initial Haiku patch
|
||||
@@ -756,10 +756,10 @@ index 54054c2..bc0ae02 100644
|
||||
if (self.compiler.find_library_file(lib_dirs, 'nsl')):
|
||||
libs = ['nsl']
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From d16d03542badc6b541d3d73d0c87d3da690ce029 Mon Sep 17 00:00:00 2001
|
||||
From ae0b0b760c33129d77351dc44fea85e94f7c27dc Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Sat, 5 Apr 2014 21:16:40 +0000
|
||||
Subject: fix pyconfig.h path
|
||||
@@ -779,10 +779,10 @@ index e288964..bf4f7ef 100644
|
||||
|
||||
# Detailed destination directories
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From b40889db5ca2fd23962bd07bf3670569e3c1c69f Mon Sep 17 00:00:00 2001
|
||||
From ea5570918e1ed3be7b5dbbb16917ec820cb1b1e6 Mon Sep 17 00:00:00 2001
|
||||
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
Date: Wed, 18 Jun 2014 12:19:13 +0000
|
||||
Subject: Import missed change from the 2.6.9 patches
|
||||
@@ -811,10 +811,10 @@ index 3b51e81..11fb12c 100644
|
||||
sitepackages.append(os.path.join(prefix, "lib",
|
||||
"python" + sys.version[:3],
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From 92fa53e4a517c45305d4dd473d04c48e42727413 Mon Sep 17 00:00:00 2001
|
||||
From db2f0d9278c2f2cb638fb63617d3a0ae83e0ba4a Mon Sep 17 00:00:00 2001
|
||||
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
Date: Sun, 21 Sep 2014 18:59:44 +0200
|
||||
Subject: gcc2 fix.
|
||||
@@ -834,10 +834,10 @@ index 37f5a9e..37b0b25 100644
|
||||
#endif
|
||||
#define LIKELY(x) __builtin_expect(!!(x),1)
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From f2712d5a22bf59d5418f6233b6f6922aaa10de00 Mon Sep 17 00:00:00 2001
|
||||
From 2f9e5705ef41830863d49df8e2d62a2a726261e4 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Fri, 28 Nov 2014 16:26:28 +0000
|
||||
Subject: tarfile: let link fail and catch exception.
|
||||
@@ -866,10 +866,10 @@ index adf91d5..f284408 100644
|
||||
self._extract_member(self._find_link_target(tarinfo), targetpath)
|
||||
except KeyError:
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From b733169c0e28c09f826f11d7cca7027f27b8ac8c Mon Sep 17 00:00:00 2001
|
||||
From 1ebdc711acc90ac7ee763ede88fd14b314bf38c7 Mon Sep 17 00:00:00 2001
|
||||
From: Timothy Gu <timothygu99@gmail.com>
|
||||
Date: Sun, 11 Jan 2015 18:18:22 -0800
|
||||
Subject: Fix resource module after the initial haiku patch
|
||||
@@ -902,10 +902,10 @@ index 6c5f52f..73758bb 100644
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From 4cc5f80a471d1261b04c08750cb95c1c8592c4f7 Mon Sep 17 00:00:00 2001
|
||||
From da6620a9816d0eafa8414086c1f8462b992b96fe Mon Sep 17 00:00:00 2001
|
||||
From: Timothy Gu <timothygu99@gmail.com>
|
||||
Date: Sun, 11 Jan 2015 18:40:43 -0800
|
||||
Subject: resource: Fix [gs]et_rlimit() modes detection
|
||||
@@ -981,10 +981,10 @@ index 73758bb..0c396f6 100644
|
||||
#endif
|
||||
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From 82835c0f1c35f9b92fcb197d029eb1c782114b72 Mon Sep 17 00:00:00 2001
|
||||
From f3b8e2d311c7121cadc1e7e336920033d0d15756 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Tue, 26 May 2015 19:39:55 +0000
|
||||
Subject: Haiku hasn't makedev(), _PyInt_FromDev isn't defined.
|
||||
@@ -1004,5 +1004,120 @@ index e73805f..515c61a 100644
|
||||
PyStructSequence_SET_ITEM(v, 2, _PyInt_FromDev(st->st_dev));
|
||||
#endif
|
||||
--
|
||||
2.10.2
|
||||
2.12.2
|
||||
|
||||
|
||||
From 5b76bd46239853ebddecf8579469cce8b598f076 Mon Sep 17 00:00:00 2001
|
||||
From: Philippe Houdoin <philippe.houdoin@gmail.com>
|
||||
Date: Tue, 23 May 2017 19:48:08 +0000
|
||||
Subject: Implement CTypes's find_library for Haiku
|
||||
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index ab10ec5..72e495b 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -232,6 +232,55 @@ elif os.name == "posix":
|
||||
def find_library(name, is64 = False):
|
||||
return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
|
||||
|
||||
+ elif sys.platform.startswith("haiku"):
|
||||
+
|
||||
+ def _num_version(libname):
|
||||
+ # "libxyz.so.MAJOR.MINOR" => [ MAJOR, MINOR ]
|
||||
+ parts = libname.split(b".")
|
||||
+ nums = []
|
||||
+ try:
|
||||
+ while parts:
|
||||
+ nums.insert(0, int(parts.pop()))
|
||||
+ except ValueError:
|
||||
+ pass
|
||||
+ return nums or [sys.maxint]
|
||||
+
|
||||
+ def find_library(name):
|
||||
+ for directory in os.environ['LIBRARY_PATH'].split(os.pathsep):
|
||||
+ if directory.startswith("%A/"):
|
||||
+ directory = directory.replace('%A',
|
||||
+ os.path.dirname(os.path.abspath(sys.argv[0] or os.getcwd())))
|
||||
+
|
||||
+ if not os.path.isdir(directory):
|
||||
+ continue
|
||||
+
|
||||
+ # try direct match
|
||||
+ fname = os.path.join(directory, name)
|
||||
+ if os.path.isfile(fname):
|
||||
+ return fname
|
||||
+
|
||||
+ fname = os.path.join(directory, 'lib%s.so' % name)
|
||||
+ if os.path.isfile(fname):
|
||||
+ return fname
|
||||
+
|
||||
+ # no exact matching in this directroy
|
||||
+ # collect versioned candidates, if any
|
||||
+ candidates = []
|
||||
+ pattern = re.compile(r'lib%s\.so\.\S+' % re.escape(name))
|
||||
+ for entry in os.listdir(directory):
|
||||
+ if not os.path.isfile(os.path.join(directory, entry)):
|
||||
+ continue
|
||||
+
|
||||
+ if re.match(pattern, entry):
|
||||
+ candidates.append(os.path.join(directory, entry))
|
||||
+
|
||||
+ if candidates:
|
||||
+ # return latest version found
|
||||
+ candidates.sort(key=_num_version)
|
||||
+ return candidates[-1]
|
||||
+
|
||||
+ return None
|
||||
+
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
@@ -299,6 +348,12 @@ def test():
|
||||
print cdll.LoadLibrary("libcrypto.dylib")
|
||||
print cdll.LoadLibrary("libSystem.dylib")
|
||||
print cdll.LoadLibrary("System.framework/System")
|
||||
+ elif sys.platform.startswith("haiku"):
|
||||
+ print find_library("libbz2.so.1.0")
|
||||
+ print find_library("tracker")
|
||||
+ print find_library("media")
|
||||
+ print cdll.LoadLibrary(find_library("tracker"))
|
||||
+ print cdll.LoadLibrary("libmedia.so")
|
||||
else:
|
||||
print cdll.LoadLibrary("libm.so")
|
||||
print cdll.LoadLibrary("libcrypt.so")
|
||||
--
|
||||
2.12.2
|
||||
|
||||
|
||||
From 6ad0d99bf27bbd544c7c370da89a6249b50955b0 Mon Sep 17 00:00:00 2001
|
||||
From: Philippe Houdoin <philippe.houdoin@gmail.com>
|
||||
Date: Wed, 24 May 2017 11:06:41 +0000
|
||||
Subject: Map 'c' and 'm' libraries to libroot.so on Haiku
|
||||
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 72e495b..a2cc0a1 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -236,7 +236,7 @@ elif os.name == "posix":
|
||||
|
||||
def _num_version(libname):
|
||||
# "libxyz.so.MAJOR.MINOR" => [ MAJOR, MINOR ]
|
||||
- parts = libname.split(b".")
|
||||
+ parts = libname.split('.')
|
||||
nums = []
|
||||
try:
|
||||
while parts:
|
||||
@@ -246,6 +246,8 @@ elif os.name == "posix":
|
||||
return nums or [sys.maxint]
|
||||
|
||||
def find_library(name):
|
||||
+ if name in ('c', 'm'):
|
||||
+ return find_library('root')
|
||||
for directory in os.environ['LIBRARY_PATH'].split(os.pathsep):
|
||||
if directory.startswith("%A/"):
|
||||
directory = directory.replace('%A',
|
||||
--
|
||||
2.12.2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user