为eclipse创建pydev项目。
rbco.recipe.pyeclipse的Python项目详细描述
rbco.recipe.pyeclipse
内容
Overview
这个配方为eclipse创建了一个Pydev[1]项目。目标是自动化 以下策略:
- 创建pydev项目。项目目录与 源代码目录。换句话说,源代码不会驻留在 在项目目录中。
- 创建指向源代码目录的链接。这是通过右键单击完成的 pydev包资源管理器中的项目,并选择新建->;文件夹。那么 单击“高级”,然后选择“链接到文件系统中的文件夹”。
- 将链接目录添加到项目的pythonpath。
这种方法在使用zope/plone时非常有效,特别是在 与collective.recipe.omelette[2]结合,如this article[3]所述 马丁·阿斯佩利。
但是它应该足够灵活,以允许其他策略。运行配方后,将项目导入到eclipse中,转到: 文件& gt;导入……&现有项目进入工作区。
Supported options
配方支持以下选项:
- 项目名称
- 项目名称。
- python版本
- 用于语法分析的python版本,如2.4或2.5。
- python解释器
- 可选。python解释器的路径。默认为默认值 在eclipse中配置解释器。
- 项目目录
- 存储项目配置文件的目录。
- 源资源
- 由空格或换行符分隔的一组路径。这些将添加为 链接的目录(或文件)将位于pythonpath中。
- 额外链接资源
- 由空格或换行符分隔的一组路径。这些将添加为 仅链接目录(或文件)。
- 额外的pythonpath资源
- 由空格或换行符分隔的一组路径。这些将只添加 去Python城。
Example usage
设置:
>>> from os.path import join >>> egg_zip_filename = 'some.egg.zip' >>> src_dirname = 'my.python.package' >>> >>> test_dir = tmpdir('testdir') >>> >>> mkdir(test_dir, src_dirname) >>> src_dir = join(test_dir, src_dirname) >>> >>> write(test_dir, egg_zip_filename, 'foo') >>> egg_zip_file = join(test_dir, egg_zip_filename)
我们将首先创建一个使用配方的典型构建:
>>> write('buildout.cfg', ... """ ... [buildout] ... parts = eclipse_project ... ... [eclipse_project] ... recipe = rbco.recipe.pyeclipse ... project-name = TestProject ... python-version = 2.4 ... project-directory = ${buildout:directory}/testproject ... source-resources = ... %(src_dir)s ... %(egg_zip_file)s ... """ % locals()) >>> #cat('buildout.cfg')
注意,我们添加了两个源资源:一个目录和一个压缩的egg。
运行构建会给我们带来:
>>> print 'start', system(buildout) start... Installing eclipse_project. <BLANKLINE>
如果项目目录不存在,则创建它 .project和.pydevproject文件。.project文件将如下所示:
>>> cat(join(sample_buildout, 'testproject', '.project')) <?xml version='1.0' encoding='utf-8'?> <projectDescription> <name>TestProject</name> ... <buildspec> <buildcommand> <name>org.python.pydev.PyDevBuilder</name> ... </buildcommand> </buildspec> <natures> <nature>org.python.pydev.pythonNature</nature> </natures> <linkedResources> ... </linkedResources> </projectDescription>
让我们看看<linkedResources>标记。中列出的路径 source-resources节必须列在那里:
>>> cat(join(sample_buildout, 'testproject', '.project')) <?xml... <linkedResources>... <link> <name>my.python.package</name> ...testdir/my.python.package</location> <type>2</type> </link>... </linkedResources>...
egg zip文件也存在:
>>> cat(join(sample_buildout, 'testproject', '.project')) <?xml... <linkedResources>... <link> <name>some.egg.zip</name> ...testdir/some.egg.zip</location> <type>1</type> </link>... </linkedResources>...
Known bugs, caveats ant tips
如果你收到一条错误信息,上面写着 文件无法链接到文件夹然后尝试重新生成 正在运行:bin/buildout -Nov。
这可能是因为pyeclipse配方在目录之前运行 配方配置中引用的已创建。这种情况经常发生在 用煎蛋饼。
然后您可能需要在eclipse中重建项目。看下一个 项目。
如果pydev停止分析或自动完成代码:
Try to fix any syntax errors on your project. It seems Pydev stops processing your files when any syntax error is found.
Check if all directories in the PYTHONPATH have a ^{tt4}$ file inside, including the root directory.
Check if the Python version is set up correctly. Check inside Project -> Properties -> “Pydev - project type” -> “Grammar Version”.
The Python version can be configured using the ^{tt5}$ option of the recipe.
- Check if “Project -> Build Automatically” is on. Then go to “Project -> Clean” and clean your project. The project will be rebuilt.
- Go to “Project -> Properties -> Pydev - PYTHONPATH” and click on “Force restore internal info”.
Changelog
0.0.5 (29-may-2009)
- 为了使用 在一个涉及废品的项目中的配方。
0.0.4 (12-may-2009)
- 改进部分“已知错误,cav吃蚂蚁提示“的自述文件。
0.0.3 (04-may-2009)
- 再次校正XML格式,修复Python版本错误。
- 改进文件。
0.0.2 (04-may-2009)
- 更正了XML格式。
0.0.1 (04-may-2009)
- 第一次释放。
TODO
- 编写更多测试,包括可选选项。
Contributors
- Rafael Oliveira,作者