44pyproject.toml file that is used to build the Python package for NixOS and
55put it under the project root.
66
7- Requirement: `toml` and `requests` Python packages and Docker installed.
7+ Requirement:
8+ - toml
9+ - requests
10+ - Docker
11+ - nix-prefetch-url
12+
13+ To install the required Python packages, run:
814
915 pip install toml requests
1016
17+ To install Docker, follow the instructions at:
18+ https://docs.docker.com/get-docker/
19+
20+ To install "nix-prefetch-url", follow the following instructions:
21+ # Install Nix in single-user mode
22+ curl -L https://nixos.org/nix/install | sh -s -- --no-daemon
23+
24+ # Source nix in your current shell
25+ . ~/.nix-profile/etc/profile.d/nix.sh
26+
27+ # Reload your shell or open new terminal
28+ source ~/.bashrc
29+
30+ # Verify nix-prefetch-url works
31+ which nix-prefetch-url
32+
1133To run the script:
1234
1335 python build_nix_docker.py
@@ -119,23 +141,15 @@ def create_defualt_nix(dependencies_list, meta_dict):
119141let
120142 python = pkgs.python313;
121143
122- # Helper function to override a package to disable tests
123- disableAllTests =
124- package: extraAttrs:
125- package.overrideAttrs (
126- old:
127- {
144+ # Helper function to create packages with specific versions and disabled tests
145+ buildCustomPackage = { pname, version, format ? "wheel", src, ... }@attrs:
146+ python.pkgs.buildPythonPackage ({
147+ inherit pname version format src;
128148 doCheck = false;
129149 doInstallCheck = false;
130150 doPytestCheck = false;
131151 pythonImportsCheck = [];
132- checkPhase = "echo 'Tests disabled'";
133- installCheckPhase = "echo 'Install checks disabled'";
134- pytestCheckPhase = "echo 'Pytest checks disabled'";
135- __intentionallyOverridingVersion = old.__intentionallyOverridingVersion or false;
136- }
137- // extraAttrs
138- );
152+ } // attrs);
139153
140154 pythonOverlay = self: super: {
141155"""
@@ -145,11 +159,12 @@ def create_defualt_nix(dependencies_list, meta_dict):
145159 print ("Processing {}/{}: {}" .format (idx + 1 , deps_size , dep ["name" ]))
146160 name = dep ["name" ]
147161 version = dep ["version" ]
148- # Handle 'django_notifications_patched','django-rest-hooks' and 'funcparserlib' separately
162+ # Handle 'django_notifications_patched', 'django-rest-hooks' and
163+ # 'python_ldap' separately
149164 if (
150165 name == "django-rest-hooks"
151166 or name == "django_notifications_patched"
152- or ( name == "funcparserlib" and version == "0.3.6" )
167+ or name == "python_ldap"
153168 ):
154169 if name == "django-rest-hooks" and version == "1.6.1" :
155170 nix_content += " " + name + " = python.pkgs.buildPythonPackage {\n "
@@ -179,43 +194,23 @@ def create_defualt_nix(dependencies_list, meta_dict):
179194 )
180195 nix_content += " };\n "
181196 nix_content += " };\n "
182- # This section can be removed once funcparserlib is updated to >=1.0.0
183- # https://github.com/aboutcode-org/dejacode/issues/394
184- elif name == "funcparserlib" and version == "0.3.6" :
185- nix_content += " " + name + " = self.buildPythonPackage rec {\n "
186- nix_content += ' pname = "funcparserlib";\n '
187- nix_content += ' version = "0.3.6";\n '
197+ elif name == "python_ldap" and version == "3.4.5" :
198+ nix_content += " " + name + " = buildCustomPackage {\n "
199+ nix_content += ' pname = "python_ldap";\n '
200+ nix_content += ' version = "3.4.5";\n '
188201 nix_content += ' format = "setuptools";\n '
189- nix_content += " doCheck = false;\n "
190202 nix_content += " src = pkgs.fetchurl {\n "
191- nix_content += ' url = "https://files.pythonhosted.org/packages/cb/f7/b4a59c3ccf67c0082546eaeb454da1a6610e924d2e7a2a21f337ecae7b40/funcparserlib-0.3.6 .tar.gz";\n '
203+ nix_content += ' url = "https://files.pythonhosted.org/packages/0c/88/8d2797decc42e1c1cdd926df4f005e938b0643d0d1219c08c2b5ee8ae0c0/python_ldap-3.4.5 .tar.gz";\n '
192204 nix_content += (
193- ' sha256 = "07f9cgjr3h4j2m67fhwapn8fja87vazl58zsj4yppf9y3an2x6dp ";\n '
205+ ' sha256 = "16pplmqb5wqinzy4azbafr3iiqhy65qzwbi1hmd6lb7y6wffzxmj ";\n '
194206 )
195- nix_content += " };\n \n "
196- # Original setpy.py:
197- # https://github.com/vlasovskikh/funcparserlib/blob/0.3.6/setup.py
198- # funcparserlib version 0.3.6 uses use_2to3 which is no
199- # longer supported in modern setuptools. Remove the
200- # "use_2to3" from the setup.py
201- nix_content += " postPatch = ''\n "
202- nix_content += " cat > setup.py << EOF\n "
203- nix_content += " # -*- coding: utf-8 -*-\n "
204- nix_content += " from setuptools import setup\n "
205- nix_content += " setup(\n "
206- nix_content += ' name="funcparserlib",\n '
207- nix_content += ' version="0.3.6",\n '
208- nix_content += ' packages=["funcparserlib", "funcparserlib.tests"],\n '
209- nix_content += ' author="Andrey Vlasovskikh",\n '
210- nix_content += ' description="Recursive descent parsing library based" \
211- "on functional combinators",\n '
212- nix_content += ' license="MIT",\n '
213- nix_content += ' url="http://code.google.com/p/funcparserlib/",\n '
214- nix_content += " )\n "
215- nix_content += " EOF\n "
216- nix_content += " '';\n "
217- nix_content += " propagatedBuildInputs = with self; [];\n "
218- nix_content += " checkPhase = \" echo 'Tests disabled for funcparserlib'\" ;\n "
207+ nix_content += " };\n "
208+ nix_content += " nativeBuildInputs = with pkgs; [\n "
209+ nix_content += " pkg-config\n "
210+ nix_content += " python.pkgs.setuptools\n "
211+ nix_content += " python.pkgs.distutils\n "
212+ nix_content += " ];\n "
213+ nix_content += " buildInputs = with pkgs; [ openldap cyrus_sasl ];\n "
219214 nix_content += " };\n "
220215 else :
221216 need_review_packages_list .append (dep )
@@ -233,7 +228,7 @@ def create_defualt_nix(dependencies_list, meta_dict):
233228 if component .get ("packagetype" ) == "bdist_wheel" :
234229 whl_url = component .get ("url" )
235230 whl_sha256 = get_sha256_hash (whl_url )
236- nix_content += " " + name + " = python.pkgs.buildPythonPackage {\n "
231+ nix_content += " " + name + " = buildCustomPackage {\n "
237232 nix_content += ' pname = "' + name + '";\n '
238233 nix_content += ' version = "' + version + '";\n '
239234 nix_content += ' format = "wheel";\n '
@@ -251,12 +246,10 @@ def create_defualt_nix(dependencies_list, meta_dict):
251246 if component .get ("packagetype" ) == "sdist" :
252247 sdist_url = component .get ("url" )
253248 sdist_sha256 = get_sha256_hash (sdist_url )
254- nix_content += (
255- " " + name + " = disableAllTests super." + name + " {\n "
256- )
249+ nix_content += " " + name + " = buildCustomPackage {\n "
257250 nix_content += ' pname = "' + name + '";\n '
258251 nix_content += ' version = "' + version + '";\n '
259- nix_content += " __intentionallyOverridingVersion = true ;\n "
252+ nix_content += ' format = "setuptools" ;\n '
260253 nix_content += " src = pkgs.fetchurl {\n "
261254 nix_content += ' url = "' + sdist_url + '";\n '
262255 nix_content += ' sha256 = "' + sdist_sha256 + '";\n '
0 commit comments