python env setup

来源:百度文库 编辑:神马文学网 时间:2024/04/28 20:55:28



-
-

Installing Microsoft Windows Third-Party Development Software

-
Need docs for unix
Include docs for downloading and installing MinGW
-

Cygwin

Cygwin provides a UNIX like environment in Windows. We're not using the Cygwin compiler to compile Avida, but we are using installing it because it provides easier access to tools such as Subversion and wget.


-


Cygwin download
Download Cygwin and install it. When selecting packages, make sure you install the following tools:


-

  • subversion

  • openssh

  • wget

  • make

  • automake

  • autoconf


Don't install any of the other stuff, including the Qt libraries. We will compile native libraries.



-

Version Control System
-

Subversion
-


Usage:


-


Basic instructions for use with Avida can be found on
the Devolab's web site.


That link looks temporary. When it breaks, ask David for the new link.
-


Read more detailed instructions at
red-bean.com's online Subversion pages.




-

Build System
-

MinGW
-


Requirements:


None.


The MinGW project provides a native compiler for Windows based on GCC. If we compiled with Cygwin, the executable would need the Cygwin compatibility DLL.


-


Installation:


-


Download MinGW at
MinGW Home
. Also install MSYS and the MSYS Developer toolkit. This provides a bash shell and make. Unpack the latest w32-api, automake, and autoconf tarballs in the MinGW directory.



-

CMake
-


Requirements:


None.


-


Installation:


-


Download and run the CMake installer for Windows via
http://www.cmake.org/files/v2.0/CMSetup206.exe


-


Basic instructions for use with Avida can be found in the file "
README
" in the top-level Avida source code directory. Read more detailed instructions at
CMake's online documentation pages.




-

Avida-Ed interactive GUI requirements
-

Python
-


What is it?


Python is an interpreted, interactive, object-oriented programming language. It permits rapid experimentation with and design of new parts of the Avida-Ed GUI without recompilation of c++ parts of Avida. Our Python code is then embedded in the double-clickable Avida-Ed application, along with a Python interpreter, and is run when Avida-Ed is launched.


-


Requirements:


Readline is suggested but not required. Using the Python interpreter without Readline's command-line editing, tab-completion, and history is pretty tedious. There are no other requirements.


-


Installation:


-


Download and install Python
http://www.python.org/ftp/python/2.4.1/python-2.4.1.msi


-


GCC compatible versions of the Python libraries need to be generated. Cygwin comes with programs called pexports and dlltool to help with this.
Instructions for generating GCC compatible Python library


-


pexports.exe /c/WINDOWS/system32/python24.dll > python24.def dlltool --dllname python24.dll --def python24.def --output-lib libpython24.a cp libpython24.a c:\python24\libs


-


Where things are installed:


-


Python 2.4 is installed at
C:\Python24
by default.


-


Usage:


-


Oodles of instruction can be had at
Python's documentation pages.



-

Readline
-


Readline isn't absolutely required, but it does help with development and is recommended. You can pickup a windows Python module at
http://sourceforge.net/projects/uncpythontools/
. Download and unpack the Readline Python package
http://easynews.dl.sourceforge.net/sourceforge/uncpythontools/readline-1.12.win32.exe
into the directory of your choice using cygwin; for example:


-


Requirements:


ctypes modules: http://starship.python.net/crew/theller/ctypes


-


$ cd ~/src


$ wget http://easynews.dl.sourceforge.net/sourceforge/uncpythontools/readline-1.12.win32.exe


Build and install. This is easy, just click on the installer in explorer or execute it from the command line.



-

Qt/Windows

We can use the GPL version of Qt/PyQt, because of the wonderful work from the kde-cygin project and kscraft project. This does not require Cygwin, and will compile under MinGW.


-


$ wget http://prdownloads.sourceforge.net/qtwin/qt-win-free-3.3.4-3-src.tar.bz2?download


$ tar xvfj qt-win-free-3.3.4-3.src.tar.bz2


-


Qt/Win and some of the third-party software that depends on Qt/Win require that certain environment variables be set. For example, if you use
bash
as your shell:


-


$ cd qt-3


$ export QTDIR=`pwd`


$ export MINGW=/c/MinGW


$ export PATH=$PATH:$QTDIR/bin:$QTDIR/lib:$MINGW/bin:/c/Python24


$ export QMAKESPEC=win32-g++


-
Record the value of
$QTDIR
. These settings of
$QTDIR
,
$PATH
, and
$DYLD_LIBRARY_PATH
will be required later by other third-party software. To determine the value of
$QTDIR
, for example:


$ echo $QTDIR


/c/cygwin/home/josh/src/qt-3

Configure and build:


-


$ configure.bat


If the build dies in the middle, execute the following:


-


$ mingw32-make



-

SIP
-


SIP requires that the
$QTDIR
,
$PATH
, and
$MINGW
environment variables point to your Qt/Windows installation, so set them accordingly if they aren't already set. For example, if you use
bash
as your shell:


-


$ export QTDIR=/c/cygwin/home/josh/src/qt-3


$ export MINGW=/c/mingw


$ export PATH=$PATH:$QTDIR/bin:$QTDIR/lib:/c/Python24


-


Download and unpack the SIP source archive
http://www.river-bank.demon.co.uk/download/sip/sip-4.1.1.tar.gz
into the directory of your choice using MSYS; for example:


-


$ cd /c/cygwin/home/josh/src


$ wget http://www.river-bank.demon.co.uk/download/sip/sip-4.3.tar.gz


$ tar xvfz sip-4.3.tar.gz


-


Patch to build on Windows. As documented on this page:
http://kscraft.sourceforge.net/convert_xhtml.php?doc=pyqt-windows-install.xhtml
, there is a patch you need to apply to SIP if you download it directly from Riverbank. To download and apply the patch:


-


$ wget http://prdownloads.sourceforge.net/kscraft/sip-4.1.1.diff?download


$ cd sip-4.3


$ patch -p1 < ../sip-4.1.1.diff


Configure, build, and install, make SURE you do this in either the windows command shell or the MSYS shell.


If you are using MSYS:


-


$ cd sip-4.3


$ /c/python24/python configure.py -l qt-mt -p win32-g++ DEL_FILE=rm COPY=cp MKDIR=mkdir


$ make


$ make install


If you are using Windows cmd:


-


$ cd sip-4.3


$ c:\python24\python configure.py -l qt-mt -p win32-g++


$ mingw32-make


$ mingw32-make install



-

PyQt
-


PyQt requires that the
$QTDIR
,
$PATH
, and
$MINGW
environment variables point to your Qt/Windows installation, so set them accordingly if they aren't already set. For example, if you use
bash
as your shell:


-


$ export QTDIR=/c/cygwin/home/josh/src/qt-3


$ export MINGW=/c/mingw


$ export PATH=$PATH:$QTDIR/bin:$QTDIR/lib:/c/Python24


-


Download and unpack the PyQt source archive
http://www.river-bank.demon.co.uk/download/PyQt/PyQt-mac-gpl-3.13.tar.gz
into the directory of your choice using Terminal.app; for example:


-


$ cd ~/src


$ wget http://www.river-bank.demon.co.uk/download/PyQt/PyQt-x11-gpl-3.15.tar.gz


$ tar xvfz PyQt-x11-gpl-3.15.tar.gz


-


Patch to build on Windows. As documented on this page:
http://kscraft.sourceforge.net/convert_xhtml.php?doc=pyqt-windows-install.xhtml
, there is a patch you need to apply to PyQt if you download it directly from Riverbank. To download and apply the patch:


-


$ wget http://easynews.dl.sourceforge.net/sourceforge/kscraft/PyQt-x11-3.13.diff


$ cd PyQt-x11-gpl-3.15


$ patch -p1 < ../PyQt-x11-3.13.diff


-


$ cd PyQt-x11-gpl-3.15


$ /c/python24/python configure.py


$ make


$ make install


If you are using Windows cmd:


-


$ cd PyQt-x11-gpl-3.15


$ c:\python24\python configure.py


$ mingw32-make


$ mingw32-make install



-

Numeric
-


Download and unpack the Numeric Python package source archive
http://easynews.dl.sourceforge.net/sourceforge/numpy/Numeric-24.0b2.tar.gz
into the directory of your choice using MSYS; for example:


-


$ cd ~/src


$ wget http://easynews.dl.sourceforge.net/sourceforge/numpy/Numeric-24.0b2.tar.gz


$ tar xvfz Numeric-24.0b2.tar.gz


Build and install:


-


$ cd Numeric-24.0b2


$ python setup.py build -cmingw32


$ python setup.py install --skip-build



-

Numarray
-


Download and unpack the Numarray Python package source archive
http://easynews.dl.sourceforge.net/sourceforge/numpy/numarray-1.3.3.tar.gz
into the directory of your choice using MSYS; for example:


-


$ cd ~/src


$ wget http://easynews.dl.sourceforge.net/sourceforge/numpy/numarray-1.3.3.tar.gz


$ tar xvfz numarray-1.3.3.tar.gz


Build and install:


-


$ cd numarray-1.3.3


$ python setup.py build -cmingw32


$ python setup.py install --skip-build



-

PyQwt
-


PyQwt requires that the
$QTDIR
,
$PATH
, and
$MINGW
environment variables point to your Qt/Windows installation, so set them accordingly if they aren't already set. For example, if you use
bash
as your shell:


-


$ export QTDIR=/c/cygwin/home/josh/src/qt-3


$ export MINGW=/c/mingw


$ export PATH=$PATH:$QTDIR/bin:$QTDIR/lib:/c/Python24


-


Download and unpack the PyQwt-4.2 Python package source archive
http://easynews.dl.sourceforge.net/sourceforge/pyqwt/PyQwt-4.2.tar.gz
into the directory of your choice using cygwin; for example:


-


$ cd ~/src


$ wget http://easynews.dl.sourceforge.net/sourceforge/pyqwt/PyQwt-4.2.tar.gz


$ tar xvfz PyQwt-4.2.tar.gz


Build and install, using the Windows command shell.


-


$ cd PyQwt-4.2/configure


$ python configure.py


$ mingw32-make


$ mingw32-make install



-

ElementTree
-


Download and unpack the ElementTree Python package source archive
http://effbot.org/downloads/elementtree-1.2.6-20050316.tar.gz
into the directory of your choice


-


$ cd ~/src


$ wget http://effbot.org/downloads/elementtree-1.2.6-20050316.tar.gz


$ tar xfvz elementtree-1.2.6-20050316.tar.gz


Build and install:


-


$ cd elementtree-1.2.6-20050316


$ python setup.py build


$ python setup.py install



-

GCC-XML

The CVS version of GCC-XML needs to be installed if you're using MinGW. The 0.6.0 version requires MSVC to be installed.


-


$ cd ~/src


$ cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML login


$ cvs -d :pserver:anoncvs@www.gccxml.org:/cvsroot/GCC_XML co gccxml


Configure, build, and install:


-


$ cd gccxml


$ mkdir build


$ cd build


$ cmake .. -G"Unix Makefiles"


$ make



-

Boost.Python
-


Download and unpack the Boost source archive
http://easynews.dl.sourceforge.net/sourceforge/boost/boost_1_33_0.tar.gz
into the directory of your choice using cygwin; for example:


-


$ cd ~/src


$ wget http://easynews.dl.sourceforge.net/sourceforge/boost/boost_1_33_0.tar.gz


$ tar xvfz boost_1_33_0.tar.gz


Build Boost.Jam, the Boost Build system. Use the Windows command shell to build it.


-


$ cd boost_1_33_0


$ cd tools\build\jam_src


$ build.bat gcc-nocygwin


Switch back over to MSYS. copy bin.ntx86/* to /usr/local/bin


-


$ cp tools/build/jam_src/bin.ntx86/bjam /usr/local/bin


Build Boost.Python (warning -- because Boost is a big package, most of which we don't need and would take a long time to compile, we disable most of Boost, resulting in a big and ugly command):


-


$ cd ..\..\..\


export PYTHON_ROOT=/c/Python24


export PYTHON_VERSION=2.4


$ bjam -sTOOLS=gcc-nocygwin \


-sBUILD=release \


--prefix=/usr/local \


--without-serialization \


--without-test \


--without-date_time \


--without-filesystem \


--without-regexp \


--without-signals \


--without-program_options \


--with-python-root=/c/Python24 \


-sPYTHON_VERSION=2.4


-


Install Boost.Python (again, a big and ugly command -- essentially the same as the previous, but appended with "
install
"):


-


$ bjam -sTOOLS=gcc-nocygwin \


"-sBUILD=release"


--prefix=/usr/local \


--without-serialization \


--without-test \


--without-date_time \


--without-filesystem \


--without-regexp \


--without-signals \


--without-program_options \


--with-python-root=/c/Python24 \


-sPYTHON_VERSION=2.4 \


install


After building it, we still need to compile and install the Boost.Python libraries.


-


$ cd libs/python/pyste/install


python setup.py install



-

IPython (optional but recommended)
-


First install the Python for Windows extensions
http://easynews.dl.sourceforge.net/sourceforge/pywin32/pywin32-204.win32-py2.4.exe


-


$ cd ~/src


$ wget http://easynews.dl.sourceforge.net/sourceforge/pywin32/pywin32-204.win32-py2.4.exe



Then run the installer


-


Download and unpack the IPython package source archive for Windows
http://ipython.scipy.org/dist/ipython-0.6.15.tar.gz
into the directory of your choice using cygwin; for example:


-


$ cd ~/src


$ wget http://ipython.scipy.org/dist/ipython-0.6.15.tar.gz


$ tar xvfz ipython-0.6.15.tar.gz


Install:


-


$ cd ipython-0.6.15


$ python setup.py install




-

Building Avida
-

Compiling Avida

Building is similiar to building on Mac OSX. This can all be done in the MSYS environment.


-


$ mkdir build


$ cd build


$ cmake -G"Unix Makefiles" \
-DAVD_CONSISTENCY_TEST_PRIMITIVE:BOOL=OFF \
-DAVD_PRIMITIVE:BOOL=ON \
-DAVD_UNIT_TESTS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DAVD_GUI_NCURSES:BOOL=ON \
-DAVD_PY_BINDINGS:BOOL=ON \
-DBOOST_INCLUDE_PATH:PATH=/usr/local/include/boost-1_33 \
-DBOOST_LIBRARY:FILEPATH=/usr/local/lib/libboost_python-gcc.lib \
-DPYTHON_INCLUDE_PATH:PATH=/c/Python24/include \
-DPYTHON_LIBRARY:FILEPATH=/c/Python24/libs/python24.lib \
-DAVD_GUI_PYQT:BOOL=ON \
..



Before compiling Avida, you will need to set your GCCXML_FLAGS. Here is one that works for the latest version of MinGW (GCC 3.4.2)


-


export GCCXML_FLAGS="-D__DBL_MIN_EXP__='(-1021)' -D__FLT_MIN__='1.17549435e-38F' -D__CHAR_BIT__='8' -D__WCHAR_MAX__='65535U' -D__DBL_DENORM_MIN__='4.9406564584124654e-324' -D__FLT_EVAL_METHOD__='2' -D__DBL_MIN_10_EXP__='(-307)' -D__FINITE_MATH_ONLY__='0' -D__GNUC_PATCHLEVEL__='2' -D_stdcall='__attribute__((__stdcall__))' -D__SHRT_MAX__='32767' -D__LDBL_MAX__='1.18973149535723176502e+4932L' -D__LDBL_MAX_EXP__='16384' -D__SCHAR_MAX__='127' -D__USER_LABEL_PREFIX__='_' -D__STDC_HOSTED__='1' -D__WIN32='1' -D__LDBL_HAS_INFINITY__='1' -D__DBL_DIG__='15' -D__FLT_EPSILON__='1.19209290e-7F' -D__GXX_WEAK__='1' -D__tune_i686__='1' -D__LDBL_MIN__='3.36210314311209350626e-4932L' -D__DECIMAL_DIG__='21' -D__LDBL_HAS_QUIET_NAN__='1' -D__GNUC__='3' -D_cdecl='__attribute__((__cdecl__))' -D__DBL_MAX__='1.7976931348623157e+308' -D__WINNT='1' -D__DBL_HAS_INFINITY__='1' -D__WINNT__='1' -D_fastcall='__attribute__((__fastcall__))' -D__cplusplus='1' -D__USING_SJLJ_EXCEPTIONS__='1' -D__DEPRECATED='1' -D__DBL_MAX_EXP__='1024' -D__WIN32__='1' -D__GNUG__='3' -D__LONG_LONG_MAX__='9223372036854775807LL' -D__GXX_ABI_VERSION='1002' -D__FLT_MIN_EXP__='(-125)' -D__DBL_MIN__='2.2250738585072014e-308' -D__FLT_MIN_10_EXP__='(-37)' -D__DBL_HAS_QUIET_NAN__='1' -D__REGISTER_PREFIX__='' -D__cdecl='__attribute__((__cdecl__))' -D__NO_INLINE__='1' -D__i386='1' -D__FLT_MANT_DIG__='24' -D__VERSION__='3.4.2 (mingw-special)' -D_WIN32='1' -D_X86_='1' -Di386='1' -D__i386__='1' -D__SIZE_TYPE__='unsigned int' -D__FLT_RADIX__='2' -D__LDBL_EPSILON__='1.08420217248550443401e-19L' -D__MSVCRT__='1' -D__FLT_HAS_QUIET_NAN__='1' -D__FLT_MAX_10_EXP__='38' -D__LONG_MAX__='2147483647L' -D__FLT_HAS_INFINITY__='1' -D__stdcall='__attribute__((__stdcall__))' -D__EXCEPTIONS='1' -D__LDBL_MANT_DIG__='64' -D__WCHAR_TYPE__='short unsigned int' -D__FLT_DIG__='6' -D__INT_MAX__='2147483647' -DWIN32='1' -D__MINGW32__='1' -D__FLT_MAX_EXP__='128' -D__DBL_MANT_DIG__='53' -D__WINT_TYPE__='short unsigned int' -D__LDBL_MIN_EXP__='(-16381)' -D__WCHAR_UNSIGNED__='1' -D__LDBL_MAX_10_EXP__='4932' -D__DBL_EPSILON__='2.2204460492503131e-16' -D__tune_pentiumpro__='1' -D__fastcall='__attribute__((__fastcall__))' -DWINNT='1' -D__FLT_DENORM_MIN__='1.40129846e-45F' -D__FLT_MAX__='3.40282347e+38F' -D__GNUC_MINOR__='4' -D__DBL_MAX_10_EXP__='308' -D__LDBL_DENORM_MIN__='3.64519953188247460253e-4951L' -D__PTRDIFF_TYPE__='int' -D__LDBL_MIN_10_EXP__='(-4931)' -D__LDBL_DIG__='18' -D__declspec(x)=__attribute__((x)) -iwrapper c:/cygwin/home/gerrishj/src/gccxml/GCC_XML/Support/GCC/3.4 -I/mingw/include -I/mingw/include/c++/3.4.2 -I/mingw/include/c++/3.4.2/mingw32 -I/mingw/lib/gcc/mingw32/3.4.2/include -include c:/cygwin/home/gerrishj/src/gccxml/GCC_XML/Support/GCC/3.4/gccxml_builtins.h"


Then compile Avida


-


make