-
Notifications
You must be signed in to change notification settings - Fork 20
PureOnMacOSX
Pure readily compiles from source on Mac OS X if you have the required tools and libraries on your system. But we really recommend installing it through MacPorts which has an abundance of other ports of Linux/Unix software in its repositories, including all dependencies of Pure and its addon modules. The Pure packages are maintained by Ryan Schmidt, who is also one of the MacPorts project managers, and by Albert Gräf, the principal developer of Pure.
We're dedicated to make the Pure experience on the Mac as complete and pleasant as possible. If you notice anything that's missing or not working properly on the Mac, then please file a ticket on MacPorts' bug tracker (if it's related to an existing port), report the issue on the Pure mailing list, or mail me directly at [email protected].
Please check the MacPorts website for information on how to set up MacPorts on your system. To install ports from MacPorts you use the port install
command. This needs to be run as root, via the sudo
command, so that you have the administrator rights necessary to install software on your computer. (Other variants of the port
command can and should be run as an ordinary user, e.g., if you want to retrieve information about the available ports. You can use the terminal application of your Mac to enter these commands in the shell.)
Once you got MacPorts up and running, installing the Pure interpreter and the online documentation should be as simple as:
sudo port install pure pure-docs
Pure is also in MacPorts' binary package repositories, so this will most likely not even need a compilation step. Afterwards try running pure
from the terminal to invoke the interpreter. At the interpreter's prompt, you can type expressions to be evaluated. For instance:
$ pure
__ \ | | __| _ \ Pure 0.62 (x86_64-apple-darwin13.2.0)
| | | | | __/ Copyright (c) 2008-2014 by Albert Graef
.__/ \__,_|_| \___| (Type 'help' for help, 'help copying'
_| for license information.)
Loaded prelude from /opt/local/lib/pure/prelude.pure.
> map (2^) (1..10);
[2.0,4.0,8.0,16.0,32.0,64.0,128.0,256.0,512.0,1024.0]
Running help
in the interpreter will fire up the online help. You can also try the examples distributed with Pure which will be installed under /opt/local/share/examples/pure
. To exit the interpreter, type quit
or ctrl+D
at the beginning of the interpreter's command line.
If you later decide that Pure is not for you and that you'd like to remove these packages again, you can do that with the port uninstall
command:
sudo port uninstall pure pure-docs
The following commands let you update your MacPorts installation so that you can always have the latest version of Pure and the other ports you have installed on your system:
sudo port selfupdate
sudo port upgrade outdated
The first command updates MacPorts' port database (and MacPorts itself if needed). The second command then upgrades any ports for which there are newer versions available in MacPorts (sudo port selfupdate
will tell you when it is time to do so). You can also upgrade specific packages like this:
sudo port upgrade pure pure-docs
Please also check the Using MacPorts section of the MacPorts documentation to find out how to employ the port
program to maintain your MacPorts installation.
MacPorts also offers a complete collection of Pure addon modules which cover a wide range of useful programming utilities and libraries from different categories. Once you have Pure itself up and running, you can install individual addon packages as usual with the port
command. For instance, if you're interested in math and scientific computing then you might want to get Pure's interfaces to the Octave numeric computation language and the Reduce computer algebra system, which can be installed as follows:
sudo port install pure-octave pure-reduce
The available addons are all in MacPorts' pure
category, so you can list them with port list category:pure
, or employ port info category:pure
to show a brief summary of each package. The package descriptions can also be viewed online in MacPorts' package browser. More comprehensive descriptions of the packages can be found in the Pure documentation; you can also view these with the help
command of the Pure interpreter (e.g., help pure-octave#
will bring up the documentation of the pure-octave module). Examples contained in the packages are available in the corresponding subdirectories of /opt/local/share/examples
after installation.
Using the pure
category, you can also just install everything that's available:
sudo port install category:pure
Installing these packages for the first time will pull in quite a few dependencies in the form of other MacPorts packages, so this can take a while. The same command, using port uninstall
in lieu of port install
can be used to remove all addon packages if you no longer need them.
For your convenience, we also offer some additional OS X-specific packages below which will make your life easier when working with Pure on the Mac. These are described below.
As already mentioned, the help
command in the Pure interpreter will open the online help in a browser. By default, it uses w3m, a text-based browser readily available in MacPorts. Use the q
key to exit from w3m when done reading the online help. The same kind of help browser is also available in Emacs and Aquamacs, see below.
Using w3m has the advantage that you can read the online help right there in the interpreter, without having to switch to another window. However, w3m may take some time getting used to, and it also keeps you from interacting with the interpreter while reading, so you may prefer to use your standard web browser instead. Any standards-compliant html browser will do. To these ends, just put the following line into your .bash_profile file:
export PURE_HELP=open
This will take effect next time you open a shell in a terminal window and launch the Pure interpreter in it. The html pages of the online help will then open in your default web browser in a separate window, and the interpreter will immediately be ready again to accept your commands.
You might want to consider using Aquamacs, an excellent, free and Mac-friendly (native Aqua) port of Emacs, as an option to edit and run your Pure scripts using Pure's Emacs mode. This provides you with syntax highlighting, online help, and the ability to invoke the Pure interpreter and run entire Pure scripts or individual code snippets directly in Aquamacs. To make it easy to install Pure mode in Aquamacs, we have put together a little package: aquamacs-pure-mode-1.2.pkg. The package includes both pure-mode and emacs-w3m (the latter uses w3m, already discussed above, to browse the Pure documentation in Aquamacs).
Note: This is an unsigned package, so you may need to override Gatekeeper to allow installation. Instructions on how to do this can be found in the section labeled "How to open an app from a unidentified developer and exempt it from Gatekeeper" on this page.
The package can be installed either in your home directory or system-wide. It plugs into Aquamacs so that Pure mode should be available and enabled right away after installing the package.
Note: Pure mode also provides integration with the Pd computer music application (see below). If you want to use this, you still have to enable the definition of the pure-pd-pure-support
variable in the site-start.el file (if you installed the pure-mode package in your home directory, you can find this file under ~/Library/Application Support/Aquamacs Emacs/pure-mode/). Just uncomment the line with the definition so that the corresponding part of the file reads:
;; Enable Pd keybindings and menu.
(custom-set-variables '(pure-pd-pure-support t))
This will add a new Pd menu to the Pure mode menu. More information about this can be found in the pd-pure manual.
Pure can be also run as a plugin in the scientific editor TeXmacs, please check our TeXmacs wiki page for details. The plugin also works on Mac OS X, but isn't included in the MacPorts packages right now, so you'll have to install it manually. To make things easier, we have prepared a package which should help you get up and running quickly on the Mac. Here's what you'll need:
-
TeXmacs: There's a port for TeXmacs in MacPorts, but I could never get it to work, so I recommend going with one of the ready-made OS X packages from the TeXmacs website instead. The version that works best for me on Sierra is in the TeXmacs-1.99.4.dmg disk image. (YMMV, though, so check the link to find a version of the package that works for you.)
-
texmacs-pure-plugin-macosx.zip: This is a copy of the Pure TeXmacs plugin from the Pure sources, patched up so that the default Pure library path is set to
/opt/local/lib/pure
. (This matches the default MacPorts installation path, so everything should work out of the box.) The package contains two folders,packages
andplugins
. Just drop these into your~/.TeXmacs
folder (create the folder if needed).
In principle, the plugin should be ready to go now, but there still are some additional bits and pieces that are needed to enable some of the more advanced functionality of the plugin, so read on.
-
We strongly recommend to install the pure-reduce package from MacPorts (
sudo port install pure-reduce
). This is optional, but you'll need this to make the math output work, and to provide integration with the Reduce computer algebra system. -
Finally, make sure that you have the TeXmacs-formatted Pure documentation files installed. This is available as an option of the MacPorts pure-docs package (install with
sudo port install pure-docs +tmdocs
).
After finishing the installation, you can fire up TeXmacs and kick the tires. If everything was installed properly then you should be able to find some Pure-related items in TeXmacs' Insert | Session
menu. Create a new document and try the Insert | Session | Pure
command to insert a basic Pure session. The interpreter should start up right inside the TeXmacs document and leave you at its command prompt, where you can start evaluating Pure expressions. More information can be found in TeXmacs' help menu, under Help | Plug-ins | Pure
.
Here are some common pitfalls you may run into, with some remarks that will hopefully help you get Pure running smoothly in TeXmacs, as it's supposed to:
-
If the Pure sessions don't show up in the menu after installing the plugin, try
Tools | Update | Plugins
. -
If the Pure sessions are working, but the
Pure
menu (which appears next to theInsert
menu when the cursor is in a Pure session) comes up empty, then most likely you forgot to install the Pure documentation files (see above). Once you install these, thePure
menu will show a few options to access the Pure online help when inside a Pure session, and the TeXmacs toolbar will also have an additional?
button which does the same. Also note that outside of Pure sessions the Pure menu won't be available, unless you also have Pure scripts enabled in a document (Document | Scripts | Pure
menu option), in which case it also shows a few options for creating inline Pure snippets ("evaluation tags" and "switches" in TeXmacs parlance).
Pure has very good support for interfacing with Miller Puckette's Pd, a popular graphical multimedia programming environment and free Max/MSP alternative. A brief overview of these facilities can be found on the Pure Data wiki page. The following packages are all available in MacPorts:
-
The pd-pure package lets you write Pd externals in Pure. It can be installed with:
sudo port install pd-pure
. -
The pd-faust package provides you with a dynamic Faust module loader for Pd. It can be installed with:
sudo port install pd-faust
(please note that this will also pull in the pd-pure package which is needed to run pd-faust). -
The faust2pd package provides a little helper script which lets you generate Pd GUI patches from Faust programs. This is needed for the
faust2puredata
script included in the Faust distribution. It can be installed with:sudo port install faust2pd
. (Note that you do not need this to run pd-faust, which already includes an improved variant of faust2pd, please check the documentation for details.)
After installation you'll find the faust2pd
executable in /opt/local/bin
(which will be on your PATH
so that you can run it on the command line), and the pd-pure and pd-faust externals will be in /opt/local/lib/pd/extra
.
There's currently no port for Pd in MacPorts, so you'll have to install one of the available binary Pd distributions for the Mac. Miller Puckette's "vanilla" Pd, Christoph Steiner's Pd-Extended and Jonathan Wilkes' Mac port (nick-named "Purr Data") of Ico Bukvic's Pd-l2ork are all known to work. (As vanilla Pd comes without any 3rd party externals, and Pd-extended hasn't been updated since 2013, we'd recommend Purr Data, which is relatively new, actively maintained, has all the latest bugfixes, and offers pretty much all of Pd-extended's features and much more. A quick introduction to Purr Data can be found here.)
For 64 bit Intel Macs, you'll need a 64 bit version of Pd, Pd-Extended or Pd-l2ork to use the externals. At the time of this writing, the latest versions can be found here:
-
Pd-extended: https://sourceforge.net/projects/pure-data/files/pd-extended/
-
Purr Data: https://agraef.github.io/purr-data/
These applications normally expect to find their externals on the Pd library path (usually /Library/Pd
for system-wide and ~/Library/Pd
for personal installation on the Mac, please see the Pd FAQ for details; for Pd-l2ork the directory is named Library/Pd-l2ork
instead). So you need to tell them where to find the Pure-related externals installed from MacPorts. The easiest way to do this is to just add /opt/local/lib/pd/extra
to the list of search paths in Pd's Preferences
dialog.
A better way, which also makes sure that the help patches in the faust
and pure
packages and the helper abstractions under extra
are found without any further ado, is to create symbolic links to these items in your ~/Library/Pd
or ~/Library/Pd-l2ork
folder (which needs to be created if it doesn't exist yet). For vanilla Pd, this can be done from the command line as follows (omit the last line if you only installed pd-pure):
mkdir -p ~/Library/Pd
ln -s /opt/local/lib/pd/extra/pure* ~/Library/Pd
ln -s /opt/local/lib/pd/extra/faust ~/Library/Pd
For Purr Data a.k.a. Pd-l2ork you'll have to substitute Pd-l2ork
for Pd
, i.e.:
mkdir -p ~/Library/Pd-l2ork
ln -s /opt/local/lib/pd/extra/pure* ~/Library/Pd-l2ork
ln -s /opt/local/lib/pd/extra/faust ~/Library/Pd-l2ork
Please note that after installation, pd-pure and, if you installed it, pd-faust still need to be activated by adding them to Pd's startup libraries, as described in the pd-pure and pd-faust documentation. The precise steps are slightly different depending on which Pd version you use, but generally you can just go to the Startup
options in the Preferences
dialog and add pure
and, if you installed it, faust/pdfaust
there, in that order. Another possibility is to add the options -lib pure -lib faust/pdfaust
in the Startup flags
field.
After committing these changes and restarting the Pd application you should see something similar to the following message in the Pd main window, which indicates that pd-pure was loaded and is ready to go:
pd-pure 0.24 (pure-0.66) (c) 2009-2017 Albert Graef <[email protected]>
pd-pure: compiled for pd-0.45 on Feb 23 2017
Likewise, if you installed and activated pd-faust, you'll also see something like this message:
pd-faust 0.13 (c) 2011-2016 Albert Graef <[email protected]>
pd-faust: registered with pd-pure
Opening Pd's help browser from the Help
menu lets you peruse the available examples in the pure
and faust
folders which can be found under /opt/local/lib/pd/extra
, or you can just open these folders in Finder and launch the examples from there.
Note that in order to write your own Faust programs for use with pd-faust, you'll also need Grame's Faust compiler which is available in MacPorts, too; please check the Faust wiki page for details.
Other related software can be found on my personal Github page. Some interesting items there are, e.g., the pd-lv2plugin and pd-mdnsbrowser externals, for which you can find Mac binaries in the Downloads sections of these repositories. These externals all require pd-pure to run.
Pure's Tcl/Tk module (pure-tk) can optionally interface to VTK which allows you to do advanced 3D graphics and scientific visualizations using VTK's Tcl/Tk bindings. There's also an interface to Peter G. Baum's and William J. Giddings' Tcl-Gnome/GTK bridge Gnocl which lets you develop Gnome/GTK applications using pure-tk. You can live without these, but then the Pure VTK and Gnocl examples won't run and you'll miss out on some really powerful extensions of the basic Tcl/Tk interface.
To make VTK and Gnocl work on the Mac, you'll need some Tcl/Tk modules which aren't available in MacPorts right now. (There's a port of VTK 5.x in MacPorts, but it lacks the required Tk modules and thus isn't very useful for VTK development using Tcl/Tk.) These can all be made to work when compiling recent versions of VTK and Gnocl from source, but the process isn't straightforward. The main complication is that VTK needs to be linked against Apple's Tcl/Tk system framework included in OS X (rather than MacPorts' Tcl/Tk version) to make the Tk integration work. Thus, in order to use VTK and Gnocl via Pure's Tcl/Tk interface, you need special versions of pure-tk, Gnocl and VTK which are all linked against the OS X Tcl/Tk system libraries.
Until these become available in MacPorts, we provide 64 bit Intel binaries of pure-tk and the relevant dependencies below. Please note that these libraries have all been built on Mavericks and so they will require a fairly recent OS X version (OS X 10.9.2+ has been tested, earlier OS X versions might or might not work). All binaries are linked against the OS X Tcl/Tk 8.5 system libraries. Gnocl also requires the Gnome and GTK libraries from MacPorts and their dependencies.
The following packages are available:
-
pure-tk-0.5-macosx-x86_64.zip: This is a version of the pure-tk module linked against the OS X Tcl/Tk 8.5 system libraries. Use this as a drop-in replacement for the pure-tk package from MacPorts. The files in this package go into the Pure library directory at
/opt/local/lib/pure
. -
gnocl-0.9.96-macosx-x86_64.zip: This package contains the Gnocl Tcl module and some useful addon modules (GnoclBuilder, GnoclCanvas and GnoclGconf). They are linked against the OS X Tcl/Tk 8.5 system libraries and the Gnome and GTK libraries from MacPorts (you'll need at least libgnome, libgnomecanvas, libgnomeui, libglade2, libnotify and gconf; the following command will install all of these:
sudo port install libgnome libgnomecanvas libgnomeui libglade2 libnotify
). The package unzips intoLibrary/Tcl
, so it should be enough to just unzip the package in your home directory to have the package contents installed in the right locations. -
vtk-6.1-tcltk-macosx-x86_64.zip: This contains the Tcl/Tk modules from VTK along with all required libraries. They are linked against the OS X Tcl/Tk 8.5 system libraries. Like the Gnocl package, you can simply unzip this package in your home directory to have the files installed in your
~/Library/Tcl
folder.
Before you use these libraries with the pure-tk module, we recommend checking that the Gnocl and VTK modules can be loaded by the Tcl interpreter. This can be done by running /usr/bin/tclsh
from the command line and entering the following Tcl commands:
package require vtk
package require Gnocl
package require GnoclBuilder
package require GnoclCanvas
package require GnoclGconf
(Make sure that you really run this with the system Tcl shell /usr/bin/tclsh
; if you get a bunch of "can't find package" error messages instead then most likely you invoked the wrong Tcl shell.)
If everything works as it should, then these commands should print the package version numbers (6.1 for vtk
, 0.9.96 for Gnocl
and GnoclBuilder
, 0.9.95 for GnoclCanvas
and GnoclGconf
). If you get a bunch of error messages instead, then most likely some required libraries are missing; check that you have the system Tcl/Tk framework and the MacPorts Gnome/GTK libraries installed. (In addition to the Gnome/GTK libraries from MacPorts you'll need at least Xcode and the XQuartz X server; please consult the MacPorts installation instructions for information on how to get these up and running.)