Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions pkgs/development/python-modules/http-parser/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ lib
, buildPythonPackage
, fetchFromGitHub
, cython
, setuptools
, pytestCheckHook
{
lib,
buildPythonPackage,
fetchFromGitHub,
cython,
setuptools,
pytestCheckHook,
}:

buildPythonPackage rec {
Expand All @@ -28,18 +29,19 @@ buildPythonPackage rec {
make -B
'';

pythonImportsCheck = [
"http_parser"
];
pythonImportsCheck = [ "http_parser" ];

nativeCheckInputs = [
pytestCheckHook
];
# The imp module is deprecated since version 3.4, and was removed in 3.12
# https://docs.python.org/3.11/library/imp.html
# Fix from: https://github.com/benoitc/http-parser/pull/101/
patches = [ ./imp-importlib.diff ];

nativeCheckInputs = [ pytestCheckHook ];

meta = with lib; {
meta = {
description = "HTTP request/response parser for python in C";
homepage = "https://github.com/benoitc/http-parser";
license = licenses.mit;
maintainers = with maintainers; [ ];
license = lib.licenses.mit;
maintainers = [ ];
};
}
31 changes: 31 additions & 0 deletions pkgs/development/python-modules/http-parser/imp-importlib.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/setup.py b/setup.py
index 5c3f768..04de1d0 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,8 @@ from distutils.errors import CCompilerError, DistutilsExecError, \
from distutils.command.build_ext import build_ext
from distutils.command.sdist import sdist as _sdist
import glob
-from imp import load_source
+import importlib.machinery
+import importlib.util
import io
import os
import shutil
@@ -28,6 +29,16 @@ if sys.platform == 'win32' and sys.version_info > (2, 6):
# find the compiler
ext_errors += (IOError,)

+
+def load_source(modname, filename):
+ loader = importlib.machinery.SourceFileLoader(modname, filename)
+ spec = importlib.util.spec_from_file_location(
+ modname, filename, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ return module
+
+
http_parser = load_source("http_parser", os.path.join("http_parser",
"__init__.py"))