From 6786f11afb32786abab5541b8ce9309f64173c15 Mon Sep 17 00:00:00 2001 From: Chuang Zhu Date: Mon, 6 May 2024 07:39:01 +0800 Subject: [PATCH 1/2] curl-impersonate: install headers --- pkgs/tools/networking/curl-impersonate/default.nix | 5 +++++ 1 file changed, 5 insertions(+) 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 From 93f99c29199aad4d7610639dd6c5fb50fd9291e8 Mon Sep 17 00:00:00 2001 From: Chuang Zhu Date: Mon, 6 May 2024 07:39:37 +0800 Subject: [PATCH 2/2] python3Packages.curl-cffi: init at 0.6.3 --- .../python-modules/curl-cffi/default.nix | 49 +++++++++++++++++++ .../curl-cffi/use-system-libs.patch | 23 +++++++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 74 insertions(+) create mode 100644 pkgs/development/python-modules/curl-cffi/default.nix create mode 100644 pkgs/development/python-modules/curl-cffi/use-system-libs.patch 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/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 { };