导航

Win7环境下TreeSaver 例子环境的搭配

Posted on 2011-07-14 11:58  蝈蝈俊  阅读(820)  评论(0编辑  收藏  举报

TreeSaver 绝大多数情况下,我们只需要下载预先编译好的,比如后面地址的这两个链接:https://github.com/Treesaver/treesaver/downloads 

image

这两个一个是编译好的 0.9.2 版本的, 另外一个是带调试信息以及注释的版本。

 

如果我们想研究 TreeSaver的工作原理,这时候可能我们就需要搭配TreeSaver的开发环境了,

实话实说,这个环境搭配起来还真复杂,我折腾了一周多,才搞清楚,主要原因是因为他搭配开发环境必须的几个工具竟然都是我之前没用过的。

下面就是搭配开发环境的步骤:


1、配置TortoiseGit使用Github服务器

TreeSaver 使用的 Git 作为源代码管理,你要能下载它的原代码,就必须装相关软件,这里由于我是Win电脑,所以我选用的是:TortoiseGit  和 msysgit。

TortoiseGit 是TortoiseSVN的Git版本,tortoisegit用于迁移TortoiseSVN到TortoiseGit。 可以这么认为:TortoiseGit 只是对 msysgit 做了GUI的功能封装。

msysGit 有个简单的 GUI 工具,及简单的 Explorer 集成;但它自带的 Bash 非常好用,深得 Linux 的真传。

 

在安装 TortoiseGit 之前,你的 Windows PC 上必须先安装 msysgit。因为msysgit提供了 Git 核心。
而且安装顺序是:先安装 msysgit,然后安装 TortoiseGit。如果你弄反了,也没有关系,可以进入 TortoiseGit 的设置界面
(右键菜单上 TortoiseGit -> Settings -> General -> MSysGit -> Path),
手动指定 Git 核心文件的位置(例如 c:\Program Files\Git\bin)。TortoiseGit发现没有,当你进入设置界面的时候,TortoiseGit自动就给你设置上了,你只需要保存即可。

msysgit 下载地址:

http://code.google.com/p/msysgit/downloads/list

TortoiseGit 下载地址:

http://code.google.com/p/tortoisegit/downloads/list

 

安装 msysgit  时,注意这一步不是选择的默认选项:我们选这一项,是为了我们后面可以方便的用命令行来执行 Git 命令。

后面编译 TreeSaver 就需要确保这一项选择的。

image 

这一步也不是选择的默认设置,选这一项是因为我习惯使用 Putty

image

更详细的配置步骤可以参考:

64位windows 7下成功配置TortoiseGit使用Github服务器
http://our2848884.blog.163.com/blog/static/146854834201152325233854/

 

 

2、下载安装 python

我这里下载的是 2.7 版本(因为后面要用的Paver是基于python2的),目前Paver针对 Python3的还没有开发出来。

python 官方下载地址: http://www.python.org/getit/ 

但是这个地址是被墙的,我是从下面地址下载的。
http://www.cnpythoner.com/pythondown/python2.7down.html

安装后,我的python 是安装在 C:\Python27 目录下的。

为了我们方便运行 python, 我们需要把 C:\Python27 目录放在 Path 系统环境变量中

 

 

3、安装 Easy_install

easy_install是由PEAK(Python Enterprise Application Kit)开发的setuptools包里带的一个命令,所以使用easy_install实际上是在调用setuptools来完成安装模块的工作。

用这个安装会让我们安装Python的工具非常容易。

根据你操作系统的不同,在下面页面选择不同的安装方式

我的是64位的Win7,所以我选择的是

http://pypi.python.org/pypi/setuptools/#windows

即下载 ez_setup.py 文件,并在Python 中执行它。

我把下载的 ez_setup.py 文件放在 python 目录下了,所以执行信息如下:

C:\Python27>python.exe ez_setup.py
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Processing setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to c:\python27\lib\site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install.exe.manifest script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts
Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

参考资料:

Python Easy Install
http://lht.iteye.com/blog/509229

 

4、安装 Paver

Paver是一个基于Python的软件项目脚本工具,和Make 或者Rake 类似。它用来帮助解决一些重复的工作,类似运行文件生成,移动文件,下载等,并支持python语法和提供大量源代码库的优势。

有了 Easy_install  安装其他就很容易了。

只需要简单的执行下面命令就可以。

C:\Python27>c:\Python27\Scripts\easy_install.exe Paver
Searching for Paver
Reading http://pypi.python.org/simple/Paver/
Reading http://www.blueskyonmars.com/projects/paver/
Reading http://paver.github.com/
Best match: Paver 1.0.4
Downloading http://pypi.python.org/packages/source/P/Paver/Paver-1.0.4.tar.gz#md5=43a36ec27abc476ec9c8d82fa016d03d
Processing Paver-1.0.4.tar.gz
Running Paver-1.0.4\setup.py -q bdist_egg --dist-dir c:\users\1\appdata\local\temp\easy_install-fs6uk1\Paver-1.0.4\egg-dist-tmp-6jqove
creating c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg
Extracting paver-1.0.4-py2.7.egg to c:\python27\lib\site-packages
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\bzr.py to bzr.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\command.py to command.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\defaults.py to defaults.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\doctools.py to doctools.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\easy.py to easy.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\misctasks.py to misctasks.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\options.py to options.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\path.py to path.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\path25.py to path25.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\release.py to release.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\runtime.py to runtime.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\setuputils.py to setuputils.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\ssh.py to ssh.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\svn.py to svn.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\tasks.py to tasks.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\virtual.py to virtual.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\__init__.py to __init__.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\cog\cogapp.py to cogapp.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\cog\whiteutils.py to whiteutils.pyc
byte-compiling c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg\paver\cog\__init__.py to __init__.pyc
Adding paver 1.0.4 to easy-install.pth file
Installing paver-script.py script to C:\Python27\Scripts
Installing paver.exe script to C:\Python27\Scripts
Installing paver.exe.manifest script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\paver-1.0.4-py2.7.egg
Processing dependencies for Paver
Finished processing dependencies for Paver

为了我们方便运行 python, 我们需要把 C:\Python27\Scripts 目录放在 Path 系统环境变量中

 

参考资料:

Paver 1.0 发布:Python 脚本工具
http://www.iteye.com/news/6446-paver-1-0-released-python-script-tools

 

Paver 的源码在  http://pypi.python.org/pypi/Paver/

你也可以在 http://paver.github.com/paver/ 找到它的一些使用文档。

 

5、安装 Closure Linter

Google 很重视代码风格的一致性,而且还公开过一份 JavaScript 代码风格指南: Google JavaScript Style Guide,现在它们又发布了一个工具来帮助你检查 JavaScript 代码是否严格遵循了 Google JavaScript Style Guide :Closure Linter

这个工具的安装教程可以在下面地址看到:
http://code.google.com/intl/zh-CN/closure/utilities/docs/linter_howto.html

我这里由于是Win环境,并且前面安装了 Python 和 Easy Install module,所以安装它就非常容易,只要执行下面命令即可(我已经预先把C:\Python27\Scripts 目录放在Path环境变量了,所以安装命令更简单):

C:\> easy_install http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz
Downloading http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz
Processing closure_linter-latest.tar.gz
Running closure_linter-2.3\setup.py -q bdist_egg --dist-dir c:\users\1\appdata\local\temp\easy_install-wwkxkp\closure_linter-2.3\egg-dist-tmp-hsabiqzip_safe flag not set; analyzing archive contents...
Adding closure-linter 2.3 to easy-install.pth file
Installing fixjsstyle-script.py script to C:\Python27\Scripts
Installing fixjsstyle.exe script to C:\Python27\Scripts
Installing fixjsstyle.exe.manifest script to C:\Python27\Scripts
Installing gjslint-script.py script to C:\Python27\Scripts
Installing gjslint.exe script to C:\Python27\Scripts
Installing gjslint.exe.manifest script to C:\Python27\Scripts

Installed c:\python27\lib\site-packages\closure_linter-2.3-py2.7.egg
Processing dependencies for closure-linter==2.3
Searching for python-gflags
Reading http://pypi.python.org/simple/python-gflags/
Reading http://code.google.com/p/python-gflags
Best match: python-gflags 1.5.1
Downloading http://python-gflags.googlecode.com/files/python-gflags-1.5.1.tar.gz

Processing python-gflags-1.5.1.tar.gz
Running python-gflags-1.5.1\setup.py -q bdist_egg --dist-dir c:\users\1\appdata\local\temp\easy_install-7kwull\python-gflags-1.5.1\egg-dist-tmp-gam0_xzip_safe flag not set; analyzing archive contents...
error removing build\bdist.win32\egg: build\bdist.win32\egg\bin\gflags2man.py:
error removing build\bdist.win32\egg: build\bdist.win32\egg\bin:
error removing build\bdist.win32\egg: build\bdist.win32\egg:
Adding python-gflags 1.5.1 to easy-install.pth file

Installed c:\python27\lib\site-packages\python_gflags-1.5.1-py2.7.egg
Finished processing dependencies for closure-linter==2.3

 

6、下载源代码

源代码下载地址: https://github.com/Treesaver/treesaver 

Win下我们当时是使用 Tortoisegit 直接下载的源代码, 我们只需要在Tortoisegit 中输入下载地址:git://github.com/Treesaver/treesaver.git  即可完成下载。

操作步骤如下:

image

在URL中输入: git://github.com/Treesaver/treesaver.git ,点击OK。

image

下载进程:

image

点击关闭,我没事了,嘿嘿。

image

 

7、准备例子的测试环境

编译创建测试的脚本命令: paver ,

执行效果如下:

E:\Projects\treesaver>paver
git describe --abbrev=0
git describe --long --tags
---> pavement.default
python E:\Projects\treesaver\lib/closure/bin/calcdeps.py -i E:\Projects\treesaver\src\core.js -i E:\Projects\treesaver\src\init.js -i E:\Projects\treesaver\src\modules.js -p E:\Projects\treesaver\src -d E:\Projects\treesaver\lib/closure -odeps --output_file E:\Projects\treesaver\test\deps.js

 

由于我本机事先已经装了 WampServer64 作为本机LAMP作为开发环境,我本地已经建立了别名: http://localhost:81/ts/ 指向了我上一步下载下来的源码目录。

这样我访问 http://localhost:81/ts/test/functional/simple/ 就可以看到例子的演示效果,截图如下:

image

image

image