Commits

Richo Healey committed cb1bf7e

Work without CoreLocation on non-darwin platforms

  • Participants
  • Parent commits 45da5f4

Comments (0)

Files changed (5)

 
 On OS X 10.6 (Mountain Lion) or later, you can enable Core Location in System Preferences, in the "Security" or "Security & Privacy" section.
 
+Hacking
+-------
+
+For hacking on OSX, you will likely want to install ``requires-corelocation.txt`` as well as ``requires.txt``.
+
 Using on the command-line
 -------------------------
 

File doko/__init__.py

 from collections import namedtuple
 import webbrowser
 
-import CoreLocation
+try:
+    import CoreLocation
+except ImportError:
+    # CoreLocation attempts will fail.
+    CoreLocation = None
+
 import requests
 import BeautifulSoup
 
     Fetch and return a Location from OS X Core Location, or throw
     a LocationServiceException trying.
     """
+    if not CoreLocation:
+        raise LocationServiceException('CoreLocation not available')
+
     m = CoreLocation.CLLocationManager.new()
 
     if not m.locationServicesEnabled():

File requirements-osx.txt

+pyobjc==2.4
+pyobjc-core==2.4
+pyobjc-framework-Accounts==2.4
+pyobjc-framework-AddressBook==2.4
+pyobjc-framework-AppleScriptKit==2.4
+pyobjc-framework-AppleScriptObjC==2.4
+pyobjc-framework-Automator==2.4
+pyobjc-framework-CFNetwork==2.4
+pyobjc-framework-CalendarStore==2.4
+pyobjc-framework-Cocoa==2.4
+pyobjc-framework-Collaboration==2.4
+pyobjc-framework-CoreData==2.4
+pyobjc-framework-CoreLocation==2.4
+pyobjc-framework-CoreText==2.4
+pyobjc-framework-DictionaryServices==2.4
+pyobjc-framework-EventKit==2.4
+pyobjc-framework-ExceptionHandling==2.4
+pyobjc-framework-FSEvents==2.4
+pyobjc-framework-InputMethodKit==2.4
+pyobjc-framework-InstallerPlugins==2.4
+pyobjc-framework-InstantMessage==2.4
+pyobjc-framework-LatentSemanticMapping==2.4
+pyobjc-framework-LaunchServices==2.4
+pyobjc-framework-Message==2.4
+pyobjc-framework-PreferencePanes==2.4
+pyobjc-framework-PubSub==2.4
+pyobjc-framework-QTKit==2.4
+pyobjc-framework-Quartz==2.4
+pyobjc-framework-ScreenSaver==2.4
+pyobjc-framework-ScriptingBridge==2.4
+pyobjc-framework-SearchKit==2.4
+pyobjc-framework-ServerNotification==2.4
+pyobjc-framework-ServiceManagement==2.4
+pyobjc-framework-Social==2.4
+pyobjc-framework-SyncServices==2.4
+pyobjc-framework-SystemConfiguration==2.4
+pyobjc-framework-WebKit==2.4

File requirements.txt

-pyobjc==2.4
-pyobjc-core==2.4
-pyobjc-framework-Accounts==2.4
-pyobjc-framework-AddressBook==2.4
-pyobjc-framework-AppleScriptKit==2.4
-pyobjc-framework-AppleScriptObjC==2.4
-pyobjc-framework-Automator==2.4
-pyobjc-framework-CFNetwork==2.4
-pyobjc-framework-CalendarStore==2.4
-pyobjc-framework-Cocoa==2.4
-pyobjc-framework-Collaboration==2.4
-pyobjc-framework-CoreData==2.4
-pyobjc-framework-CoreLocation==2.4
-pyobjc-framework-CoreText==2.4
-pyobjc-framework-DictionaryServices==2.4
-pyobjc-framework-EventKit==2.4
-pyobjc-framework-ExceptionHandling==2.4
-pyobjc-framework-FSEvents==2.4
-pyobjc-framework-InputMethodKit==2.4
-pyobjc-framework-InstallerPlugins==2.4
-pyobjc-framework-InstantMessage==2.4
-pyobjc-framework-LatentSemanticMapping==2.4
-pyobjc-framework-LaunchServices==2.4
-pyobjc-framework-Message==2.4
-pyobjc-framework-PreferencePanes==2.4
-pyobjc-framework-PubSub==2.4
-pyobjc-framework-QTKit==2.4
-pyobjc-framework-Quartz==2.4
-pyobjc-framework-ScreenSaver==2.4
-pyobjc-framework-ScriptingBridge==2.4
-pyobjc-framework-SearchKit==2.4
-pyobjc-framework-ServerNotification==2.4
-pyobjc-framework-ServiceManagement==2.4
-pyobjc-framework-Social==2.4
-pyobjc-framework-SyncServices==2.4
-pyobjc-framework-SystemConfiguration==2.4
-pyobjc-framework-WebKit==2.4
 BeautifulSoup==3.2.1
 requests==0.14.0
 Package information for doko package.
 """
 
+import sys
 from setuptools import setup
 
 VERSION = '0.1.0'
 
+requires = [
+        'BeautifulSoup==3.2.1',
+        'requests==0.14.0',
+]
+if sys.platform == 'sys':
+    for package in ('pyobjc==2.4', 'pyobjc-core==2.4', 'pyobjc-framework-CoreLocation==2.4'):
+        requires.append(package)
+
 setup(
         name='doko',
         description="Detect location using CoreLocation on OS X.",
                     'doko = doko:main',
                 ],
         },
-        install_requires=[
-            'pyobjc==2.4',
-            'pyobjc-core==2.4',
-            'pyobjc-framework-CoreLocation==2.4',
-            'BeautifulSoup==3.2.1',
-            'requests==0.14.0',
-        ],
+        install_requires=requires,
     )