Skip to content

Commit

Permalink
pyton312Packages.arelle: 18.3 -> 2.30.25, unbreak, refactor (#337284)
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman authored Nov 9, 2024
2 parents d55bf75 + 43d0f16 commit 2b3acac
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 67 deletions.
179 changes: 126 additions & 53 deletions pkgs/development/python-modules/arelle/default.nix
Original file line number Diff line number Diff line change
@@ -1,87 +1,160 @@
{
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
'';

# Documentation
postBuild = ''
(cd apidocs && make html && cp -r _build $doc)
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
];

# 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 =
''
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";
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"}.
'';
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
];
};
}
14 changes: 0 additions & 14 deletions pkgs/development/python-modules/arelle/tests.patch

This file was deleted.

72 changes: 72 additions & 0 deletions pkgs/development/python-modules/sphinx-autodoc2/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
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 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down

0 comments on commit 2b3acac

Please sign in to comment.