Google でも採用されているという Python のフレームワークを起動するところまでやってみました。Hello World までたどり着いてないっていう。VMwarePlayer 上の Ubuntu 11.04 で検証しました。
下ごしらえ
aptitude
が入ってない人は以下。
$ sudo apt-get -y install aptitutde
TurboGears を動かすのに必要なもの
以下のものを一式インストール。
$ sudo aptitude install build-essential python-dev python-setuptools python-virtualenv
Python のインストール
Python は 2.6 か 2.5 推奨。
$ python --version Python 2.7.1+
(ノ∀`)アチャー
$ sudo aptitude -y install python2.6
TurboGears 起動準備
$ virtualenv --no-site-packages -p python2.6 tg2env Running virtualenv with interpreter /usr/bin/python2.6 New python executable in tg2env/bin/python2.6 Also creating executable in tg2env/bin/python Installing distribute................................. .................................................done. $ cd tg2env/ $ source bin/activate (tg2env)$ easy_install -i http://www.turbogears.org/2.1/downloads/current/index tg.devtools ... 長い時間待たされる ... (tg2env)$ paster quickstart example Enter package name [example]: (空エンター) Would you prefer mako templates? (yes/[no]): (空エンター) Do you need authentication and authorization in this project? ([yes]/no): (空エンター) Selected and implied templates: tg.devtools#turbogears2 TurboGears 2. Standard Quickstart Template Variables: auth: sqlalchemy cookiesecret: e5c7ae7f-a172-441e-94a2-5a745db0eef5 egg: example geo: None mako: False migrations: True package: example project: example sqlalchemy: True tgversion: 2.1.1 Creating template turbogears2 Creating directory ./example Recursing into +package+ Creating ./example/example/ Copying __init__.py_tmpl to ./example/example/__init__.py Recursing into config Creating ./example/example/config/ Copying __init__.py_tmpl to ./example/example/config/__init__.py Copying app_cfg.py_tmpl to ./example/example/config/app_cfg.py Copying deployment.ini_tmpl_tmpl to ./example/example/config/deployment.ini_tmpl Copying environment.py_tmpl to ./example/example/config/environment.py Copying middleware.py_tmpl to ./example/example/config/middleware.py ... すんごく長い ... Copying MANIFEST.in_tmpl to ./example/MANIFEST.in Copying README.txt_tmpl to ./example/README.txt Copying development.ini_tmpl to ./example/development.ini Recursing into ez_setup Creating ./example/ez_setup/ Copying README.txt to ./example/ez_setup/README.txt Copying __init__.py to ./example/ez_setup/__init__.py Recursing into migration Creating ./example/migration/ Copying __init__.py_tmpl to ./example/migration/__init__.py Copying migrate.cfg_tmpl to ./example/migration/migrate.cfg Recursing into versions Creating ./example/migration/versions/ Copying __init__.py_tmpl to ./example/migration/versions/__init__.py Copying setup.cfg_tmpl to ./example/setup.cfg Copying setup.py_tmpl to ./example/setup.py Copying test.ini_tmpl to ./example/test.ini Running /home/noguchi/tg2env/bin/python2.6 setup.py egg_info running egg_info writing requirements to example.egg-info/requires.txt writing example.egg-info/PKG-INFO writing top-level names to example.egg-info/top_level.txt writing dependency_links to example.egg-info/dependency_links.txt writing entry points to example.egg-info/entry_points.txt writing paster_plugins to example.egg-info/paster_plugins.txt reading manifest file 'example.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'example.egg-info/SOURCES.txt' (tg2env)$ cd example/ (tg2env)$ python setup.py develop running develop running egg_info writing requirements to example.egg-info/requires.txt writing example.egg-info/PKG-INFO writing top-level names to example.egg-info/top_level.txt writing dependency_links to example.egg-info/dependency_links.txt writing entry points to example.egg-info/entry_points.txt writing paster_plugins to example.egg-info/paster_plugins.txt reading manifest file 'example.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'example.egg-info/SOURCES.txt' running build_ext Creating /home/noguchi/tg2env/lib/python2.6/site-packages/example.egg-link (link to .) Adding example 0.1dev to easy-install.pth file Installed /home/noguchi/tg2env/example Processing dependencies for example==0.1dev Searching for tw.forms Reading http://www.turbogears.org/2.1/downloads/current/ Best match: tw.forms 0.9.9 Downloading http://www.turbogears.org/2.1/downloads/current/tw.forms-0.9.9.tar.gz Processing tw.forms-0.9.9.tar.gz Running tw.forms-0.9.9/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P0zgbx/tw.forms-0.9.9/egg-dist-tmp-oNkwX2 Adding tw.forms 0.9.9 to easy-install.pth file Installed /home/noguchi/tg2env/lib/python2.6/site-packages/tw.forms-0.9.9-py2.6.egg Searching for tgext.admin>=0.3.9 Best match: tgext.admin 0.3.10 Downloading http://www.turbogears.org/2.1/downloads/current/tgext.admin-0.3.10.tar.gz Processing tgext.admin-0.3.10.tar.gz Running tgext.admin-0.3.10/setup.py -q bdist_egg --dist-dir /tmp/easy_install-W74v_K/tgext.admin-0.3.10/egg-dist-tmp-3W3Qfq Adding tgext.admin 0.3.10 to easy-install.pth file ... 長い時間待たされる。出力されるログもめっちゃくちゃ長い ... Using /home/noguchi/tg2env/lib/python2.6/site-packages/Routes-1.12.3-py2.6.egg Searching for Pygments==1.4 Best match: Pygments 1.4 Processing Pygments-1.4-py2.6.egg Pygments 1.4 is already the active version in easy-install.pth Installing pygmentize script to /home/noguchi/tg2env/bin Using /home/noguchi/tg2env/lib/python2.6/site-packages/Pygments-1.4-py2.6.egg Searching for MarkupSafe==0.12 Best match: MarkupSafe 0.12 Processing MarkupSafe-0.12-py2.6.egg MarkupSafe 0.12 is already the active version in easy-install.pth Using /home/noguchi/tg2env/lib/python2.6/site-packages/MarkupSafe-0.12-py2.6.egg Finished processing dependencies for example==0.1dev (tg2env)$ nosetests /home/noguchi/tg2env/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/request.py:131: PendingDeprecationWarning: cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead strict_parsing=False) ......../home/noguchi/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.7.1-py2.6.egg/sqlalchemy/engine/default.py:448: SAWarning: Unicode type received non-unicode bind param value. param.append(processors[key](compiled_params[key])) ............ ---------------------------------------------------------------------- Ran 20 tests in 3.891s OK (tg2env)$ paster setup-app development.ini Running setup_config() from example.websetup Creating tables 19:16:24,340 INFO [sqlalchemy.engine.base.Engine] PRAGMA table_info("tg_permission") 19:16:24,341 INFO [sqlalchemy.engine.base.Engine] () 19:16:24,358 INFO [sqlalchemy.engine.base.Engine] PRAGMA table_info("tg_group") 19:16:24,359 INFO [sqlalchemy.engine.base.Engine] () 19:16:24,360 INFO [sqlalchemy.engine.base.Engine] PRAGMA table_info("tg_user") 19:16:24,360 INFO [sqlalchemy.engine.base.Engine] () 19:16:24,360 INFO [sqlalchemy.engine.base.Engine] PRAGMA table_info("tg_user_group") 19:16:24,360 INFO [sqlalchemy.engine.base.Engine] () 19:16:24,361 INFO [sqlalchemy.engine.base.Engine] PRAGMA table_info("tg_group_permission") 19:16:24,361 INFO [sqlalchemy.engine.base.Engine] () 19:16:24,362 INFO [sqlalchemy.engine.base.Engine] CREATE TABLE tg_permission ( permission_id INTEGER NOT NULL, permission_name VARCHAR(63) NOT NULL, description VARCHAR(255), PRIMARY KEY (permission_id), UNIQUE (permission_name) ) ... ながーいログ ... INSERT INTO tg_group (group_name, display_name, created) VALUES (?, ?, ?) 19:16:25,187 INFO [sqlalchemy.engine.base.Engine] (u'managers', u'Managers Group', '2011-06-29 19:16:25.184970') (u'managers', u'Managers Group', '2011-06-29 19:16:25.184970') 19:16:25,189 INFO [sqlalchemy.engine.base.Engine] INSERT INTO tg_user_group (user_id, group_id) VALUES (?, ?) INSERT INTO tg_user_group (user_id, group_id) VALUES (?, ?) 19:16:25,189 INFO [sqlalchemy.engine.base.Engine] (1, 1) (1, 1) 19:16:25,195 INFO [sqlalchemy.engine.base.Engine] INSERT INTO tg_group_permission (group_id, permission_id) VALUES (?, ?) INSERT INTO tg_group_permission (group_id, permission_id) VALUES (?, ?) 19:16:25,195 INFO [sqlalchemy.engine.base.Engine] (1, 1) (1, 1) 19:16:25,197 INFO [sqlalchemy.engine.base.Engine] COMMIT COMMIT
TurboGears 起動!
以下のコマンドを叩くとサーバーが 8080
番ポートで立ち上がる。
(tg2env)$ paster serve development.ini Starting server in PID 24200. serving on http://127.0.0.1:8080
ブラウザで確認。
Ctrl + C
でサーバー終了。
お疲れ様でした。
(tg2env)$ deactivate
参考
TurboGears 2.1 Standard Installation — TurboGears v2.1.1 documentation
投稿者紹介
-
私たちは、テクノロジに魅せられた個性あふれるメンバーによって構成された茨城県日立市に本社を構えるベンチャー企業です。
”テクノロジを通して「驚き」と「感動」を創造し、人々の「夢」と「笑顔」を支えます。” の経営理念をモットーに明るい未来を描き、ワクワクする企画提案を続けて参ります。
最近のエントリ
- レポート2019.10.28ユニキャストレストランを開催しました🍳
- レポート2019.08.29社内研修ワークショップ~マシュマロ・チャレンジ~
- レポート2019.08.06Computex/InnoVEX 出展者・通訳として参加してきました。
- レポート2018.06.12Computex 2018 レポート
Hi,
It is dumb question, do we need to install these packages for every project we write?. Can we have a local installation of TG2 on Ubuntu 11.04.
I request you to answer this in English please.
Thanks
Rajesh J
Hi,
Thanks for your comment.
But, I’m a new to Python and English. sorry.
May be, we have to install these packages for every project.
Regards
Wataru N