Posts about macos (old posts, page 1)

2010-10-27 installing python and its components

  • Python is often pre-installed on your system or easy to download. More difficult is to get the essential packages (numpy, scipy, matplotlib, ipython) and their dependencies installed. Here, I list some of the possibilities.

on MacOsX: using MacPorts

  • A basic installation procedure is to use the enthought distribution,
  • Another route is to use MacPorts. It is a generic package manager inspired by what you get using Debian's apt scheme.
  • Once installed, do on the command-line
    • on Leopard:
      sudo port install py25-pil py25-numpy py25-scipy py25-ipython py25-matplotlib +cairo+latex+tkinter
      sudo python_select python25

      (Note: you may also use python26 on Leopard).

    • on Snow Leopard:
      sudo port install py26-numpy py26-scipy py26-ipython py26-matplotlib
      sudo port install py26-pyobjc2-cocoa py26-pil py26-distribute py26-pip py26-py2app python_select
      sudo port install vtk5 +carbon +qt4_mac +python26 py26-mayavi
      
      sudo python_select python26

      to install a bunch of useful python packages.

    • to get a package that is not available through macports, do:
      sudo easy_install progressbar
  • for visionEgg :
    sudo port install py26-opengl py26-game
    sudo easy_install visionegg
  • http://ipython.scipy.org/moin/Py4Science/InstallationOSX
  • on Snow Leopard, you'll have to follow these instructions.

Windows

Debian / Ubuntu

DistUtils, PIP & Easy Install

  • most of the time, there's a setup.py file:
    python setup.py install --prefix=~
  • See http://peak.telecommunity.com/DevCenter/EasyInstall
  • to install numpy (same for pylab, scipy, or visionegg), simply do
    easy_install numpy
  • most of the cases, on a test server or a single-user machine, you may find more useful to install in your home dirtectory, for instance:
    easy_install -d ~/lib/python2.5/site-packages/ numpy
  • to upgrade, use
    easy_install -U numpy
  • you can browse the list of available packages.
  • for pip: http://pip.openplans.org/
  • you may create a script tu update all packages:
    for i in `python -c "for dist in __import__('pkg_resources').working_set: print dist.project_name"`:
    do
    echo "`easy_install -U $i`"
    echo "++++++++++++++++++++++++++++++++++++++++++++++++++"
    done
  • to install PIL, use
    easy_install -d lib/python2.6/site-packages/ --find-links http://www.pythonware.com/products/pil/ Imaging

SVNs: bleeding edge versions

  • numpy
    svn co http://svn.scipy.org/svn/numpy/trunk numpy
    cd numpy
    python setup.py build
    sudo python setup.py install
    rm -rf build
    cd ..
  • SciPy
    svn co http://svn.scipy.org/svn/scipy/trunk scipy
    cd scipy
    python setup.py build
    sudo python setup.py install
    rm -rf build
    cd ..
  • pylab
    svn co https://svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib
    cd matplotlib
    python setup.py build
    sudo python setup.py install
    sudo rm -rf build
    cd ..
  • SPE
    svn checkout svn://svn.berlios.de/python/spe/trunk/_spe
  • PIL
    wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
    tar zxvf  Imaging-1.1.6.tar.gz
    cd Imaging-1.1.6
    python setup.py build_ext -i
    python selftest.py
    python setup.py install
  • gsl
    cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/gsl login
    cvs -d :pserver:anoncvs@sources.redhat.com:/cvs/gsl checkout gsl
    cd gsl/
    ./autogen.sh
    ./configure --enable-maintainer-mode
    make
  • pytables
    • dependency on HDF
      wget ftp://ftp.hdfgroup.org/HDF5/current/src/hdf5-1.6.5.tar.gz
      tar zxvf hdf5-1.6.5.tar.gz
      cd hdf5-1.6.5
      ./configure --enable-cxx
      make
      make install
      h5ls -r  Documents/Sci/projets/virtualV1/experiments/benchmark_one/results/benchmark_retina_high.h5
      wget http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/Pyrex-0.9.5.1a.tar.gz
      tar zxvf Pyrex-0.9.5.1a.tar.gz
      cd Pyrex-0.9.5.1a
      python setup.py build
      sudo python setup.py install
      rm -rf build
    • install
      wget http://puzzle.dl.sourceforge.net/sourceforge/pytables/pytables-1.4.tar.gz
      #svn co http://pytables.org/svn/pytables/trunk/ pytables
      tar zxvf pytables-1.4.tar.gz
      cd pytables-1.4
      export DYLD_LIBRARY_PATH=/sw/lib # or in .bashrc
      python setup.py install --hdf5=/sw
      cd ..
  • pygtk
    wget http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.8/pygtk-2.8.6.tar.bz2
    tar xvfj pygtk-2.8.6.tar.bz2
    cd pygtk-2.8.6
    .configure
    make
    sudo make install    # or without sudo as root
    cd ..

2010-09-27 bundling using py2app

2010-09-28 05:44:57

using macports

  • install py2app :
    sudo port install -u  py26-py2app
  • there's sometimes a problem in py2app to check the right architecture to build on:
    find /opt/local -name apptemplate/setup.py
    sudo vim /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/py2app/apptemplate/setup.py
  • in this case, this can be done by adding the following lines to py2app/apptemplate/setup.py:
    gPreBuildVariants = [
        ...
        {
            'name': 'main-x86_64',
            'target': '10.6',
            'cflags': '-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch x86_64',
            'cc': 'gcc-4.2',
        },
        {
            'name': 'main-i386',
            'target': '10.6',
            'cflags': '-isysroot / -arch i386',
            'cc': 'gcc-4.2',
        },
        ...
    ]

    . So, change to

    gPreBuildVariants = [
        {
            'name': 'main-x86_64',
            'target': '10.5',
            'cflags': '-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch x86_64',
            'cc': 'gcc-4.2',
         },
    #     {
    #         'name': 'main-universal',
    #         'target': '10.5',
    #         'cflags': '-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch ppc64 -arch x86_64',
    #         'cc': 'gcc-4.2',
    #     },
    #     {
    #         'name': 'main-fat3',
    #         'target': '10.5',
    #         'cflags': '-isysroot / -arch i386 -arch ppc -arch x86_64',
    #         'cc': 'gcc-4.2',
    #     },
    #     {
    #         'name': 'main-intel',
    #         'target': '10.5',
    #         'cflags': '-isysroot / -arch i386 -arch x86_64',
    #         'cc': 'gcc-4.2',
    #     },
    #     {
    #         'name': 'main-fat',
    #         'target': '10.3',
    #         'cflags': '-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc',
    #         'cc': 'gcc-4.0',
    #     },
    ]

using homebrew

2010-08-31 managing packages on MacOsX : testing HomeBrew

2010-08-31 09:11:31
  • a newcomer after fink and MacPorts: http://wiki.github.com/mxcl/homebrew/
  • advertised here
  • install
     $ ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
    ==> This script will install:
    /usr/local/bin/brew
    /usr/local/Library/Formula/...
    /usr/local/Library/Homebrew/...
    
    Press enter to continue
    ==> Downloading and Installing Homebrew...
    ==> Installation successful!
  • fix permissions
    $ sudo chown -R `whoami` /usr/local
  • to install python specific stuff, use pip:
    brew install pip
    echo '[install]
    install-scripts=/usr/local/Cellar/PyPi/2.6/bin
    install-data=/usr/local/Cellar/PyPi/2.6/share' > ~/.pydistutils.cfg
    pip install ipython
  • this is with the exception of numpy + scipy, the latter needing
    cd tmp
    svn co http://svn.scipy.org/svn/numpy/trunk numpy
    pip install numpy
    
    brew install suite-sparse
    svn co http://svn.scipy.org/svn/scipy/trunk scipy
    pip install scipy

2010-08-30 Terminal.app shortcuts

2010-08-31 09:35:58
  • from http://superuser.com/questions/52483/terminal-tips-and-tricks-for-mac-os-x
    To make Ctrl← and Ctrl→  useful again, that is going a word forward or backward like they usually do on Linux, you must make Terminal.app send the right string to the shell. In the preferences, go to the Settings tab and select your default profile. Go to Keyboard and set control cursor left and control cursor right to send string \033b and \033f respectively.
    
    While your're at it, you can also fix Home (\033[H), End (\033[F), Page Up (\033[5~) and Page Down (\033[6~) so that they send those keys to the shell instead of scrolling the buffer.

2010-08-03 compiling OpenCV on MacOSX 10.6

2010-08-03 12:14:29

using macports

  • it works now with macports:
    sudo port install -u opencv +python26 +tbb

latest SVN

  • compiling here along with MacTex...
  • from http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port
    svn co https://code.ros.org/svn/opencv/trunk/opencv
    cd opencv # the directory containing INSTALL, CMakeLists.txt etc.
    mkdir build
    cd build
    cmake -D CMAKE_OSX_ARCHITECTURES=x86_64 -D WITH_FFMPEG=ON -D BUILD_EXAMPLES=ON -D BUILD_LATEX_DOCS=ON -D PDFLATEX_COMPILER=/usr/texbin/pdflatex -D BUILD_NEW_PYTHON_SUPPORT=ON  -D PYTHON_LIBRARY=/opt/local/lib/libpython2.6.dylib -D PYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Headers ..
    make -j4
    sudo make install
  • I had to rebuild some ports
    sudo port install ilmbase
    port provides /opt/local/lib/libIlmImf.dylib
    sudo port install openexr
    sudo port install libdc1394

    and recompile

  • then could run
    cd ../samples/python/
    python camera.py

using homebrew

  • another route is homebrew: http://gist.github.com/519418 / :
    $ brew info opencv
    opencv 2.1.1-pre
    http://opencv.willowgarage.com/wiki/
    Depends on: cmake, pkg-config, libtiff, jasper, tbb
    /usr/local/Cellar/opencv/2.1.1-pre (96 files, 37M)
    
    The OpenCV Python module will not work until you edit your PYTHONPATH like so:
      export PYTHONPATH="/usr/local/lib/python2.6/site-packages/:$PYTHONPATH"
    
    To make this permanent, put it in your shell's profile (e.g. ~/.profile).
    
    http://github.com/mxcl/homebrew/commits/master/Library/Formula/opencv.rb

2010-03-15 securing the server

This page is word-editable, please edit if you find an error.

  • SSH (Secure Shell) is installed on most systems (here GnuLinuxUbuntu and MacOsX) so don't panic about compilations (try Putty on Windows). Try a simple ssh -V to check version or which ssh to locate the binary.
  • Thanks to ssh, you can transport all your data (accessing files, merging repositories, lauching remote X programs) transparently using a secure connection. Thanks to tunneling, this is also simpler thus more secure for your computer and your provider. Having all security located in one interface sure is a big advantage: once your SSH communication channel is set-up, you should only focus on what you wish to do (SVN, etc...).
  • Most documentation may be found in man ssh, man ssh-keygen (remember that thanks to the underlying pager system, you can search for a keyword, for instance hello, by typing \hello[ENTER]). Many other sources of help exist, such as this FAQ

Setting up SSH: spreading the good keys

  1. There are many ways to authenticate your session, but mainly password or keys. Keys are to be preferred to avoid typing your password 10 times a day. It is also most secure (you type your key's password locally and not remotely).
  2. Generate a private/public key pair. Simple command to do this:
    ssh-keygen -t rsa
  3. Copy the key to the
    ssh-copy-id -i ~/.ssh/id_rsa.pub username@host

    . this can be also be done using

    scp ~/.ssh/id_rsa.pub username@host:~/mykey.pub
    ssh username@host
    cat mykey.pub >> .ssh/authorized_keys
  4. Now try logging into the remote machine again from local
    ssh REMOTE_USERNAME@remote_host
  5. Check that your public key is in the list of authorized keys: .ssh/authorized_keys.
  6. Change password regularly:
    ssh-keygen -p

    It is not advised to put an empty pass-phrase, rather use key agent (see below).

Aliasing

  • it is possible to create alias of the ssh binary to hostnames... but more simply, you may put
    alias myserver='ssh -Y -p2221 myuser@myserver.domain.com'

    where 2221 is here the port used by the SSH server on myserver.domain.com

  • more cleanly, you may edit your  .ssh/config file with:
    Host myserver.domain.com
            User myuser
            Port 2221

    Be careful that properties are right : chmod 600 ~/.ssh/config

key agent

  • An agent loads your keys on the local machines:
    • it's more secure, since all passwords are typed locally, you only send encrypted authentifications
    • it's more practical, since you type your password once per session
  • http://www.sshkeychain.org/mirrors/SSH-with-Keys-HOWTO/
  • GUI interface on MacOsX : http://www.sshkeychain.org/
    • install with macports using sudo port install SSHKeychain, you'll find it in /Applications/MacPorts

tunnels

securing the server

  • Robots usually try common name / password combinations on your SSH server. If you're the only user admin_name of your server you may use in the SSH server configuration file (usually /etc/ssh/sshd_config) the option AllowUsers admin_name to restrict access to user admin_name and avoid brute force attacks. Since robots are most of the time dumb, they'll get an immediate acces denied response to any connection request.
  • Robots usually sniff port 22. To change the port which is listened by the SSH server, either modify the default port in the SSH server configuration file (usually /etc/ssh/sshd_config). Another way is to use your router to redirect the outside port (for instance 2221) to the default port of your server.

2009-11-26 inkscape native

2009-11-26 09:27:37
  • trying out http://wiki.inkscape.org/wiki/index.php/CompilingMacOsX#Building_Aqua_November_2009
  • build dependencies
    sudo port install autoconf automake
    
    sudo port install librsvg libwpd libwpg libcroco
    
    sudo port install libxslt boost boehmgc gtkmm lcms intltool popt
    
    sudo port install cairo +quartz+no_x11 cairomm pango +quartz+no_x11 poppler +quartz gtk2 +quartz
    
    sudo port install gsl
    
    sudo port install hicolor-icon-theme
    
    sudo port install subversion
    
    sudo port install libxml2 libxslt
    
    # optional to speed up the compiling process:
    sudo port install ccache
    export CC="ccache gcc"
    export CXX="ccache g++"
  • getting the sources
    cd tmp
    svn co https://inkscape.svn.sourceforge.net/svnroot/inkscape/inkscape/trunk inkscape
    cd inkscape/packaging/macosx/
  • compile
    # Edit the file osx-build.sh to remove the configure option --enable-osxapp
    # (line 24)
    
    # I used TextWrangler for this, pico or another command line editor will do the same.
    
    # Back to the terminal:
    
    # configure it:
    sudo ./osx-build.sh c
    
    # build it:
    sudo ./osx-build.sh b
    
    # install it:
    sudo ./osx-build.sh i
    
    # test it:
    ../../Build/bin/inkscape

    compiles ok :-), but crashes rather rapidly :-(

2009-08-29 Tips on Filesystems, security and al on mac os x

  • mount with AFP sharepoints from the command line (thanks to this hint) :
    # mount_afp [-i] [-o options] afp_url node
    mkdir /Volumes/truc
    mount_afp afp://user:PASSWORD@server/truc /Volumes/truc
    umount /Volumes/truc
    rmdir /Volumes/truc

finder nags when changing a file's extension

  • read the default value (should be 0)
    defaults read com.apple.finder FXEnableExtensionChangeWarning
  • change it:
    defaults write com.apple.finder FXEnableExtensionChangeWarning False

Make spell check show only desired languages

HFS+

  • Mac OS X Filesystems
  • One feature of HFS volumes is that fle are referred to as links: for instance you can read a PDF file while changing the name at the same time. No problem!
  • Safely remove '._' files created by HFS(+)
    find . -name '._*' -print0 | xargs -0 rm

Spotlight

  • to remove the remaining index files on the volume using the command:  sudo mdutil -E /Volumes/volume_name  utilitaires CLI :
    sudo mdutil --help
    mdutil: unrecognized option `--help'
    usage: mdutil -pE volume ...
            mdutil can be used to manage the metadata stores used by Spotlight.
            -p              publish metadata for the provided volumes.
            -i (on|off)     set indexing status for the provided volumes.
            -E              erase the master copy of the metadata stores for the provided volumes.
            -s              print indexing status for the provided volumes.

System & Security

nmap

  • to scan for open ports on a remote machine :
    sudo nmap -T3 -vv -sS -p 1-65535 -P0 google.com
    Starting nmap 3.81 ( http://www.insecure.org/nmap/ ) at 2006-04-05 16:32 CEST
    Initiating SYN Stealth Scan against google.com [65535 ports] at 16:32
    Discovered open port 80/tcp on google.com
    SYN Stealth Scan Timing: About 2.18% done; ETC: 16:55 (0:22:26 remaining)

Dash board

  • Don't use Dashboard? No particular reason to leave it running, consuming memory. Following http://www.macosxhints.com/article.php?story=20050723123302403, you can turn Dashboard off by doing:
    defaults write com.apple.dashboard mcx-disabled -boolean YES
    killall Dock
  • Unsurprisingly, you change YES to NO to re-enable Dashboard:
    defaults write com.apple.dashboard mcx-disabled -boolean NO
    killall Dock

Unix - X11

Change login window on (Snow) Leopard

  • disrupted by the look of the plasma flames? think it looks like a cheap star trek sundae? check http://paulstamatiou.com/2007/10/31/how-to-change-leopards-login-wallpaper :
    cd /System/Library/CoreServices
    sudo rm DefaultDesktop.jpg
    #sudo mv DefaultDesktop.jpg DefaultDesktop_old.jpg # if you want to keep the Aurora stuff (it stills around, do a 'locate Aurora'
    sudo ln -s /Library/Desktop\ Pictures/Nature/Stones.jpg DefaultDesktop.jpg

2008-08-29 keyboard

Touches spéciales (unix) sur clavier Mac francais

Merci a http://busy.lab.free.fr/mac/ !

backslash \ shift + option + /
pipe, or | shift + option + L
tidle ~ option + N
simple quote ' 4 key, that's to say a regular ' on any keyboard I guess.
opening brace { option + (
closing brace } option + )
opening square bracket [ shift + option + (
closing square bracket ] shift + option + )

Apple also got the habit to give it's own special names to some keys:

  • ctrl is called, well, control. So far, so good.
  • the alt key (with a funy sign under it) is called option.
  • the key with a funny sharp and the Apple logo is called command (for we are supposed to be so creative Apple users I think), or sometimes more logically apple.

keyboard shortcuts

  • in Finder (and most other applications)
    • ⌃⌘Z to zoom the window
    • ⌘ + ` to switch between your windows
    • ⇧⌘[ and ⇧⌘] to switch tabs
    • ⌃⌘D to show the dictionary
  • in Firefox:
    • Fn + Alt + Left arrow gets you to the home page.
    • Command + L : link bar
    • Command + K: search box
    • Ctrl + Tab: Next Tab
  • see Mac OS X keyboard shortcuts