nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 aiohttp,
4 buildPythonPackage,
5 fetchFromGitHub,
6 isPyPy,
7 mypy,
8 pytestCheckHook,
9 requests,
10 setuptools,
11}:
12
13buildPythonPackage rec {
14 pname = "charset-normalizer";
15 version = "3.4.4";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 owner = "jawah";
20 repo = "charset_normalizer";
21 tag = version;
22 hash = "sha256-MtSBKG8bXUsgEPyXxMRBPPFI8mfuIETy6UVshe7yqGg=";
23 };
24
25 postPatch = ''
26 substituteInPlace _mypyc_hook/backend.py \
27 --replace-fail "mypy>=1.4.1,<=1.18.2" "mypy"
28 '';
29
30 build-system = [
31 setuptools
32 ]
33 ++ lib.optional (!isPyPy) mypy;
34
35 env.CHARSET_NORMALIZER_USE_MYPYC = lib.optionalString (!isPyPy) "1";
36
37 nativeCheckInputs = [ pytestCheckHook ];
38
39 pythonImportsCheck = [ "charset_normalizer" ];
40
41 passthru.tests = {
42 inherit aiohttp requests;
43 };
44
45 meta = {
46 description = "Python module for encoding and language detection";
47 mainProgram = "normalizer";
48 homepage = "https://charset-normalizer.readthedocs.io/";
49 changelog = "https://github.com/jawah/charset_normalizer/blob/${src.tag}/CHANGELOG.md";
50 license = lib.licenses.mit;
51 maintainers = with lib.maintainers; [ fab ];
52 };
53}