Quick Python/Developer tips for OSX Lion

July 30th, 2011 § 18 comments

Lion king 5067

Yes; of course I upgraded to OSX Lion on day one. To quote myself from twitter:

I am happy in the warm cozi­ness and stark white­ness of Steve Jobs’ monoculture.

Regard­less of that though, I had very few hic­cups with Lion itself — but a few things you need to deal with going in:

  • Be on a high band­width con­nec­tion. The down­loads you have to make are huge.
  • XCode 4.x is now free in the App Store — you need this — the first thing you need to install after Lion is the lat­est ver­sion of XCode from the App Store, if you do this, all your vir­tualenvs, your home­brew envi­ron­ment (at least mine) just Keep Work­ing. Save your­self some pain.
    • Side note: @kennethreitz, gen­tle­man scholar, has actu­ally done a cus­tom osx-gcc-installer — this con­tains a sys­tem install of GCC and all the good­ness you need (such as install_name_tool) for Python hack­ing. So you might be able to skip the mas­sive XCode install.
    • When installing XCode, for some unknown unholy rea­son, if you have not quit itunes, and itunes helper (see activ­ity mon­i­tor) prior to start­ing the XCode installer, the install will hang. Do your­self a favor and kill it with fire.
    • Remem­ber; the binary direc­tory for the dev tools is in /Developer/usr/bin/ — this includes gcc-4.2
    • Do your­self a favor, drop “export ARCHFLAGS=”-arch x86_64”” into your .bash_profile.
  • If you’re run­ning home­brew; after the upgrade, I rec­om­mend a brew update && brew upgrade
  • If you use mer­cu­r­ial — you need to install the updated ver­sion found here.
  • Just for good mea­sure, do a global (sudo) rein­stall of vir­tualenv, vir­tualen­vwrap­per and pip. Make sure they’re pointed at the right default Python (in my case the sys­tem one).
  • If you are using VMWare Fusion: You really need to be run­ning the lat­est ver­sion of 3.x.
  • If you are using Boot­camp, and plan on turn­ing on full disk encryp­tion, see this note from Hacker News (this is why I con­fine win­dows to VMware images)

Other than the above; my dev envi­ron­ment pretty much just kept rock­ing — Lion’s default Python install is a healthy Python 2.7.1 — dou­ble nice++ — MacVim, edi­tor of choice just kept plug­ging away, although I have not tried the “offi­cial unre­leased” ver­sion they have for Lion. I have a slight aver­sion to run­ning beta builds of my editor.

Some of you are going to run into some annoy­ances; I can’t help you with all of them, but I can help you with the two inter­face changes I could not deal with (I actu­ally like all the other ones).

  • First; go into sys­tem pref­er­ences > mis­sion con­trol and uncheck “Auto­mat­i­cally rearrange spaces based on most recent use” — trust me, you’ll thank me.
  • Sec­ond, there’s this … annoy­ing ani­ma­tion when you make new appli­ca­tion win­dows (See the Ars Lion Review | kin­dle ver­sion). The ani­ma­tion offends me on a cel­lu­lar level. You dis­able it by run­ning this on the com­mand line:
    defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool NO ; killall Dock
  • Show hid­den files in finder:
    defaults write com.apple.finder AppleShowAllFiles -bool YES
  • Show full paths in finder:
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
  • Note: Don’t like muck­ing around with the com­mand line, or want to have some­thing with a birds eye view that can con­trol just about any­thing, check out “Secrets” from black­tree. I’m fine with magic PLIST hacks, but this does put a nice UI on all the hacks.
  • Also, if you’re a power user, or want tiling behav­ior for win­dows — see SizeUp or Divvy (I use Sizeup) both of which are excel­lent addi­tions to win­dow man­age­ment, even in Lion. I tend to be anal about win­dow coor­di­na­tion on the screen even with mis­sion control/expose.

Other than that; I’m a happy camper. The new scroll behav­ior on the track­pads is amaz­ing, if not jar­ring when using a mouse. Every­thing just pretty much kept work­ing for me. But then again, I’m pretty easy to please.

See also — “Four Lion Ter­mi­nal Hacks” from Mac­world and “Top 10 Secret Fea­tures in OSX Lion” from Life­hacker — if you really, really hate the UI changes, see “How to de-IOSify” from Life­hacker. More cool tips and tricks: “Mis­cel­la­neous Lion Tips and Tricks” and also “Mis­cel­la­neous Lion Tips and Tricks part two”.

p.s. I orig­i­nally for­got to men­tion this — but the full disk encryp­tion in Lion is imple­mented damn well — it’s easy for users to “get” — seam­less, and trans­par­ent. In my hon­est opin­ion, this is worth the price of upgrad­ing alone if you have a lap­top. It’s so well done, and it sim­ply shows how crappy fil­e­vault was — it also goes to show that if you make crypto easy and trans­par­ent for users, they might actu­ally use it. See the Ars Review for a deeper dive. See also “PGP WDE vs. Lion Disk Encryp­tion

p.p.s. See this ArsTech­nica arti­cle about how to cre­ate a bootable copy of the Lion install disk you can use to do offline installs for other machines. I’d rec­om­mend doing the same for XCode if you have more than one mac to upgrade (or you lack FiOS).

 

  • steve

    Thanks for the tips.  Did you run into any prob­lems with MacVim not remem­ber­ing its win­dow size after a relaunch?  (I don’t want to :set columns and :set lines because I sync the con­fig between com­put­ers with dif­fer­ent res­o­lu­tion displays).

  • http://jessenoller.com jnoller

    Nope, but I set columns and lines…

  • http://kennethreitz.com Ken­neth Reitz

    Thanks for the shout out!

    Also, since Lion is 64bit-only, I think only “export ARCHFLAGS=”–arch x86_64” is necessary. 

  • http://jessenoller.com jnoller

    Thanks! Amended, I had for­got­ten I swapped to x86_64 only

  • Stan Seib­ert

    Amen to the Fil­e­Vault rec­om­men­da­tion.  As a long time user of PGP WDE, I was amazed to see how much faster the Apple encryp­tion imple­men­ta­tion was.  I no longer have to decide between fast SDD speeds and secu­rity my data.  Hav­ing to drop to the com­mand line to encrypt exter­nal disks is kind of annoy­ing com­pared to PGP, but it still works.

    Now if Apple would just close the DMA over Firewire secu­rity prob­lem, every­thing would be great…

  • Van­flan

    defaults write NSGlob­al­Do­main NSAuto­mat­icWin­dowAn­i­ma­tion­sEn­abled –bool NO
    gives me an error

    2011-07-30 14:42:04.550 defaults[17711:707] Unex­pected argu­ment NO; leav­ing defaults unchanged.

  • http://jessenoller.com jnoller

    Are you run­ning lion?

  • Ihavenone

    Be on a high band­width con­nec­tion. The down­loads you have to make are huge.” None needed, actu­ally. You can burn the instal­la­tion DVD on a disc (or USB stick etc.) and it con­tains all needed for a fresh instal­la­tion, with no inter­net con­nec­tion, with­out Snow Leop­ard “under­neath”. Let me repeat that: for a FRESH INSTALLATION WITH NO INTERNET CONNECTION, WITHOUT SNOW LEOPARD UNDERNEATH.

  • http://jessenoller.com jnoller

    Yes, but you still have to down­load Lion itself, and XCode. It’s well known you can make an offline replica, in fact, here’s the ars links: http://arstechnica.com/apple/guides/2011/07/ask-ars-do-i-have-to-use-the-mac-app-store-to-install-lion.ars– I was talk­ing about the fact that you have to do the ini­tial down­load of
    both Lion and XCode.

  • Niklas

    Hiya, just curi­ous, what’s the pur­pose of ARCHFLAGS?

  • http://jessenoller.com jnoller

    Since gcc/Xcode/etc are set to build for mul­ti­ple plat­forms (ppc, i386, x86_64) you can run into issues com­pil­ing C exten­sions for python unless you restrict it down to only what you need. Many python pack­age will go… Crazy try­ing to do cross plat­form builds unless you set it.
    Lion is 100% 64 bit — set it and for­get it. If you search for python pack­age lipo errors you’ll see what I mean. I think this also affects ruby gem build­ing as well.
    Tl;dr — it restricts your tar­get com­pi­la­tion archi­tec­tures when build­ing c modules.

  • Anony­mous

    Have the same prob­lem in Lion: “defaults write com.apple.finder _FXShowPosixPathInTitle –bool YES” yeilds “defaults[399:707] Unex­pected argu­ment YES; leav­ing defaults unchanged.”

  • http://jessenoller.com jnoller

    For both you (Melpo) and Van­Flan — if you copied and pasted it from my blog post, Lion/OSX’s copy and paste intel­li­gence when it comes to HTML was bit­ing you in the butt. I’ve changed the lines to be pre-formatted so copy and paste should work *right* now for you. You were get­ting html injected into the paste.

  • Steve

    Great post.  Thank you.

    Any trou­bles set­ting up django, mod_wsgi, apache?

  • http://jessenoller.com jnoller

    Nope!

  • http://task3.cc Daniel Grazi­otin

    Thank you very much for this post. As both OS X Lion user and (Python) devel­oper, I really appre­ci­ate all of your tips.

  • http://www.lukejones.me/ Luke Jones

    Thank you for the tips :)

  • Niklas

    Thanks for the clarification!

What's this?

You are currently reading Quick Python/Developer tips for OSX Lion at jessenoller.com.

meta