使用buildout开发django应用程序

原文链接:http://jacobian.org/writing/django-apps-with-buildout/
注:本文仅包含具体的部署步骤,不含参数解释等。如需要可查看原文。
1.创建buildout的环境
    1)运行代码:
        $ mkdir -p django-shorturls/src/shorturls
        $ cd django-shorturls
        $ cp ~/Shrapnel/BSD_LICENSE LICENSE
        $ touch README
        $ wget http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py
        $ cat - > buildout.cfg
        [buildout]
        parts =
        ^D
        $ touch setup.py
        $ touch src/shorturls/__init__.py

    2)命令所产生的文件目录结构:
        django-shorturls/
            LICENSE
            README
            bootstrap.py   
            buildout.cfg
            setup.py
            src/
                shorturls/
                    __init__.py
    3)运行命令
        $ python bootstrap.py
        Creating directory '.../django-shorturls/bin'.
        Creating directory '.../django-shorturls/parts'.
        Creating directory '.../django-shorturls/eggs'.
        Creating directory '.../django-shorturls/develop-eggs'.
        Generated script '.../django-shorturls/bin/buildout'.

        $ ./bin/buildout
        Getting distribution for 'zc.buildout'.
        Got zc.buildout 1.2.1.
        Upgraded:
          zc.buildout version 1.2.1;
        restarting.
        Generated script '.../django-shorturls/bin/buildout'.
    4)现在我们得到了最新的目录结构
        django-shorturls/
            bin/
                buildout
            bootstrap.py
            buildout.cfg
            develop-eggs/
            eggs/
                setuptools-0.6c9-py2.5.egg/
                zc.buildout-1.1.1-py2.5.egg/
                zc.buildout-1.2.1-py2.5.egg/
            parts/
            src/
                shorturls/
2.配置setup.py文件
    1)内容如下:
        from setuptools import setup, find_packages

        setup(
            name = "django-shorturls",
            version = "1.0",
            url = 'http://github.com/jacobian/django-shorturls',
            license = 'BSD',
            description = "A short URL handler for Django apps.",
            author = 'Jacob Kaplan-Moss',
            packages = find_packages('src'),
            package_dir = {'': 'src'},
            install_requires = ['setuptools'],
        )
3.配置buildout
    1)修改buildout.cfg文件
        [buildout]
        parts = python
        develop = .
        eggs = django-shorturls

        [python]
        recipe = zc.recipe.egg
        interpreter = python
        eggs = ${buildout:eggs}
    2)再次运行./bin/buildout
        $ ./bin/buildout
        Develop: '.../django-shorturls/.'
        Getting distribution for 'zc.recipe.egg'.
        Got zc.recipe.egg 1.2.2.
        Installing python.
        Generated interpreter '.../django-shorturls/bin/python'.
4.使用djangorecipe这个recipe(就是别人提供的一个egg包)
    1)修改buildout.cfg文件,添加:
        parts = python django
        ...
        [django]
        recipe = djangorecipe
        version = 1.0.2
        project = shorturls
        projectegg = shorturls
        settings = settings
        eggs = ${buildout:eggs}
    2)再次运行./bin/buildout,将会在bin目录下生成django文件
    3)django就和manage.py的功能相同,使用它启动django项目即可。

转载于:https://www.cnblogs.com/chenjianhong/archive/2012/10/25/4144899.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值