As someone who lived through the transition, Mac OS X was a huge leap forward. It made not only the classic Mac OS feel dated, but also Microsoft’s competing Windows XP, which wouldn’t even ship until August of that year. But the initial release of Mac OS X 10.0 was basically a paid beta. “This week’s ‘Mac virus’ scare turned out to be nothing more than a worm for Mac OS X that propagates through iChat and infects local Mac applications. OSX/Leap.A is a wake up call to Mac.
Use Time Machine, the built-in backup feature of your Mac, to automatically back up your personal data, including apps, music, photos, email, and documents. Having a backup allows you to recover files that were deleted, or that were lost because the hard disk (or SSD) in your Mac needed to be erased or replaced. Learn how to restore your Mac from a backup.
To create backups with Time Machine, all you need is an external storage device. After you connect the storage device and select it as your backup disk, Time Machine automatically makes hourly backups for the past 24 hours, daily backups for the past month, and weekly backups for all previous months. The oldest backups are deleted when your backup disk is full.
Connect one of the following external storage devices, sold separately. Learn more about backup disks that you can use with Time Machine.
After you select a backup disk, Time Machine immediately begins making periodic backups—automatically and without further action by you. The first backup may take a long time, but you can continue using your Mac while a backup is underway. Time Machine backs up only the files that changed since the previous backup, so future backups will be faster.
To start a backup manually, choose Back Up Now from the Time Machine menu in the menu bar. Use the same menu to check the status of a backup or skip a backup in progress.
This article discusses how to import the Python libraries in a Python program.
The Leap Motion Python API is provided as a Python extension module containing both Python and native code.The Python API supports Python 2.7.
Windows | Mac | Linux | |
---|---|---|---|
Python module | lib/Leap.py | lib/Leap.py | lib/Leap.py |
32-bit native libraries | lib/x86/LeapPython.pyd lib/x86/Leap.dll | lib/x86/LeapPython.so lib/x86/libLeap.so | |
64-bit native libraries | lib/x64/LeapPython.pyd lib/x64/Leap.dll | lib/x64/LeapPython.so lib/x64/libLeap.so | |
Universal binary native libraries | lib/LeapPython.so lib/libLeap.dylib |
You can find these libraries in the lib folder of the Leap Motion SDK download package. On Windows and Linux, you must use the x86 versions of the native libraries for 32-bit versions of Python and the x64 versions for 64-bit versions of Python.
Leap Motion does not provide these libraries in a standard Python package or install them on end-user computers. Treat the libraries as internal modules of your application. It is your responsibility to distribute the libraries with your application.
To import the Leap module, the library files must be placed in a location where the Python runtime can find them. The easiest way to do this is to put them in the same directory as your application source code. Python looks in the same directory as the importing file for imported modules.
If you prefer to keep the libraries in a separate directory from your source code, you can add the path to the Leap Motion libraries to the Python sys.path list before importing the Leap module:
For example, if your project file structure looked like:
You could copy the Leap Motion libraries to the lib subfolder (making sure to copy the appropriate files for your platform and architecture). For example, on a Mac, your project would look like:
From the Snakes.py or Ladders.py source, you could then import the Leap module with the following:
This import method assumes that your Python file is always run with the current working directory set to the folder containing your main Python file. To allow the import to work when the main application file is invoked from any directory, you can use the Python inspect module to get the directory containing your source file and then set the sys.path relative to that folder:
Note: If you are developing applications solely for your own use, you can put the Leap module and its supporting native libraries in any convenient location: for example, in one of the folders listed in the Python sys.path variable, a folder referenced in your PYTHONPATH environment variable, etc – just remember where you put them when it comes time to update your Leap Motion SDK. However, since the Leap module isn’t currently available through standard Python package managers, copying the Leap Motion libraries to one of the standard Python module search locations isn’t recommended. Doing so could create conflicts if multiple applications try to install their own version of the Leap Motion libraries.
To support both 32-bit and 64-bit architectures at the same time on Windows and Linux, you can use a run-time check for the architecture and then set the sys.path to reference the correct files. On Mac, the Leap Motion libraries are universal binaries that support both architectures, so this technique is not needed.
Using the hypothetical SnakesAndLadders project as an example again, you would copy both sets of library files to separate folders within the application, for example:
And then reference the proper Leap module at run time:
The same technique could be extended to support multiple platforms at the same time.
To use the Leap Motion Python libraries with an alternate Python 2.7 distribution on Mac or Linux (i.e HomeBrew or MacPorts, etc.) or with a self-built version of Python, you must update the LeapPython.so loader path to reference the desired instance of Python.
First, run the otool utility to display the current loader paths:
Which will display output similar to:
The line starting with, /Library/Frameworks/Python.framework/Versions/2.7/Python is the reference to Python, which needs to be changed with the install_name_tool utility.
Second, run the install_name_tool utility to update the Python reference to the desired location. For example:
Note:otool and install_name_tool are standard Linux and OS X command line utilities.
The LeapPython library included in the Leap Motion SDK supports only Python 2.7. However, the SDK also includes the SWIG interface file used to generate the LeapPython source code, so advanced users can generate and compile their own version of LeapPython. For instructions, refer to Generating a Python 3.3.0 Wrapper with SWIG 2.0.9 in our support knowledge base.