Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.09 3.9 kB view raw
1{ buildPythonPackage 2, fetchPypi 3, python 4, stdenv 5, pytest 6, glibcLocales 7, cython 8, dateutil 9, scipy 10, moto 11, numexpr 12, pytz 13, xlrd 14, bottleneck 15, sqlalchemy 16, lxml 17, html5lib 18, beautifulsoup4 19, hypothesis 20, openpyxl 21, tables 22, xlwt 23, runtimeShell 24, isPy38 25, libcxx ? null 26}: 27 28let 29 inherit (stdenv.lib) optional optionals optionalString; 30 inherit (stdenv) isDarwin; 31 32in buildPythonPackage rec { 33 pname = "pandas"; 34 version = "1.1.1"; 35 36 src = fetchPypi { 37 inherit pname version; 38 sha256 = "53328284a7bb046e2e885fd1b8c078bd896d7fc4575b915d4936f54984a2ba67"; 39 }; 40 41 checkInputs = [ pytest glibcLocales moto hypothesis ]; 42 43 nativeBuildInputs = [ cython ]; 44 buildInputs = optional isDarwin libcxx; 45 propagatedBuildInputs = [ 46 dateutil 47 scipy 48 numexpr 49 pytz 50 xlrd 51 bottleneck 52 sqlalchemy 53 lxml 54 html5lib 55 beautifulsoup4 56 openpyxl 57 tables 58 xlwt 59 ]; 60 61 # doesn't work with -Werror,-Wunused-command-line-argument 62 # https://github.com/NixOS/nixpkgs/issues/39687 63 hardeningDisable = optional stdenv.cc.isClang "strictoverflow"; 64 65 # For OSX, we need to add a dependency on libcxx, which provides 66 # `complex.h` and other libraries that pandas depends on to build. 67 postPatch = optionalString isDarwin '' 68 cpp_sdk="${libcxx}/include/c++/v1"; 69 echo "Adding $cpp_sdk to the setup.py common_include variable" 70 substituteInPlace setup.py \ 71 --replace "['pandas/src/klib', 'pandas/src']" \ 72 "['pandas/src/klib', 'pandas/src', '$cpp_sdk']" 73 ''; 74 75 # Parallel Cythonization is broken in Python 3.8 on Darwin. Fixed in the next 76 # release. https://github.com/pandas-dev/pandas/pull/30862 77 setupPyBuildFlags = optionals (!(isPy38 && isDarwin)) [ 78 # As suggested by 79 # https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#creating-a-python-environment 80 "--parallel=$NIX_BUILD_CORES" 81 ]; 82 83 84 disabledTests = stdenv.lib.concatMapStringsSep " and " (s: "not " + s) ([ 85 # since dateutil 0.6.0 the following fails: test_fallback_plural, test_ambiguous_flags, test_ambiguous_compat 86 # was supposed to be solved by https://github.com/dateutil/dateutil/issues/321, but is not the case 87 "test_fallback_plural" 88 "test_ambiguous_flags" 89 "test_ambiguous_compat" 90 # Locale-related 91 "test_names" 92 "test_dt_accessor_datetime_name_accessors" 93 "test_datetime_name_accessors" 94 # Can't import from test folder 95 "test_oo_optimizable" 96 # Disable IO related tests because IO data is no longer distributed 97 "io" 98 # KeyError Timestamp 99 "test_to_excel" 100 # ordering logic has changed 101 "numpy_ufuncs_other" 102 "order_without_freq" 103 # tries to import from pandas.tests post install 104 "util_in_top_level" 105 # Fails with 1.0.5 106 "test_constructor_list_frames" 107 "test_constructor_with_embedded_frames" 108 ] ++ optionals isDarwin [ 109 "test_locale" 110 "test_clipboard" 111 ]); 112 113 doCheck = !stdenv.isAarch64; # upstream doesn't test this architecture 114 115 checkPhase = '' 116 runHook preCheck 117 '' 118 # TODO: Get locale and clipboard support working on darwin. 119 # Until then we disable the tests. 120 + optionalString isDarwin '' 121 # Fake the impure dependencies pbpaste and pbcopy 122 echo "#!${runtimeShell}" > pbcopy 123 echo "#!${runtimeShell}" > pbpaste 124 chmod a+x pbcopy pbpaste 125 export PATH=$(pwd):$PATH 126 '' + '' 127 LC_ALL="en_US.UTF-8" py.test $out/${python.sitePackages}/pandas --skip-slow --skip-network -k "$disabledTests" 128 runHook postCheck 129 ''; 130 131 meta = { 132 # https://github.com/pandas-dev/pandas/issues/14866 133 # pandas devs are no longer testing i686 so safer to assume it's broken 134 broken = stdenv.isi686; 135 homepage = "https://pandas.pydata.org/"; 136 description = "Python Data Analysis Library"; 137 license = stdenv.lib.licenses.bsd3; 138 maintainers = with stdenv.lib.maintainers; [ raskin fridh knedlsepp ]; 139 platforms = stdenv.lib.platforms.unix; 140 }; 141}