___  _  ___  _  _  ___  ___ 
 /   \/ \/   \| \| |/  _|/ _ \
 |      || | ||  | |\_  \|  _|
 |__|_|_|\___/\____||___/\___/
 Project Mouse (v3.4) 
 By Nate Royer
 © 1995-2008

	
 
Project Mouse

Installing Django for Leopard with MySQL Support

I was following the instructions from Chapter 2 of the Django Book an online reference for learning and using Django, a Python web framework. My initial experience with Mac OS X Leopard (10.5.1) and adding open-source software has been a pleasure.

I have yet to encounter the dependency nightmare I have experienced with previous Mac OS X systems. Of course, I have also tamed my need for the absolute bleeding edge of software by avoiding nightly builds and the like, at least for time being.

Installing Django

# Download Django <URL: http://www.djangoproject.com/download/ /> dev:www $ tar xzvf Django-*.tar.gz. dev:www $ cd Django-*. dev:www $ sudo python setup.py install # Test the django module dev:www $ python >>> import django >>> django.VERSION

Add MySQL Support to Python

Adding MySQL support for Python presented the only issue. A unexpected configuration error prevents the MySQLdb module from compiling and then a different issue throws a 'file not found' error when the module is loaded into Python.

I am not familiar enough with either system to say which developer has changed their installed path or even if it is some erroneous oversight on my part when originally installing MySQL or MySQLdb. In any case, here is what I need to do to complete the compile and install of MySQLdb for Mac OS X Leopard:

Update: Installing on Mac OS X Server Leopard 10.5

When compiling/installing MySQLdb for Mac OS X Server Leopard 10.5.x one will receive a different error for gcc about not being able to find my_conf.h. Because MySQL 5.0 is pre-installed in the Server addition this error stumped me until I read an Apple Support Article that explains that the client header files (.h) are not included with the Server edition for what I can only imagine is some sort of security preference.

$ curl -O http://www.opensource.apple.com/darwinsource/other/MySQL-43.binaries.tar.gz # Follow the instructions to add MySQL header files.

Mac OS X (Client) Leopard does not come with MySQL pre-installed and the standard binary package for installing from MySQL includes the client and server files needed to interact with the service as well as the bits needed for MySQLdb. A small note that SQLite is supported by default as of Python 2.5+ and is the staple for use in many Cocoa applications for Mac OS X. For local application support or general 'tinkering' its pretty handy database, just not as fast as MySQL when it comes to dynamically serving content to web clients.

# Download the latest stable version of MySQLdb from <URL: http://mysql-python.sourceforge.net/ /> dev:www $ tar xzf MySQL-python-*.tar.gz dev:www $ cd MySQL-python-* dev:www $ find / -name mysql_conf # Edit site.cgf at line 13 to add your full mysql_conf path mysql_config = /usr/local/mysql/bin/mysql_config # <URL: http://forums.mysql.com/read.php?50,175059,179979#msg-179979 /> # Edit these lines from _mysql.c 37 //ifndef uint 38 //define uint unsigned int 39 //endif ... 484 //uint port = MYSQL_PORT; CHANGED to next line 485 unsigned int port = MYSQL_PORT; 486 //uint client_flag = 0; CHANGED to next line 487 unsigned int client_flag = 0; # Issue 1 is now solved and you can compile MySQLdb dev:www $ python setup.py build dev:www $ sudo python setup.py install # Issue 2 i ssolved by creating a symbolic link to the # libmysqlclient_r.15.dylib library. dev:www $ sudo mkdir /usr/local/mysql/lib/mysql dev:www $ sudo ln -s /usr/local/mysql/lib/libmysqlclient_r.15.dylib\ /usr/local/mysql/lib/mysql/libmysqlclient_r.15.dylib # test MySQLdb module in python dev:www $ python >>> import MySQLdb # no trace back errors == 'sweetness'

For future reference

System paths for Mac OS X Leopard (10.5) default pre-installed Python framework.

dev:www $ python >>> import sys >>> print sys.path '' '/Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-ppc.egg' '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip' '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5' '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin' '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/\ plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload', '/Library/Python/2.5/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC'

Start a New Project

dev:Python $ mkdir Django dev:Python $ cd Django/ dev:Django $ django-admin.py startproject LearningDjango dev:Django $ ls -1 LearningDjango/ total 24 __init__.py # Python sees this directory as a package manage.py # command-line utility settings.py # Django project settings and configuration urls.py # "Table of Contents" for the project

Start the Development Server

dev:LearningDjango $ python manage.py runserver Validating models... 0 errors found. Django version 0.96.1, using settings 'LearningDjango.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [08/Jan/2008 20:12:10] "GET / HTTP/1.1" 404 2069


macosx

Open Directory and .htpasswd

Fascinating! I worked on a project* once that involved a complete rewrite of the command-line utility passwd in order to keep a number of system services including a .htpasswd file in sync with users account passwords. Mac OS X Hints noted this is made simple with Mac OS X Leopard (10.5) and Open Directory.


macosx

Virtualized Xserver

Media Temple labs has a private beta for what it’s calling Xserve-Virtual . This system has been added quickly added to my MT wish list along with the Django GridContainer which, perhaps I wont need if I move over to a full-on-mirror of my development environment using a virtual OS X Server.

A virtual Mac OS X Leopard Server running on a fully loaded cluster of Xserves virtualized using Parallels Server . I want one, … or three, … yeah that should be enough …. maybe four, for symmetry.


opensource

Fedora 9 root password mismatch resolution

Having started my journey down the command-line with Fedora 3, I was excited to try out Fedora 9. The install completed with ease (the first time around) but once I logged onto the system and attempted to configure some of the system settings, my root password didn’t work.

Why? CAPS LOCK bit was set by default during the install process making a different root password.



Mac OS XNetworkingOpen SourceProgrammingReferenceSecurity & PrivacySystem Administration

Sketch Style Drawings Photo Album Polaroid Post

In the BloggiesOne of My Many IssuesRubbish
		
  ___  _  ___  _  _  ___  ___ 
 /   \/ \/   \| \| |/  _|/ _ \
 |      || | ||  | |\_  \|  _|
 |__|_|_|\___/\____||___/\___/
 Project Mouse (v3.4) 
 By Nate Royer
 © 1995-2008