Merge pull request #218673 from SuperSandro2000/nixos-render-docs-python-cleanup

nixos-render-docs: use packageOverrides to construct python packages
This commit is contained in:
Sandro 2023-03-14 16:47:49 +01:00 committed by GitHub
commit f17f17af85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 49 deletions

@ -1,20 +1,24 @@
{ lib
, attrs
, buildPythonPackage
, commonmark
, fetchFromGitHub
, flit-core
, linkify-it-py
, markdown
, mdurl
, psutil
, py
, pytest-benchmark
, mistletoe
, mistune
, myst-parser
, panflute
, pyyaml
, sphinx
, sphinx-book-theme
, sphinx-copybutton
, sphinx-design
, pytest-regressions
, pytestCheckHook
, pythonOlder
, typing-extensions
# allow disabling tests for the nixos manual build.
# the test suite closure is just too large.
, disableTests ? false
}:
buildPythonPackage rec {
@ -36,30 +40,29 @@ buildPythonPackage rec {
];
propagatedBuildInputs = [
attrs
linkify-it-py
mdurl
] ++ lib.optionals (pythonOlder "3.8") [
typing-extensions
];
nativeCheckInputs = [
psutil
py
] ++ lib.optionals (! disableTests) [
pytest-benchmark
pytest-regressions
pytestCheckHook
];
] ++ passthru.optional-dependencies.linkify;
pytestFlagsArray = [
"--benchmark-skip"
];
# disable and remove benchmark tests
preCheck = ''
rm -r benchmarking
'';
pythonImportsCheck = [
"markdown_it"
];
passthru.optional-dependencies = {
compare = [ commonmark markdown mistletoe mistune panflute ];
linkify = [ linkify-it-py ];
rtd = [ attrs myst-parser pyyaml sphinx sphinx-copybutton sphinx-design sphinx-book-theme ];
};
meta = with lib; {
description = "Markdown parser in Python";
homepage = "https://markdown-it-py.readthedocs.io/";

@ -6,9 +6,6 @@
, markdown-it-py
, pytest-regressions
, pytestCheckHook
# allow disabling tests for the nixos manual build.
# the test suite closure is just too large.
, disableTests ? false
}:
buildPythonPackage rec {
@ -33,7 +30,7 @@ buildPythonPackage rec {
markdown-it-py
];
nativeCheckInputs = lib.optionals (!disableTests) [
nativeCheckInputs = [
pytestCheckHook
pytest-regressions
];

@ -57,7 +57,7 @@ buildPythonPackage rec {
pytest-regressions
sphinx-pytest
pytestCheckHook
];
] ++ markdown-it-py.optional-dependencies.linkify;
disabledTests = [
# AssertionError due to different files

@ -12,27 +12,16 @@ let
python = ((if stdenv.isDarwin then python3 else python3Minimal).override {
self = python;
includeSiteCustomize = true;
}).override {
packageOverrides = final: prev: {
markdown-it-py = prev.markdown-it-py.overridePythonAttrs (_: {
doCheck = false;
});
mdit-py-plugins = prev.mdit-py-plugins.overridePythonAttrs (_: {
doCheck = false;
});
# TODO add our own small test suite, maybe add tests for these deps to channels?
markdown-it-py-no-tests = python.pkgs.markdown-it-py.override {
disableTests = true;
};
mdit-py-plugins-no-tests = python.pkgs.mdit-py-plugins.override {
markdown-it-py = markdown-it-py-no-tests;
disableTests = true;
};
makeDeps = pkgs: small:
if small
then [
markdown-it-py-no-tests
mdit-py-plugins-no-tests
]
else [
pkgs.markdown-it-py
pkgs.mdit-py-plugins
];
in
python.pkgs.buildPythonApplication rec {
@ -54,12 +43,15 @@ python.pkgs.buildPythonApplication rec {
src = ./src;
};
nativeBuildInputs = [
python.pkgs.setuptools
python.pkgs.pytestCheckHook
nativeBuildInputs = with python.pkgs; [
setuptools
pytestCheckHook
];
propagatedBuildInputs = makeDeps python.pkgs true;
propagatedBuildInputs = with python.pkgs; [
markdown-it-py
mdit-py-plugins
];
pytestFlagsArray = [ "-vvrP" "tests/" ];
@ -67,7 +59,7 @@ python.pkgs.buildPythonApplication rec {
# build closures small. mypy has an unreasonably large build closure for docs builds.
passthru.tests.typing = runCommand "${pname}-mypy" {
nativeBuildInputs = [
(python3.withPackages (p: [ p.mypy p.pytest ] ++ makeDeps p false))
(python3.withPackages (ps: with ps; [ mypy pytest markdown-it-py mdit-py-plugins ]))
];
} ''
mypy --strict ${src}