diff -r b167df2912d6 Doc/using/mac.rst --- a/Doc/using/mac.rst Sun Jun 08 00:00:13 2014 +1000 +++ b/Doc/using/mac.rst Sat Jun 07 14:25:05 2014 -0700 @@ -1,86 +1,93 @@ .. _using-on-mac: -*************************** -Using Python on a Macintosh -*************************** +********************* +Using Python on a Mac +********************* :Author: Bob Savage -Python on a Macintosh running Mac OS X is in principle very similar to Python on +Python on a Mac running is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the IDE and the Package Manager that are worth pointing out. .. _getting-osx: -Getting and Installing MacPython -================================ -Mac OS X 10.8 comes with Python 2.7 pre-installed by Apple. If you wish, you -are invited to install the most recent version of Python 3 from the Python -website (http://www.python.org). A current "universal binary" build of Python, -which runs natively on the Mac's new Intel and legacy PPC CPU's, is available -there. +Python +====== -What you get after installing is a number of things: - -* A :file:`MacPython 3.4` folder in your :file:`Applications` folder. In here - you find IDLE, the development environment that is a standard part of official - Python distributions; PythonLauncher, which handles double-clicking Python - scripts from the Finder; and the "Build Applet" tool, which allows you to - package Python scripts as standalone applications on your system. - -* A framework :file:`/Library/Frameworks/Python.framework`, which includes the - Python executable and libraries. The installer adds this location to your shell - path. To uninstall MacPython, you can simply remove these three things. A - symlink to the Python executable is placed in /usr/local/bin/. +Mac OS X 10.9 comes with Python pre-installed. It comes with Python 2.7 by default. +If you wish, you are invited to install the most recent version of Python 3 from the Python +website (http://www.python.org). The Apple-provided build of Python is installed in :file:`/System/Library/Frameworks/Python.framework` and :file:`/usr/bin/python`, respectively. You should never modify or delete these, as they are -Apple-controlled and are used by Apple- or third-party software. Remember that -if you choose to install a newer Python version from python.org, you will have +Apple-controlled and are used by Apple- or third-party software. + +If you are completely new to Python you should start reading the tutorial introduction +in the `getting started guide`. + +.. _getting started guide: https://www.python.org/about/gettingstarted/ + + +Versions +======== + +You can check which version of Python you have by running the following +command on your terminal:: + + python --version + +If you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do. -IDLE includes a help menu that allows you to access Python documentation. If you -are completely new to Python you should start reading the tutorial introduction -in that document. +You can also use virtualenv_ to handle your various Python versions and environments. -If you are familiar with Python on other Unix platforms you should read the -section on running Python scripts from the Unix shell. +.. _virtualenv: http://virtualenv.readthedocs.org/en/latest/virtualenv.html How to run a Python script -------------------------- -Your best way to get started with Python on Mac OS X is through the IDLE -integrated development environment, see section :ref:`ide` and use the Help menu -when the IDE is running. +You can run your Python scripts in the following ways: -If you want to run Python scripts from the Terminal window command line or from -the Finder you first need an editor to create your script. Mac OS X comes with a -number of standard Unix command line editors, :program:`vim` and -:program:`emacs` among them. If you want a more Mac-like editor, -:program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see -http://www.barebones.com/products/bbedit/index.shtml) are good choices, as is -:program:`TextMate` (see http://macromates.com/). Other editors include -:program:`Gvim` (http://macvim.org) and :program:`Aquamacs` -(http://aquamacs.org/). +* **GUI**: one way to get started with Python on Mac OS X is through the IDLE integrated + development environment, see section :ref:`ide` and use the Help menu + when the IDE is running. Simply typing `idle` in your terminal should start + up a Python interpreter shell. -To run your script from the Terminal window you must make sure that -:file:`/usr/local/bin` is in your shell search path. +* **Terminal**: If you want to run Python scripts from the Terminal window command line + or from the Finder you first need an editor to create your script. + Mac OS X comes with a number of standard Unix command line editors, :program:`vim` and + :program:`emacs` among them. -To run your script from the Finder you have two options: + If you want a more Mac-like editor, :program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see http://www.barebones.com/products/bbedit/index.shtml) are good choices, as is + :program:`TextMate` (see http://macromates.com/). Other editors include + :program:`Gvim` (http://macvim.org), :program:`Aquamacs` + (http://aquamacs.org/), :program:`Sublime` (http://www.sublimetext.com/) + and :program:`PyCharm` (http://www.jetbrains.com/pycharm/). -* Drag it to :program:`PythonLauncher` + To run your script from the Terminal window you must make sure that + :file:`/usr/local/bin`. You can then run your Python script as follows:: + + echo "print ('Hello World')" > helloworld.py -* Select :program:`PythonLauncher` as the default application to open your - script (or any .py script) through the finder Info window and double-click it. - :program:`PythonLauncher` has various preferences to control how your script is - launched. Option-dragging allows you to change these for one invocation, or use - its Preferences menu to change things globally. + python helloworld.py + + +* **PythonLauncher**: To run your script from the Finder you have two options: + + * Drag it to :program:`PythonLauncher` + + * Select :program:`PythonLauncher` as the default application to open your + script (or any .py script) through the finder Info window and double-click it. + :program:`PythonLauncher` has various preferences to control how your script is + launched. Option-dragging allows you to change these for one invocation, or use + its Preferences menu to change things globally. .. _osx-gui-scripts: @@ -155,19 +162,6 @@ http://www.riverbankcomputing.co.uk/software/pyqt/intro. -Distributing Python Applications on the Mac -=========================================== - -The "Build Applet" tool that is placed in the MacPython 3.4 folder is fine for -packaging small Python scripts on your own machine to run as a standard Mac -application. This tool, however, is not robust enough to distribute Python -applications to other users. - -The standard tool for deploying standalone Python applications on the Mac is -:program:`py2app`. More information on installing and using py2app can be found -at http://undefined.org/python/#py2app. - - Other Resources ===============