diff --git a/pkgs/development/python-modules/curl-cffi/default.nix b/pkgs/development/python-modules/curl-cffi/default.nix new file mode 100644 index 000000000000..3f752f703bf7 --- /dev/null +++ b/pkgs/development/python-modules/curl-cffi/default.nix @@ -0,0 +1,49 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, setuptools +, curl-impersonate-chrome +, cffi +, certifi +}: + +buildPythonPackage rec { + pname = "curl-cffi"; + version = "0.6.3"; + + src = fetchFromGitHub { + owner = "yifeikong"; + repo = "curl_cffi"; + rev = "v${version}"; + hash = "sha256-VeBh5wp/VEMDGR2YK06w34hBv9qHIyA+EiZHrhEhAGw="; + }; + + patches = [ + ./use-system-libs.patch + ]; + buildInputs = [ + curl-impersonate-chrome + ]; + + format = "pyproject"; + build-system = [ + setuptools + ]; + + nativeBuildInputs = [ + cffi + ]; + propagatedBuildInputs = [ + cffi + certifi + ]; + + pythonImportsCheck = [ "curl_cffi" ]; + + meta = with lib; { + description = "Python binding for curl-impersonate via cffi"; + homepage = "https://curl-cffi.readthedocs.io"; + license = licenses.mit; + maintainers = with maintainers; [ chuangzhu ]; + }; +} diff --git a/pkgs/development/python-modules/curl-cffi/use-system-libs.patch b/pkgs/development/python-modules/curl-cffi/use-system-libs.patch new file mode 100644 index 000000000000..1d044873e461 --- /dev/null +++ b/pkgs/development/python-modules/curl-cffi/use-system-libs.patch @@ -0,0 +1,23 @@ +diff --git a/scripts/build.py b/scripts/build.py +index b705a0d..9bfcaab 100644 +--- a/scripts/build.py ++++ b/scripts/build.py +@@ -105,7 +105,6 @@ def get_curl_libraries(): + ffibuilder = FFI() + system = platform.system() + root_dir = Path(__file__).parent.parent +-download_libcurl() + + + ffibuilder.set_source( +@@ -114,9 +113,7 @@ ffibuilder.set_source( + #include "shim.h" + """, + # FIXME from `curl-impersonate` +- libraries=get_curl_libraries(), +- extra_objects=get_curl_archives(), +- library_dirs=[arch["libdir"]], ++ libraries=["curl-impersonate-chrome"], + source_extension=".c", + include_dirs=[ + str(root_dir / "include"), diff --git a/pkgs/tools/networking/curl-impersonate/default.nix b/pkgs/tools/networking/curl-impersonate/default.nix index 2ea3ac6a09a2..53db8a622080 100644 --- a/pkgs/tools/networking/curl-impersonate/default.nix +++ b/pkgs/tools/networking/curl-impersonate/default.nix @@ -31,6 +31,8 @@ let pname = "curl-impersonate-${name}"; version = "0.6.1"; + outputs = [ "out" "dev" ]; + src = fetchFromGitHub { owner = "lwthiker"; repo = "curl-impersonate"; @@ -130,6 +132,9 @@ let # Install zsh and fish completions installShellCompletion $TMPDIR/curl-impersonate-${name}.{zsh,fish} + + # Install headers + make -C curl-*/include install ''; preFixup = let diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5bc4ada81896..6da27c72faa7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2636,6 +2636,8 @@ self: super: with self; { curlify = callPackage ../development/python-modules/curlify { }; + curl-cffi = callPackage ../development/python-modules/curl-cffi { }; + curtsies = callPackage ../development/python-modules/curtsies { }; curve25519-donna = callPackage ../development/python-modules/curve25519-donna { };