Unverified Commit 2b3acacf authored by Austin Horstman's avatar Austin Horstman Committed by GitHub
Browse files

pyton312Packages.arelle: 18.3 -> 2.30.25, unbreak, refactor (#337284)

parents d55bf75c 43d0f162
Loading
Loading
Loading
Loading
+126 −53
Original line number Diff line number Diff line
{
  gui ? true,
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  lib,
  sphinx,
  lxml,

  setuptools,
  setuptools-scm,

  certifi,
  filelock,
  isodate,
  lxml,
  numpy,
  openpyxl,
  tkinter ? null,
  py3to2,
  isPy3k,
  python,
  ...
  pyparsing,
  python-dateutil,
  regex,

  gui ? true,
  tkinter,

  pycryptodome,
  pg8000,
  pymysql,
  pyodbc,
  rdflib,
  holidays,
  pytz,
  tinycss2,
  graphviz,
  cheroot,
  cherrypy,
  tornado,

  sphinxHook,
  sphinx-autodoc2,
  myst-parser,
  sphinx-copybutton,
  furo,

  pytestCheckHook,
  boto3,
}:

buildPythonPackage rec {
  pname = "arelle${lib.optionalString (!gui) "-headless"}";
  version = "18.3";
  format = "setuptools";

  disabled = !isPy3k;
  version = "2.30.25";
  pyproject = true;

  # Releases are published at http://arelle.org/download/ but sadly no
  # tags are published on github.
  src = fetchFromGitHub {
    owner = "Arelle";
    repo = "Arelle";
    rev = "edgr${version}";
    sha256 = "12a94ipdp6xalqyds7rcp6cjwps6fbj3byigzfy403hlqc9n1g33";
    rev = "refs/tags/${version}";
    hash = "sha256-xzTrFie97HDIqPZ4nzCh+0p/w0bTK12cS0FSsuIi7tY=";
  };

  outputs = [
    "out"
    "doc"
  ];
  patches = [ ./tests.patch ];
  postPatch = "rm testParser2.py";
  nativeBuildInputs = [
    sphinx
    py3to2

  postPatch = ''
    substituteInPlace pyproject.toml --replace-fail \
        'requires = ["setuptools~=73.0", "wheel~=0.44", "setuptools_scm[toml]~=8.1"]' \
        'requires = ["setuptools", "wheel", "setuptools_scm[toml]"]'

    # Darwin currently doesn't have the native `_decimal` module
    # Instead, we'll use the wrapper `decimal` module that can fall back to python based implementation
    # These lines can be removed after https://github.com/NixOS/nixpkgs/pull/354125 hits master
    substituteInPlace arelle/Validate{DuplicateFacts,XbrlCalcs}.py tests/unit_tests/arelle/test_{xmlvalidate,validatexbrlcalcs}.py  \
        --replace-fail 'from _decimal import' 'from decimal import'
  '';

  build-system = [
    setuptools
    setuptools-scm
  ];
  propagatedBuildInputs = [
    lxml

  dependencies = [
    certifi
    filelock
    isodate
    lxml
    numpy
    openpyxl
    pyparsing
    python-dateutil
    regex
  ] ++ lib.optionals gui [ tkinter ];

  # arelle-gui is useless without gui dependencies, so delete it when !gui.
  postInstall =
    lib.optionalString (!gui) ''
      find $out/bin -name "*arelle-gui*" -delete
    ''
    +
      # By default, not the entirety of the src dir is copied. This means we don't
      # copy the `images` dir, which is needed for the gui version.
      lib.optionalString (gui) ''
        targetDir=$out/${python.sitePackages}
        cp -vr $src/arelle $targetDir
      '';
  optional-dependencies = {
    crypto = [ pycryptodome ];
    db = [
      pg8000
      pymysql
      pyodbc
      rdflib
    ];
    efm = [
      holidays
      pytz
    ];
    esef = [ tinycss2 ];
    objectmaker = [ graphviz ];
    webserver = [
      cheroot
      cherrypy
      tornado
    ];
  };

  nativeBuildInputs = [
    # deps for docs
    sphinxHook
    sphinx-autodoc2
    myst-parser
    sphinx-copybutton
    furo
  ];

  # Documentation
  postBuild = ''
    (cd apidocs && make html && cp -r _build $doc)
  # the arelleGUI executable doesn't work when the gui option is false
  postInstall = lib.optionalString (!gui) ''
    find $out/bin -name "*arelleGUI*" -delete
  '';

  doCheck = false;
  nativeCheckInputs = [
    pytestCheckHook
    boto3
  ] ++ lib.flatten (lib.attrValues optional-dependencies);

  checkPhase = ''
    py.test
  preCheck = ''
    export HOME=$(mktemp -d)
  '';

  meta = with lib; {
    description =
      ''
  disabledTestPaths =
    [
      "tests/integration_tests"
    ]
    ++ lib.optionals (!gui) [
      # these tests import tkinter
      "tests/unit_tests/arelle/test_updater.py"
      "tests/unit_tests/arelle/test_import.py"
    ];

  meta = {
    description = "Open source XBRL platform";
    longDescription = ''
      An open source facility for XBRL, the eXtensible Business Reporting
      Language supporting various standards, exposed through a Python or
        REST API''
      + lib.optionalString gui " and a graphical user interface";
      REST API ${lib.optionalString gui " and a graphical user interface"}.
    '';
    mainProgram = "arelle";
    homepage = "http://arelle.org/";
    license = licenses.asl20;
    platforms = platforms.all;
    maintainers = with maintainers; [ roberth ];
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      tomasajt
      roberth
    ];
  };
}
+0 −14
Original line number Diff line number Diff line
diff --git c/arelle/CntlrProfiler.py i/arelle/CntlrProfiler.py
index a64bb1b..dc0299d 100644
--- c/arelle/CntlrProfiler.py
+++ i/arelle/CntlrProfiler.py
@@ -1,5 +1,6 @@

-import Cntlr, ModelManager, FileSource, time
+from arelle import Cntlr, ModelManager, FileSource
+import time
 from optparse import OptionParser
 import cProfile
 import gettext
diff --git c/arelle/ValidateFilingText.py i/arelle/ValidateFilingText.py
index 12dbbbb..c0e98c3 100644
+72 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  pythonOlder,

  flit-core,

  astroid,
  typing-extensions,
  typer,

  pytestCheckHook,
  pytest-regressions,
  sphinx,
  defusedxml,
}:

buildPythonPackage rec {
  pname = "sphinx-autodoc2";
  version = "0.5.0";
  pyproject = true;

  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "sphinx-extensions2";
    repo = "sphinx-autodoc2";
    rev = "refs/tags/v${version}";
    hash = "sha256-Wu079THK1mHVilD2Fx9dIzuIOOYOXpo/EMxVczNutCI=";
  };

  build-system = [ flit-core ];

  dependencies = [
    astroid
    typing-extensions

    # cli deps
    typer
  ] ++ typer.optional-dependencies.standard;

  preCheck = ''
    # make sphinx_path an alias of pathlib.Path, since sphinx_path was removed in Sphinx v7.2.0
    substituteInPlace tests/test_render.py --replace-fail \
        'from sphinx.testing.util import path as sphinx_path' \
        'sphinx_path = Path'
  '';

  nativeCheckInputs = [
    pytestCheckHook
    pytest-regressions
    sphinx
    defusedxml
  ];

  disabledTests = [
    # some generated files differ in newer versions of Sphinx
    "test_sphinx_build_directives"
  ];

  pythonImportsCheck = [ "autodoc2" ];

  meta = {
    changelog = "https://github.com/sphinx-extensions2/sphinx-autodoc2/releases/tag/v${version}";
    homepage = "https://github.com/sphinx-extensions2/sphinx-autodoc2";
    description = "Sphinx extension that automatically generates API documentation for your Python packages";
    license = lib.licenses.mit;
    mainProgram = "autodoc2";
    maintainers = with lib.maintainers; [ tomasajt ];
  };
}
+2 −0
Original line number Diff line number Diff line
@@ -15013,6 +15013,8 @@ self: super: with self; {
  sphinx-autodoc-typehints = callPackage ../development/python-modules/sphinx-autodoc-typehints { };
  sphinx-autodoc2 = callPackage ../development/python-modules/sphinx-autodoc2 { };
  sphinx-basic-ng = callPackage ../development/python-modules/sphinx-basic-ng { };
  sphinx-copybutton = callPackage ../development/python-modules/sphinx-copybutton { };