[Python] compile mysqldb for python in cygwin

Source: Internet
Author: User
[Python] compile mysqldb for python in cygwin
1. Prepare
2. Compile and install mysqlclient
3. Compile and install mysqldb
3.1. Decompress
3.2. Pre-compilation settings
3.3. Compilation and Installation
1. Prepare

Because cygwin does not provide mysqlclientProgram.Source code.

First, you must install cygwin. When installing cygwin, You must select devel, Perl, and Python packages.

Download the corresponding MySQL version. Be sure to download the "Source" version.

Download mysqldb for installation.

 

2. Compile and install mysqlclient

Go to cygwin's shell and decompress MySQLCode:

Tar-xvzf mysql-5.0.37.tar.gz

CD mysql-5.0.37

Configuration, compilation, and installation

./Configure -- without-Server

Make & make install

According to the machine configuration, compilation may take a long time, generally about half an hour.

3. Compile and install mysqldb3.1. decompress the package.

Go to cygwin's shell and decompress mysqldb:

Tar-xvzf MySQL-python-1.2.2.tar.gz

CD MySQL-python-1.2.2

3.2. Pre-compilation settings

First modify the compilation configuration file of mysqldb: site. cfg, under the MySQL-python-1.2.2 directory.

Find the [Options] item and modify it as follows:

Open a line of mysql_config =/usr/local/bin/mysql_config, and shield the line # registry_key = software/MySQL AB/MySQL Server 5.0, because cygwin is a Linux-like non-Windows Server.

We set embedded to false because it is used on a PC.

Set threadsafe to false. We try to use static compilation, and set static to true.

The final [Options] is as follows:

[Options]

# Embedded: link against the Embedded Server Library

# Threadsafe: Use the threadsafe Client

# Static: link against a static library (probably required for Embedded)

Embedded = false

Threadsafe = false

Static = true

# The Path to mysql_config.

# Only use this if mysql_config is not on your path, or you have some weird

# Setup that requires it.

Mysql_config =/usr/local/bin/mysql_config

# The Windows Registry Key for MySQL.

# This has to be set for Windows builds to work.

# Only change this if you have a different version.

# Registry_key = software/MySQL AB/MySQL Server 5.0

3.3. Compilation and Installation

CD MySQL-python-1.2.2

Python setup. py build

Python setup. py install

During installation, you may need to download setuptools as required.

In addition, after the installation is complete for the. Egg file, you can also use the Lib. cygwin-1.5.24-i686-2.5 file, that is, directly copy the file to the python site-packages can be used.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.