Skip to content

Commit e1a8ba9

Browse files
committed
Refactor code to better handle "python_ldap" #339
Signed-off-by: Chin Yeung Li <tli@nexb.com>
1 parent b83542f commit e1a8ba9

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

etc/scripts/build_nix_docker.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,29 @@ def create_defualt_nix(dependencies_list, meta_dict):
182182
183183
# Helper function to create packages with specific versions and disabled tests
184184
buildCustomPackage = { pname, version, format ? "wheel", src, ... }@attrs:
185+
let
186+
# Define special build inputs for specific packages
187+
specialBuildInputs = {
188+
python_ldap = {
189+
nativeBuildInputs = with pkgs; [
190+
pkg-config
191+
python.pkgs.setuptools
192+
python.pkgs.distutils
193+
];
194+
buildInputs = with pkgs; [ openldap cyrus_sasl ];
195+
};
196+
};
197+
198+
# Get the special build inputs for this package, or empty if none
199+
specialInputs = specialBuildInputs.${pname} or {};
200+
in
185201
python.pkgs.buildPythonPackage ({
186202
inherit pname version format src;
187203
doCheck = false;
188204
doInstallCheck = false;
189205
doPytestCheck = false;
190206
pythonImportsCheck = [];
191-
} // attrs);
207+
} // specialInputs // attrs);
192208
193209
pythonOverlay = self: super: {
194210
"""
@@ -200,11 +216,7 @@ def create_defualt_nix(dependencies_list, meta_dict):
200216
version = dep["version"]
201217
# Handle 'django_notifications_patched', 'django-rest-hooks' and
202218
# 'python_ldap' separately
203-
if (
204-
name == "django-rest-hooks"
205-
or name == "django_notifications_patched"
206-
or name == "python_ldap"
207-
):
219+
if name == "django-rest-hooks" or name == "django_notifications_patched":
208220
if name == "django-rest-hooks" and version == "1.6.1":
209221
nix_content += " " + name + " = python.pkgs.buildPythonPackage {\n"
210222
nix_content += ' pname = "django-rest-hooks";\n'
@@ -233,24 +245,6 @@ def create_defualt_nix(dependencies_list, meta_dict):
233245
)
234246
nix_content += " };\n"
235247
nix_content += " };\n"
236-
elif name == "python_ldap" and version == "3.4.5":
237-
nix_content += " " + name + " = buildCustomPackage {\n"
238-
nix_content += ' pname = "python_ldap";\n'
239-
nix_content += ' version = "3.4.5";\n'
240-
nix_content += ' format = "setuptools";\n'
241-
nix_content += " src = pkgs.fetchurl {\n"
242-
nix_content += ' url = "https://files.pythonhosted.org/packages/0c/88/8d2797decc42e1c1cdd926df4f005e938b0643d0d1219c08c2b5ee8ae0c0/python_ldap-3.4.5.tar.gz";\n'
243-
nix_content += (
244-
' sha256 = "16pplmqb5wqinzy4azbafr3iiqhy65qzwbi1hmd6lb7y6wffzxmj";\n'
245-
)
246-
nix_content += " };\n"
247-
nix_content += " nativeBuildInputs = with pkgs; [\n"
248-
nix_content += " pkg-config\n"
249-
nix_content += " python.pkgs.setuptools\n"
250-
nix_content += " python.pkgs.distutils\n"
251-
nix_content += " ];\n"
252-
nix_content += " buildInputs = with pkgs; [ openldap cyrus_sasl ];\n"
253-
nix_content += " };\n"
254248
else:
255249
need_review_packages_list.append(dep)
256250
else:

0 commit comments

Comments
 (0)