1{
2 lib,
3 buildPythonPackage,
4 setuptools,
5 fake-useragent,
6 faker,
7 fetchFromGitHub,
8 pytest-cov-stub,
9 pytest-mock,
10 pytestCheckHook,
11 pythonOlder,
12 scrapy,
13}:
14
15buildPythonPackage {
16 pname = "scrapy-fake-useragent";
17 version = "1.4.4";
18 pyproject = true;
19
20 disabled = pythonOlder "3.7";
21
22 # PyPi tarball is corrupted
23 src = fetchFromGitHub {
24 owner = "alecxe";
25 repo = "scrapy-fake-useragent";
26 rev = "59c20d38c58c76618164760d546aa5b989a79b8b"; # no tags
27 hash = "sha256-khQMOQrrdHokvNqfaMWqXV7AzwGxTuxaLsZoLkNpZ3k=";
28 };
29
30 postPatch = ''
31 substituteInPlace pytest.ini \
32 --replace-fail " --fulltrace" ""
33 '';
34
35 build-system = [ setuptools ];
36
37 dependencies = [
38 fake-useragent
39 faker
40 ];
41
42 nativeCheckInputs = [
43 pytest-cov-stub
44 pytest-mock
45 pytestCheckHook
46 scrapy
47 ];
48
49 pythonImportsCheck = [ "scrapy_fake_useragent" ];
50
51 disabledTests = [
52 # AttributeError: 'RetryUserAgentMiddleware' object has no attribute 'EXCEPTIONS_TO_RETRY'
53 "test_random_ua_set_on_exception"
54 ];
55
56 meta = with lib; {
57 description = "Random User-Agent middleware based on fake-useragent";
58 homepage = "https://github.com/alecxe/scrapy-fake-useragent";
59 changelog = "https://github.com/alecxe/scrapy-fake-useragent/blob/master/CHANGELOG.rst";
60 license = licenses.mit;
61 maintainers = [ ];
62 };
63}