Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / python-modules / setuptools-odoo / default.nix
blob5e262daa580e3f077045d29271e4f824e65a65b0
1 { lib
2 , buildPythonPackage
3 , fetchFromGitHub
4 , git
5 , pytestCheckHook
6 , pythonOlder
7 , setuptools-scm
8 , writeScript
9 }:
11 buildPythonPackage rec {
12   pname = "setuptools-odoo";
13   version = "3.2.1";
14   format = "setuptools";
16   disabled = pythonOlder "3.7";
18   src = fetchFromGitHub {
19     owner = "acsone";
20     repo = pname;
21     rev = "refs/tags/${version}";
22     hash = "sha256-aS2a1G9lssgGk3uqWgPPWpOpEnqUkCUzWsqPLQfU55k=";
23   };
25   propagatedBuildInputs = [
26     setuptools-scm
27   ];
29   # HACK https://github.com/NixOS/nixpkgs/pull/229460
30   SETUPTOOLS_SCM_PRETEND_VERSION = version;
32   patchPhase = ''
33     runHook prePatch
35     old_manifest="$(cat MANIFEST.in 2>/dev/null || true)"
36     echo 'global-include **' > MANIFEST.in
37     echo "$old_manifest" >> MANIFEST.in
39     runHook postPatch
40   '';
42   pythonImportsCheck = [
43     "setuptools_odoo"
44   ];
46   setupHook = writeScript "setupHook.sh" ''
47     setuptoolsOdooHook() {
48       # Don't look for a version suffix from git when building addons
49       export SETUPTOOLS_ODOO_POST_VERSION_STRATEGY_OVERRIDE=none
51       # Let setuptools-odoo know which files to install, when Git is missing
52       # HACK https://github.com/acsone/setuptools-odoo/issues/20#issuecomment-340192355
53       echo 'recursive-include odoo/addons/* **' >> MANIFEST.in
55       # Make sure you can import the built addon
56       for manifest in $(find -L . -name __manifest__.py); do
57         export pythonImportsCheck="$pythonImportsCheck odoo.addons.$(basename $(dirname $manifest))"
58       done
59     }
61     preBuildHooks+=(setuptoolsOdooHook)
62   '';
64   nativeCheckInputs = [
65     pytestCheckHook
66     git
67   ];
69   disabledTests = [
70     "test_addon1_uncommitted_change"
71     "test_addon1"
72     "test_addon2_uncommitted_version_change"
73     "test_odoo_addon1_sdist"
74     "test_odoo_addon1"
75     "test_odoo_addon5_wheel"
76   ];
78   meta = with lib; {
79     description = "Setuptools plugin for Odoo addons";
80     homepage = "https://github.com/acsone/setuptools-odoo";
81     changelog = "https://github.com/acsone/setuptools-odoo/blob/${version}/CHANGES.rst";
82     license = licenses.lgpl3Only;
83     maintainers = with maintainers; [ yajo ];
84   };