diff --git a/pkgs/by-name/ho/hotdoc/clang.patch b/pkgs/by-name/ho/hotdoc/clang.patch new file mode 100644 index 000000000000..cf5c10fca3d4 --- /dev/null +++ b/pkgs/by-name/ho/hotdoc/clang.patch @@ -0,0 +1,78 @@ +diff --git a/hotdoc/extensions/c/c_extension.py b/hotdoc/extensions/c/c_extension.py +index 1cfd5b3..1e1926f 100644 +--- a/hotdoc/extensions/c/c_extension.py ++++ b/hotdoc/extensions/c/c_extension.py +@@ -44,14 +44,6 @@ from hotdoc.utils.loggable import (info as core_info, warn, Logger, + debug as core_debug) + + +-LLVM_CONFIG = os.environ.get("LLVM_CONFIG") +-if LLVM_CONFIG is None: +- LLVM_CONFIG = shutil.which('llvm-config') +- +-if LLVM_CONFIG is None: +- raise ImportError() +- +- + def ast_node_is_function_pointer(ast_node): + if ast_node.kind == cindex.TypeKind.POINTER and \ + ast_node.get_pointee().get_result().kind != \ +@@ -80,42 +72,26 @@ Logger.register_warning_code('clang-headers-not-found', HotdocException, + 'c-extension') + + +-CLANG_HEADERS_WARNING = ( +- 'Did not find clang headers. Please report a bug with the output of the' +- '\'llvm-config --version\' and \'llvm-config --prefix\' commands') +- +- + def get_clang_headers(): + try: + # Clang 5.0+ can tell us directly + resource_dir = subprocess.check_output( +- ['clang', '--print-resource-dir']).strip().decode() ++ ['@clang@', '--print-resource-dir']).strip().decode() + if len(resource_dir) > 0: + include_dir = os.path.join(resource_dir, 'include') + if os.path.exists(include_dir): + return include_dir + except subprocess.CalledProcessError: + pass +- version = subprocess.check_output( +- [LLVM_CONFIG, '--version']).strip().decode() +- prefix = subprocess.check_output( +- [LLVM_CONFIG, '--prefix']).strip().decode() +- versions = (version, version.split('.').pop(0)) +- for (ver, lib) in itertools.product( +- versions, +- ['lib', 'lib64']): +- p = os.path.join(prefix, lib, 'clang', ver, 'include') +- if os.path.exists(p): +- return p + +- warn('clang-headers-not-found', CLANG_HEADERS_WARNING) ++ warn('clang-headers-not-found', 'Did not find clang headers. Make sure you\'re using Clang 5.0+') + + + CLANG_HEADERS = get_clang_headers() + + + def get_clang_libdir(): +- return subprocess.check_output([LLVM_CONFIG, '--libdir']).strip().decode() ++ return '@libclang_lib_dir@' + + + class ClangScanner(object): +diff --git a/hotdoc/extensions/c/clang/cindex.py b/hotdoc/extensions/c/clang/cindex.py +index fc93fda..0a16651 100644 +--- a/hotdoc/extensions/c/clang/cindex.py ++++ b/hotdoc/extensions/c/clang/cindex.py +@@ -3949,6 +3949,8 @@ class Config: + + if Config.library_path: + file = Config.library_path + '/' + file ++ else: ++ file = "@libclang_lib_dir@" + '/' + file + + return file + diff --git a/pkgs/development/tools/hotdoc/fix-cmake-4.patch b/pkgs/by-name/ho/hotdoc/fix-cmake-4.patch similarity index 100% rename from pkgs/development/tools/hotdoc/fix-cmake-4.patch rename to pkgs/by-name/ho/hotdoc/fix-cmake-4.patch diff --git a/pkgs/development/tools/hotdoc/default.nix b/pkgs/by-name/ho/hotdoc/package.nix similarity index 58% rename from pkgs/development/tools/hotdoc/default.nix rename to pkgs/by-name/ho/hotdoc/package.nix index 64f7538ca37b..47862db4d978 100644 --- a/pkgs/development/tools/hotdoc/default.nix +++ b/pkgs/by-name/ho/hotdoc/package.nix @@ -1,37 +1,21 @@ { lib, stdenv, - buildPythonApplication, + python3Packages, fetchpatch, fetchPypi, replaceVars, - clang, - libclang, - pytestCheckHook, pkg-config, cmake, flex, glib, json-glib, libxml2, - appdirs, - backports-entry-points-selectable, - dbus-deviation, - faust-cchardet, - feedgen, - lxml, - networkx, - pkgconfig, - pyyaml, - schema, - setuptools, - toposort, - wheezy-template, llvmPackages, gst_all_1, }: -buildPythonApplication rec { +python3Packages.buildPythonApplication rec { pname = "hotdoc"; version = "0.17.4"; pyproject = true; @@ -43,8 +27,8 @@ buildPythonApplication rec { patches = [ (replaceVars ./clang.patch { - clang = lib.getExe clang; - libclang = "${lib.getLib libclang}/lib/libclang${stdenv.hostPlatform.extensions.sharedLibrary}"; + clang = lib.getExe llvmPackages.clang; + libclang_lib_dir = "${lib.getLib llvmPackages.libclang}/lib"; }) # Fix build with gcc15 @@ -55,7 +39,9 @@ buildPythonApplication rec { }) ]; - build-system = [ setuptools ]; + postPatch = '' + patch -p1 -d cmark -i ${./fix-cmake-4.patch} + ''; nativeBuildInputs = [ pkg-config @@ -66,10 +52,12 @@ buildPythonApplication rec { buildInputs = [ glib json-glib - libxml2.dev + libxml2 ]; - dependencies = [ + build-system = with python3Packages; [ setuptools ]; + + dependencies = with python3Packages; [ appdirs backports-entry-points-selectable dbus-deviation @@ -85,7 +73,7 @@ buildPythonApplication rec { wheezy-template ]; - nativeCheckInputs = [ pytestCheckHook ]; + nativeCheckInputs = with python3Packages; [ pytestCheckHook ]; # CMake is used to build CMARK, but the build system is still python dontUseCmakeConfigure = true; @@ -103,14 +91,6 @@ buildPythonApplication rec { "hotdoc" ]; - disabledTestPaths = [ - # Executing hotdoc exits with code 1 - "tests/test_hotdoc.py::TestHotdoc::test_basic" - "tests/test_hotdoc.py::TestHotdoc::test_explicit_conf_file" - "tests/test_hotdoc.py::TestHotdoc::test_implicit_conf_file" - "tests/test_hotdoc.py::TestHotdoc::test_private_folder" - ]; - disabledTests = [ # Test does not correctly handle path normalization for test comparison "test_cli_overrides" @@ -120,20 +100,6 @@ buildPythonApplication rec { "test_index" ]; - postPatch = - # Hardcode libclang paths - '' - substituteInPlace hotdoc/extensions/c/c_extension.py \ - --replace "shutil.which('llvm-config')" 'True' \ - --replace "subprocess.check_output(['llvm-config', '--version']).strip().decode()" '"${lib.versions.major llvmPackages.libclang.version}"' \ - --replace "subprocess.check_output(['llvm-config', '--prefix']).strip().decode()" '"${lib.getLib llvmPackages.libclang}"' \ - --replace "subprocess.check_output(['llvm-config', '--libdir']).strip().decode()" '"${lib.getLib llvmPackages.libclang}/lib"' - '' - # - + '' - patch -p1 -d cmark -i ${./fix-cmake-4.patch} - ''; - # Make pytest run from a temp dir to have it pick up installed package for cmark preCheck = '' pushd $TMPDIR diff --git a/pkgs/development/tools/hotdoc/clang.patch b/pkgs/development/tools/hotdoc/clang.patch deleted file mode 100644 index 53334206b7d5..000000000000 --- a/pkgs/development/tools/hotdoc/clang.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff --git a/hotdoc/extensions/c/c_extension.py b/hotdoc/extensions/c/c_extension.py -index 1cfd5b3..cff20c8 100644 ---- a/hotdoc/extensions/c/c_extension.py -+++ b/hotdoc/extensions/c/c_extension.py -@@ -89,7 +89,7 @@ def get_clang_headers(): - try: - # Clang 5.0+ can tell us directly - resource_dir = subprocess.check_output( -- ['clang', '--print-resource-dir']).strip().decode() -+ ['@clang@', '--print-resource-dir']).strip().decode() - if len(resource_dir) > 0: - include_dir = os.path.join(resource_dir, 'include') - if os.path.exists(include_dir): -diff --git a/hotdoc/extensions/c/clang/cindex.py b/hotdoc/extensions/c/clang/cindex.py -index fc93fda..2eb8eaf 100644 ---- a/hotdoc/extensions/c/clang/cindex.py -+++ b/hotdoc/extensions/c/clang/cindex.py -@@ -3937,20 +3937,23 @@ class Config: - if Config.library_file: - return Config.library_file - -- import platform -- name = platform.system() -+ if Config.library_path: -+ import platform -+ name = platform.system() - -- if name == 'Darwin': -- file = 'libclang.dylib' -- elif name == 'Windows': -- file = 'libclang.dll' -- else: -- file = 'libclang.so' -+ if name == 'Darwin': -+ file = 'libclang.dylib' -+ elif name == 'Windows': -+ file = 'libclang.dll' -+ else: -+ file = 'libclang.so' - -- if Config.library_path: -- file = Config.library_path + '/' + file -+ if Config.library_path: -+ file = Config.library_path + '/' + file -+ -+ return file - -- return file -+ return "@libclang@" - - def get_cindex_library(self): - try: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 19820e6e1839..9aa7ffc4f299 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2421,8 +2421,6 @@ with pkgs; host = bind.host; - hotdoc = python3Packages.callPackage ../development/tools/hotdoc { }; - hpccm = with python3Packages; toPythonApplication hpccm; html-proofer = callPackage ../tools/misc/html-proofer { };