mirror of https://github.com/pyodide/pyodide.git
Package joblib
This commit is contained in:
parent
2b2f1de1c1
commit
53cd70c35c
|
@ -0,0 +1,15 @@
|
||||||
|
package:
|
||||||
|
name: joblib
|
||||||
|
version: "0.11"
|
||||||
|
|
||||||
|
source:
|
||||||
|
url: https://pypi.io/packages/source/j/joblib/joblib-0.11.tar.gz
|
||||||
|
sha256: 7b8fd56df36d9731a83729395ccb85a3b401f62a96255deb1a77220c00ed4085
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- patches/use-setuptools.patch
|
||||||
|
- patches/ctypes-import.patch
|
||||||
|
|
||||||
|
test:
|
||||||
|
imports:
|
||||||
|
- joblib
|
|
@ -0,0 +1,21 @@
|
||||||
|
diff --git a/joblib/backports.py b/joblib/backports.py
|
||||||
|
index 7dd3df1..a49ef78 100644
|
||||||
|
--- a/joblib/backports.py
|
||||||
|
+++ b/joblib/backports.py
|
||||||
|
@@ -3,7 +3,6 @@ Backports of fixes for joblib dependencies
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
-import ctypes
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
@@ -34,6 +33,8 @@ except ImportError:
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
error_access_denied = 5
|
||||||
|
+ import ctypes
|
||||||
|
+
|
||||||
|
try:
|
||||||
|
from os import replace
|
||||||
|
except ImportError:
|
|
@ -0,0 +1,12 @@
|
||||||
|
diff --git a/setup.py b/setup.py
|
||||||
|
index 134db18..f705b28 100755
|
||||||
|
--- a/setup.py
|
||||||
|
+++ b/setup.py
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
-from distutils.core import setup
|
||||||
|
+from setuptools import setup
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import joblib
|
|
@ -0,0 +1,35 @@
|
||||||
|
def test_joblib_numpy_pickle(selenium):
|
||||||
|
selenium.load_package(['numpy', 'joblib'])
|
||||||
|
selenium.run("""
|
||||||
|
import joblib
|
||||||
|
import numpy as np
|
||||||
|
from numpy.testing import assert_array_equal
|
||||||
|
|
||||||
|
X = np.ones(10)
|
||||||
|
|
||||||
|
file_path = "./X.pkl"
|
||||||
|
|
||||||
|
joblib.dump(X, file_path)
|
||||||
|
|
||||||
|
X2 = joblib.load(file_path)
|
||||||
|
|
||||||
|
assert_array_equal(X, X2)""")
|
||||||
|
|
||||||
|
|
||||||
|
def test_joblib_parallel(selenium):
|
||||||
|
selenium.load_package(['numpy', 'joblib'])
|
||||||
|
selenium.clean_logs()
|
||||||
|
selenium.run("""
|
||||||
|
from math import sqrt
|
||||||
|
from joblib import Parallel, delayed
|
||||||
|
|
||||||
|
# check that the default multiprocessing backend
|
||||||
|
# gracefully reduces to n_jobs=1
|
||||||
|
res = Parallel(n_jobs=2)(delayed(sqrt)(i ** 2)
|
||||||
|
for i in range(10))
|
||||||
|
assert res == [sqrt(i ** 2) for i in range(10)]
|
||||||
|
|
||||||
|
# check threading backend
|
||||||
|
Parallel(n_jobs=2, backend='threading')(
|
||||||
|
delayed(sqrt)(i ** 2) for i in range(10))
|
||||||
|
""")
|
Loading…
Reference in New Issue