Thursday, December 26, 2013

nmake: Installing PyQt In Windows 7 with Visual Studio .NET 2010

For those of you interested in pursuing Python development involving a front-end GUI made from Qt, and don't know how to get started on Windows 7, this is what you need to do.  This could generalize to any software you might wish to install with the "nmake" tool, which allows you to "configure", "make", and "make install" different software packages in much the same way you would on a Linux box.

My setup:

  • Windows 7 machine
  • Windows 7.0 APIs installed (C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A)
  • Microsoft Visual C++ 2010 Ultimate (will hopefully work with Express too)
First, for our specific purpose, download and install Qt if you haven't done that already.  It'll take so long that you ought to have plenty of time to run the next step (building SIP) in parallel and still have time to play at least a couple rounds of solitaire.

In general, before you build from any Makefile in Windows, download and unzip your sources into a known location.  If you plan to be building from source frequently, you may wish to simply add these as environment variables in your "System" settings before you open up a Command Prompt.  Otherwise, just add them after you start your Command Prompt session.  Here's what you need to do:
  • set INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include
  • set LIB=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
  • Add to your PATH:
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
    for MT.exe file location
If you chose the latter approach, you can just run those first two bullets as-is in the Command Prompt.  Then, the third one would be:

set PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin;%PATH%

This is it.  Then, cd into the directory where you downloaded your source to, and run the usual three commands, with the noted twists:
  • python
    Note this one takes some options that pertain to your development environment.  It didn't pick it up correctly for me, so I had to specify it manually with the flag -p win32-msvc2010. You can see all options by using the flag --show-platforms.
  • nmake
  • nmake install
The second step among these three is where you'd run into potential problems.  Usually they''re correctable by ensuring the paths are indeed correct.  The others should go smoothly.

For PyQt in particular, you need to install SIP first, and then PyQt (using the means described above).  Both of these can be found on the Riverbank Computing website.  To get the PyQt installation to work (and avoid the errors about not having a working Qmake present), make sure you have Qt installed, and then add this to your PATH:


Or whatever your equivalent path is, assuming you plan to use the MS VC 2010 toolchain as I've described before.  Several other toolchains are supported here, and this will help the system find qmake properly and proceed with installation.

As for using PyQt with Qt Designer to build a user interface, I might save that for a later date.  I hope you had a Merry Christmas (or maybe s/Christmas/$yourFavoriteHoliday/g), and have a Happy New Year since this will probably be my last post of 2013.  See you next year! 

Thursday, December 19, 2013

Livin' La Vida SSD

The other day, I upgraded my laptop's hard drive from a 500GB 7200rpm drive to a 500GB Samsung 840 EVO solid-state drive.  I purchased the SSD from for $290.00 (which is probably the most I've paid for a drive since 2007), and after taking about a week to get packaged by their warehouse and UPS taking their sweet time to get it over here, it finally came time for me to clone the contents of my HDD over to my SSD.

The performance of my HDD had been dismal, especially as it became more full of Heaven knows what.  (This is still an issue, hence why I recently downloaded Mark Russinovich's "du" program for Windows, so I could analyze which directories contained the biggest wastes of space.)  As you'll see if you watch the video, it took over seven minutes for my computer to become responsive enough to be useful after a cold boot.  Windows itself took a real long time to spin up, then it took even longer for my desktop icons to come up so I could actually click on and run anything.  As such, I would reboot maybe once every month or two, and opt to put my computer to sleep instead.  Hibernation wasn't a very good deal either, since I have 12GB of RAM in here and it would take a few minutes to do that too.

After cloning my HDD to the SSD with EaseUS Todo Backup Free Edition, I attempted to boot my SSD straight-up without any modifications afterward.  Unfortunately, Windows couldn't handle itself when it's been cloned to different hardware, so I had to straighten it out with some techniques.  I dusted off my Windows 7 installation disc and proceeded to run several of the automatic repair methods to no avail.  Eventually I ran across these instructions on fixing your boot record from Tom's Hardware.  Turns out I got myself pretty close, but just needed to select the "Command Prompt" option from the Windows 7 Repair/Recovery menu, and type:

bootrec.exe /FixMbr

This is, luckily, all it took to restore my Windows 7 to working order.  If you don't have such good luck, the Tom's Hardware article I just linked to has some more suggestions.  Once I got that squared away, my computer rebooted and, from POST to "Scan your fingerprint now", my computer booted up in around 50 seconds, as compared with about two and a half minutes with the HDD.  In under two minutes since hitting the power button, I was able to open, click around in, and close two programs very smoothly.  The SSD has made a substantial difference in my 3-year-old laptop's performance.

I currently have another SSD running Windows 8 in my desktop, and gave one to my wife for  use in her HP Envy laptop.  Between these and my new NAS box, I plan to rid myself of all the old IDE drives lying around collecting dust, plus any SATA HDD under 1TB.  My nasty old plastic bin of hard drives will, someday soon, be recycled itself.

Wait, I missed something... where's this video you spoke of?  I haven't had a chance to edit it yet, so I'll update this post later on and hopefully embed it.