Unverified Commit f17f17af authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

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

 nixos-render-docs: use packageOverrides to construct python packages 
parents a571deb0 f39cdb78
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
{ 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/";
+1 −4
Original line number Diff line number Diff line
@@ -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
  ];
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ buildPythonPackage rec {
    pytest-regressions
    sphinx-pytest
    pytestCheckHook
  ];
  ] ++ markdown-it-py.optional-dependencies.linkify;

  disabledTests = [
    # AssertionError due to different files
+17 −25
Original line number Diff line number Diff line
@@ -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}