diff --git a/packages/joblib/meta.yaml b/packages/joblib/meta.yaml new file mode 100644 index 000000000..671c786ef --- /dev/null +++ b/packages/joblib/meta.yaml @@ -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 diff --git a/packages/joblib/patches/ctypes-import.patch b/packages/joblib/patches/ctypes-import.patch new file mode 100644 index 000000000..12442d3ce --- /dev/null +++ b/packages/joblib/patches/ctypes-import.patch @@ -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: diff --git a/packages/joblib/patches/use-setuptools.patch b/packages/joblib/patches/use-setuptools.patch new file mode 100644 index 000000000..0ada78514 --- /dev/null +++ b/packages/joblib/patches/use-setuptools.patch @@ -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 diff --git a/test/test_joblib.py b/test/test_joblib.py new file mode 100644 index 000000000..396be9a4c --- /dev/null +++ b/test/test_joblib.py @@ -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)) + """)