Files
nixpkgs/pkgs/development/python-modules/formulas/default.nix
2026-11-10 03:07:28 +05:30

169 lines
3.2 KiB
Nix

{
lib,
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
gitUpdater,
pythonAtLeast,
# build-system
setuptools,
# dependencies
bahttext,
click,
click-log,
dictdiffer,
ezodf,
flask,
gunicorn,
lxml,
numpy,
numpy-financial,
openpyxl,
python-dateutil,
regex,
schedula,
scipy,
statsmodels,
tqdm,
# optional-dependencies
docutils,
graphviz,
jinja2,
pygments,
# tests
ddt,
dill,
pytestCheckHook,
sphinx,
sphinx-click,
sphinx-rtd-theme,
sphinxcontrib-restbuilder,
}:
buildPythonPackage (finalAttrs: {
pname = "formulas";
version = "1.3.4";
pyproject = true;
src = fetchFromGitHub {
owner = "vinci1it2000";
repo = "formulas";
tag = "v${finalAttrs.version}";
hash = "sha256-mcHGoXtZtBqZBh68/bsRDz75q1oHCMKoUUVlEsnPdNI=";
};
patches = [
(fetchpatch {
name = "linest-aarch64-blas-rounding.patch";
url = "https://github.com/vinci1it2000/formulas/commit/2d68e59d1abb10433feefef5c7cdcab378459159.patch";
hash = "sha256-5jnE7f2HypuFrP8g9rhWZovNw//T+vbHMfbBXhA4UmE=";
})
];
build-system = [ setuptools ];
dependencies = [
bahttext
click
click-log
dictdiffer
ezodf
flask
gunicorn
lxml
numpy
numpy-financial
openpyxl
python-dateutil
regex
schedula
scipy
statsmodels
tqdm
];
optional-dependencies =
let
excelDeps = [
dictdiffer
ezodf
lxml
openpyxl
];
in
{
excel = excelDeps;
plot = [
docutils
flask
graphviz
jinja2
pygments
regex
];
cli = excelDeps ++ [
click-log
flask
];
};
nativeCheckInputs = [
ddt
dill
docutils
graphviz
jinja2
pygments
pytestCheckHook
sphinx
sphinx-click
sphinx-rtd-theme
sphinxcontrib-restbuilder
];
# TODO remove once https://github.com/vinci1it2000/formulas/pull/186 is released
postPatch = ''
touch formulas/gui/__init__.py
substituteInPlace formulas/cli.py --replace-fail \
"ctx.params['app'] = 'formulas.app:create_app'" \
"ctx.params['app'] = 'formulas.app:create_app()'"
substituteInPlace setup.py --replace-fail \
"'formulas.gui': ['*']" \
"'formulas.gui': ['templates/*']"
''
+ lib.optionalString (pythonAtLeast "3.14") ''
# itertools.count is not picklable on 3.14; schedula stores count().__next__
# https://github.com/python/cpython/issues/101588
cat > test/conftest.py << 'EOF'
import copyreg
import itertools
def _reduce_count(_obj):
return itertools.count, ()
copyreg.pickle(itertools.count, _reduce_count)
EOF
'';
pythonImportsCheck = [ "formulas" ];
passthru.updateScript = gitUpdater { rev-prefix = "v"; };
meta = {
description = "Parse and compile Excel formulas and workbooks in Python code";
homepage = "https://github.com/vinci1it2000/formulas";
changelog = "https://github.com/vinci1it2000/formulas/blob/${finalAttrs.src.tag}/CHANGELOG.rst";
license = lib.licenses.eupl11;
maintainers = [ lib.maintainers.lucasew ];
teams = [ lib.teams.ngi ];
mainProgram = "formulas";
platforms = lib.platforms.linux;
};
})