git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #46488 from xeji/p/python-fixes

pythonPackages.{pydub,readme_renderer,pyfakefs,us,restview}: fix build

commit2bc08ce0f53c851cbc71c2049b637b6af2985eec authorxeji <36407913+xeji@users.noreply.github.com> dateThu 13 Sep 2018, 11:38 (8 years ago) parentd024f916dc5713
6 files changed+52−62
pkgs/development/python-modules/pydub/default.nix+17−7 pkgs/development/python-modules/pydub/pyaudioop-python3.patch−46 pkgs/development/python-modules/pyfakefs/default.nix+16−8 pkgs/development/python-modules/readme_renderer/default.nix+2−1 pkgs/development/python-modules/restview/default.nix+10 pkgs/development/python-modules/us/default.nix+7
pkgs/development/python-modules/pydub/default.nix+17−7
@@ -1,19 +1,29 @@
1−{ stdenv, buildPythonPackage, fetchPypi, scipy, ffmpeg-full }:
1+{ stdenv, buildPythonPackage, fetchFromGitHub, scipy, ffmpeg-full }:
22
33buildPythonPackage rec {
44 pname = "pydub";
55 version = "0.22.1";
6− src = fetchPypi {
7− inherit pname version;
8− sha256 = "20beff39e9959a3b2cb4392802aecb9b2417837fff635d2b00b5ef5f5326d313";
6+ # pypi version doesn't include required data files for tests
7+ src = fetchFromGitHub {
8+ owner = "jiaaro";
9+ repo = pname;
10+ rev = "v${version}";
11+ sha256 = "0xqyvzgdfy01p98wnvsrf6iwdfq91ad377r6j12r8svm13ygx5bv";
912 };
1013
11− patches = [
12− ./pyaudioop-python3.patch
13− ];
14+
15+ # disable a test that fails on aarch64 due to rounding errors
16+ postPatch = stdenv.lib.optionalString stdenv.isAarch64 ''
17+ substituteInPlace test/test.py \
18+ --replace "test_overlay_with_gain_change" "notest_overlay_with_gain_change"
19+ '';
1420
1521 checkInputs = [ scipy ffmpeg-full ];
1622
23+ checkPhase = ''
24+ python test/test.py
25+ '';
26+
1727 meta = with stdenv.lib; {
1828 description = "Manipulate audio with a simple and easy high level interface.";
1929 homepage = "http://pydub.com/";
pkgs/development/python-modules/pydub/pyaudioop-python3.patchdeleted−46
@@ -1,46 +0,0 @@
1−diff --git i/pydub/pyaudioop.py w/pydub/pyaudioop.py
2−index 8f8f017..aa6bb8c 100644
3−--- i/pydub/pyaudioop.py
4−+++ w/pydub/pyaudioop.py
5−@@ -1,4 +1,4 @@
6−-import __builtin__
7−+import builtins
8− import math
9− import struct
10− from fractions import gcd
11−@@ -79,7 +79,7 @@ def _get_minval(size, signed=True):
12− def _get_clipfn(size, signed=True):
13− maxval = _get_maxval(size, signed)
14− minval = _get_minval(size, signed)
15−- return lambda val: __builtin__.max(min(val, maxval), minval)
16−+ return lambda val: builtins.max(min(val, maxval), minval)
17−
18−
19− def _overflow(val, size, signed=True):
20−@@ -109,7 +109,7 @@ def max(cp, size):
21− if len(cp) == 0:
22− return 0
23−
24−- return __builtin__.max(abs(sample) for sample in _get_samples(cp, size))
25−+ return builtins.max(abs(sample) for sample in _get_samples(cp, size))
26−
27−
28− def minmax(cp, size):
29−@@ -117,8 +117,8 @@ def minmax(cp, size):
30−
31− max_sample, min_sample = 0, 0
32− for sample in _get_samples(cp, size):
33−- max_sample = __builtin__.max(sample, max_sample)
34−- min_sample = __builtin__.min(sample, min_sample)
35−+ max_sample = builtins.max(sample, max_sample)
36−+ min_sample = builtins.min(sample, min_sample)
37−
38− return min_sample, max_sample
39−
40−@@ -542,4 +542,4 @@ def lin2adpcm(cp, size, state):
41−
42−
43− def adpcm2lin(cp, size, state):
44−- raise NotImplementedError()
45−\ No newline at end of file
46−+ raise NotImplementedError()
pkgs/development/python-modules/pyfakefs/default.nix+16−8
@@ -1,7 +1,7 @@
11{ stdenv, buildPythonPackage, fetchFromGitHub, python, pytest, glibcLocales }:
22
33buildPythonPackage rec {
4− version = "3.4.1";
4+ version = "3.4.3";
55 pname = "pyfakefs";
66
77 # no tests in PyPI tarball
@@ -10,22 +10,30 @@ buildPythonPackage rec {
1010 owner = "jmcgeheeiv";
1111 repo = pname;
1212 rev = "v${version}";
13− sha256 = "0i8kq7sl8bczr927hllgfhsmirjqjh89c9184kcqmprc13ac4kxy";
13+ sha256 = "0rhbkcb5h2x8kmyxivr5jr1db2xvmpjdbsfjxl142qhfb29hr2hp";
1414 };
1515
1616 postPatch = ''
1717 # test doesn't work in sandbox
18− substituteInPlace tests/fake_filesystem_test.py \
18+ substituteInPlace pyfakefs/tests/fake_filesystem_test.py \
1919 --replace "test_expand_root" "notest_expand_root"
20− substituteInPlace tests/fake_os_test.py \
21− --replace "test_append_mode" "notest_append_mode"
22− '';
20+ substituteInPlace pyfakefs/tests/fake_os_test.py \
21+ --replace "test_path_links_not_resolved" "notest_path_links_not_resolved" \
22+ --replace "test_append_mode_tell_linux_windows" "notest_append_mode_tell_linux_windows"
23+ substituteInPlace pyfakefs/tests/fake_filesystem_unittest_test.py \
24+ --replace "test_copy_real_file" "notest_copy_real_file"
25+ '' + (stdenv.lib.optionalString stdenv.isDarwin ''
26+ # this test fails on darwin due to case-insensitive file system
27+ substituteInPlace pyfakefs/tests/fake_os_test.py \
28+ --replace "test_rename_dir_to_existing_dir" "notest_rename_dir_to_existing_dir"
29+ '');
2330
2431 checkInputs = [ pytest glibcLocales ];
2532
2633 checkPhase = ''
27− LC_ALL=en_US.UTF-8 ${python.interpreter} -m tests.all_tests
28− py.test tests/pytest_plugin_test.py
34+ export LC_ALL=en_US.UTF-8
35+ ${python.interpreter} -m pyfakefs.tests.all_tests
36+ ${python.interpreter} -m pytest pyfakefs/tests/pytest_plugin_test.py
2937 '';
3038
3139 meta = with stdenv.lib; {
pkgs/development/python-modules/readme_renderer/default.nix+2−1
@@ -27,7 +27,8 @@ buildPythonPackage rec {
2727 ];
2828
2929 checkPhase = ''
30− py.test
30+ # disable one failing test case
31+ py.test -k "not test_invalid_link"
3132 '';
3233
3334 meta = {
pkgs/development/python-modules/restview/default.nix+10
@@ -1,6 +1,7 @@
11{ lib
22, buildPythonPackage
33, fetchPypi
4+, fetchpatch
45, docutils
56, readme_renderer
67, pygments
@@ -19,6 +20,15 @@ buildPythonPackage rec {
1920 propagatedBuildInputs = [ docutils readme_renderer pygments ];
2021 checkInputs = [ mock ];
2122
23+ patches = [
24+ # fix tests after readme_renderer update
25+ # TODO remove on next update
26+ (fetchpatch {
27+ url = "https://github.com/mgedmin/restview/commit/541743ded13ae55dea4c437046984a5f13d06e8b.patch";
28+ sha256 = "031b1dlqx346bz7afpc011lslnq771lnxb6iy1l2285pph534bci";
29+ })
30+ ];
31+
2232 postPatch = ''
2333 # dict order breaking tests
2434 sed -i 's@<a href="http://www.example.com" rel="nofollow">@...@' src/restview/tests.py
pkgs/development/python-modules/us/default.nix+7
@@ -15,6 +15,13 @@ buildPythonPackage rec {
1515 sha256 = "1niglalkp7pinibzbxjdz9mxx9qmwkrh8884dag3kr72cfkrpp09";
1616 };
1717
18+ # Upstream requires jellyfish==0.5.6 but we have 0.6.1
19+ postPatch = ''
20+ substituteInPlace setup.py --replace "jellyfish==" "jellyfish>="
21+ '';
22+
23+ doCheck = false; # pypi version doesn't include tests
24+
1825 meta = {
1926 description = "A package for easily working with US and state metadata";
2027 longDescription = ''