1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 cython,
7 setuptools,
8 pytestCheckHook,
9}:
10
11buildPythonPackage rec {
12 pname = "cwcwidth";
13 version = "0.1.10";
14 pyproject = true;
15
16 src = fetchFromGitHub {
17 owner = "sebastinas";
18 repo = "cwcwidth";
19 tag = "v${version}";
20 hash = "sha256-JrzItV+nCpQCz9MM1pcq5FtGZOsWNbgAra6i5WT4Mcg=";
21 };
22
23 build-system = [
24 cython
25 setuptools
26 ];
27
28 nativeCheckInputs = [
29 pytestCheckHook
30 ];
31
32 preCheck = ''
33 # prevent import shadow
34 rm -rf cwcwidth
35
36 # locale settings used by upstream, has the effect of skipping otherwise-failing tests on darwin
37 export LC_ALL='C.UTF-8'
38 export LANG='C.UTF-8'
39 '';
40
41 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
42 # Despite setting the locales above, this test fails with:
43 # AssertionError: Tuples differ: (1, 1, 1, 1) != (1, 1, 1, 0)
44 "test_combining_spacing"
45 ];
46
47 pythonImportsCheck = [ "cwcwidth" ];
48
49 meta = {
50 description = "Python bindings for wc(s)width";
51 homepage = "https://github.com/sebastinas/cwcwidth";
52 changelog = "https://github.com/sebastinas/cwcwidth/blob/v${version}/CHANGELOG.md";
53 license = lib.licenses.mit;
54 maintainers = [ ];
55 };
56}