Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for running Django on Darwin/macOS #27685

Closed
svniemeijer opened this issue Jul 27, 2017 · 4 comments
Closed

Fix for running Django on Darwin/macOS #27685

svniemeijer opened this issue Jul 27, 2017 · 4 comments
Assignees
Labels
6.topic: darwin Running or building packages on Darwin 6.topic: python

Comments

@svniemeijer
Copy link
Contributor

Issue description

The latest python Django versions (1.10/1.11) are dependent on GEOS/GDAL.
The existing patch script 1.10-gis-libs.template.patch hardcodes a .so library as default path, but this should be .dylib libraries on Darwin.
The attached 'patch to the patch' fixes this.

Steps to reproduce

Install Django package on Darwin.

Technical details

  • System: (macOS Sierra 10.12.6)
  • Nix version: (nix-env (Nix) 1.11.13)
  • Nixpkgs version: ("17.09pre111304.5328102325")
  • Sandboxing enabled: (run grep build-use-sandbox /etc/nix/nix.conf)
@svniemeijer
Copy link
Contributor Author

--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -17,7 +17,11 @@ try:
     lib_path = settings.GDAL_LIBRARY_PATH
 except (AttributeError, EnvironmentError,
         ImportError, ImproperlyConfigured):
-    lib_path = None
+    from platform import system as _system
+    if _system() == "Darwin":
+        lib_path = "@gdal@/lib/libgdal.dylib"
+    else:
+        lib_path = "@gdal@/lib/libgdal.so"
 
 if lib_path:
     lib_names = None
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -26,7 +26,11 @@ try:
         lib_path = settings.GEOS_LIBRARY_PATH
     except (AttributeError, EnvironmentError,
             ImportError, ImproperlyConfigured):
-        lib_path = None
+        from platform import system as _system
+        if _system() == "Darwin":
+            lib_path = "@geos@/lib/libgeos_c.dylib"
+        else:
+            lib_path = "@geos@/lib/libgeos_c.so"
 
     # Setting the appropriate names for the GEOS-C library.
     if lib_path:

@LnL7 LnL7 added 6.topic: darwin Running or building packages on Darwin 6.topic: python labels Jul 27, 2017
@FRidh FRidh self-assigned this Jul 30, 2017
@joseph-long
Copy link
Contributor

👍 , just ran into this issue.

@FRidh
Copy link
Member

FRidh commented Oct 9, 2017

@svniemeijer you can use stdenv.hostPlatform.extensions.sharedLibrary as extension (and it includes the dot).

@FRidh
Copy link
Member

FRidh commented Oct 9, 2017

Pushed the fix 549188c to master and 17.09 as 8c00f93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin 6.topic: python
Projects
None yet
Development

No branches or pull requests

4 participants