Skip to content

Commit c9b9fbb

Browse files
committed
Code cleanup and fixed the ModuleNotFoundError issue for 'psycopg2' #339
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent e016700 commit c9b9fbb

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

etc/scripts/build_nix_docker.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def is_compatible_wheel(url, major, minor):
188188

189189

190190
def create_defualt_nix(dependencies_list, meta_dict):
191+
"""Generate the default.nix"""
191192
python_version = meta_dict["requires_python"]
192193
py_version_major, py_version_minor = python_version.split(".")
193194
if py_version_minor == "0":
@@ -219,14 +220,6 @@ def create_defualt_nix(dependencies_list, meta_dict):
219220
];
220221
buildInputs = with pkgs; [ openldap cyrus_sasl ];
221222
};
222-
psycopg = {
223-
nativeBuildInputs = with pkgs; [
224-
pkg-config
225-
];
226-
buildInputs = with pkgs; [
227-
postgresql
228-
];
229-
};
230223
};
231224
232225
# Get the special build inputs for this package, or empty if none
@@ -249,8 +242,7 @@ def create_defualt_nix(dependencies_list, meta_dict):
249242
print("Processing {}/{}: {}".format(idx + 1, deps_size, dep["name"]))
250243
name = dep["name"]
251244
version = dep["version"]
252-
# Handle 'django_notifications_patched', 'django-rest-hooks' and
253-
# 'python_ldap' separately
245+
# Handle 'django_notifications_patched' and 'django-rest-hooks' seperately
254246
if name == "django-rest-hooks" or name == "django_notifications_patched":
255247
if name == "django-rest-hooks" and version == "1.6.1":
256248
nix_content += " " + name + " = python.pkgs.buildPythonPackage {\n"
@@ -380,23 +372,22 @@ def create_defualt_nix(dependencies_list, meta_dict):
380372
wheel
381373
pip
382374
pkgs.pkg-config
383-
pkgs.makeWrapper
384-
];
385-
386-
# Add PostgreSQL to buildInputs to ensure libpq is available at runtime
387-
buildInputs = with pkgs; [
388-
postgresql
389375
];
390376
391377
# Ensure proper runtime setup.
392378
postInstall = ''
393-
# Create source directory like RPM does (for source access)
379+
# Create source directory
394380
mkdir -p $out/src
395-
cp -r ${./.}/* $out/src/ 2>/dev/null || true
381+
382+
# Copy source files, dereferencing symlinks to avoid broken links
383+
cp -rL ${./.}/* $out/src/ 2>/dev/null || true
396384
397385
# Remove build artifacts from source copy
398386
rm -rf $out/src/dist $out/src/build $out/src/result $out/src/default.nix 2>/dev/null || true
399387
388+
# Remove any bin directories that might contain symlinks
389+
rm -rf $out/src/bin 2>/dev/null || true
390+
400391
# Wrap the dejacode executable to set up the runtime environment
401392
wrapProgram $out/bin/dejacode \
402393
--set PYTHONPATH "$out/src:$out/lib/python*/site-packages" \
@@ -405,6 +396,7 @@ def create_defualt_nix(dependencies_list, meta_dict):
405396
'';
406397
407398
propagatedBuildInputs = with pythonWithOverlay.pkgs; [
399+
psycopg2 # Add psycopg2 to fix ModuleNotFoundError issue in Django 5.2.7
408400
"""
409401

410402
for dep in dependencies_list:

0 commit comments

Comments
 (0)