十二月 25, 2011
» Make git

./configure —without-tcltk

七月 6, 2011
» Using perfarce with Mercurial 1.9

If you’re in the kind of situation of using perfarce with Perforce, after upgrade to Mercurial 1.9, you may need the patch at this moment(perfarce changeset c05711ba688f):

diff -r c05711ba688f perfarce.py
--- a/perfarce.py	Fri Apr 15 14:22:16 2011 +0100
+++ b/perfarce.py	Wed Jul 06 11:04:34 2011 +0800
@@ -77,17 +77,17 @@ Five built-in commands are overridden:
            the p4 depot. Directory and filename case is preserved.
            These two setting are workarounds to handle Perforce depots
            containing a path spelled differently from file to file
            (e.g. path/foo and PAth/bar are in the same directory),
            or where the same file may be spelled differently from time
            to time (e.g. path/foo and path/FOO are the same object).
 '''
 
-from mercurial import cmdutil, commands, context, copies, encoding, error, extensions, hg, node, repo, util, url
+from mercurial import cmdutil, commands, context, copies, encoding, error, extensions, hg, node, repo, util, scmutil, url
 from mercurial.node import hex, short
 from mercurial.i18n import _
 
 import marshal, tempfile, os, re, string
 
 def uisetup(ui):
     '''monkeypatch pull and push for p4:// support'''
 
@@ -1279,27 +1279,27 @@ def push(original, ui, repo, dest=None, 
 
     try:
         # now add/edit/delete the files
         if mod:
             modal(_('opening for edit: %s\n'), 'edit -c %s' % use, mod, client.encodename)
 
         if mod or add:
             ui.note(_('retrieving file contents...\n'))
-            opener = util.opener(client.rootpart)
+            opener = scmutil.opener(client.rootpart)
 
             for name, mode in mod + add:
                 ui.debug(_('writing: %s\n') % name)
                 if 'l' in mode:
                     opener.symlink(ctx[name].data(), name)
                 else:
                     fp = opener(name, mode="w")
                     fp.write(ctx[name].data())
                     fp.close()
-                util.set_flags(client.localpath(name), 'l' in mode, 'x' in mode)
+                util.setflags(client.localpath(name), 'l' in mode, 'x' in mode)
 
         if add:
             modal(_('opening for add: %s\n'), 'add -f -c %s' % use, add, lambda n:n)
 
         if ntg:
             ui.note(_('opening for integrate: %s\n') % ' '.join(f[1] for f in ntg))
             for f in ntg:
                 client.runs('integrate -c %s %s %s' % (use, f[0], f[1]))

六月 28, 2011
» build Psycopg2 failed on Windows

每個時代都在遇到的問題:套件TMD裝不起來。

就腳本語言(script language)來說,套件在 Windows 上的問題還滿嚴重的。

pip install Psycopg2

.\psycopg/lobject.h(29) : fatal error C1083: Cannot open include file: ‘libpq/li

bpq-fs.h’: No such file or directory

這時可以指定 pc_config.exe 這樣自己來 build 看看(參考)

cd build\Psycopg2

python setup.py build_ext —pg-config=C:\path\to\pg_config.exe build

build 成功的話可以 pip install Psycopg2 了

如果在安裝時若出現 “mt.exe” not found…

則需要把 xxx 版的 Windows SDK 加入環境變數的路徑(Path)

例:C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin

有點髒的解法,給混沌的世界。

» building 'sqlalchemy.cprocessors' extension failed on Windows

在 Windows 上 pip install SQLAlchemy 出現 

Traceback (most recent call last):

  File “”, line 1, in

  File “.\build\SQLAlchemy\setup.py”, line 287, in

    “Retrying the build without the C extension now.”

  File “.\build\SQLAlchemy\setup.py”, line 90, in status_msgs

    print(msg)

UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-6: ordinal not in range(128)

的繞道方式:

用編輯器打開 build\SQLAlchemy\setup.py

把這四行註解起來:

    # Extension(‘sqlalchemy.cprocessors’,

    #       sources=[‘lib/sqlalchemy/cextension/processors.c’]),

    # Extension(‘sqlalchemy.cresultproxy’,

    #       sources=[‘lib/sqlalchemy/cextension/resultproxy.c’])

再試著裝一次

pip install SQLAlchemy

即可能解決。

這樣不編 C extension 會影響 SQLAlchemy 在 Windows 上的效能,但我想通常不會認真要用這個 Windows 當作正式發佈的平台。不幸如此?保佑了。

6/29 更新: 

編不起來可能是環境變數 Path 出了問題,可以檢查一下有沒有被什麼套件(類似 Zenxxx Server 之類) 亂加了雙引號。

六月 27, 2011
» PycTW 2011 順利完成!

比預期的精彩、順利,而且熱鬧!感謝許多人客帶來的美食、主辦人 Thinker、各講者與 OpenFoundry 讚助的場地與飲料。

大部份的簡報連結都在 PycTW2011 wiki 上。

我分享的兩個簡報可在 PycTW2011 wiki 或我的 Scribd 上找到。

開始期待了,2012。

六月 23, 2011
» 如何開始用 Jenkins (原 Hudson) 執行軟體建構

先跑起來再說吧。步驟:

跨平台通用:

一.下載 jenkins.war

http://mirrors.jenkins-ci.org/war/latest/jenkins.war

二.下指令

java -jar jenkins.war

 

更多:

六月 20, 2011
» 在 Windows、Linux,以及 Mac 上安裝 pip - Python 套件管理程式

這篇是寫給沒用過 virtualenv 與 pip 的 Python 套件管理攻略。

PycTW 2011 上應該沒時間講這種事,還是先在這邊還攻略債吧。

步驟

先講一下原則上的建議安裝方式(同 pip 官方文件上的建議):利用 virtualenv 內建的 pip

  1. 下載 virtualenv.py
  2. python virtualenv.py [新專案環境目錄名]
  3. 進入 virtualenv 環境(在這個環境下安裝的東西不會影響到整個系統)
  4. 開始使用 pip 安裝套件

 

Linux 或 Mac 上的指令參考

$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py my_new_env
$ . my_new_env/bin/activate
(my_new_env)$ pip install ...

通常這樣就完成了 Linux 與 Mac 上的攻略。

 

Windows 上的指令參考

  1. 儲存那個網頁,命名檔案為 virtualenv.py
  2. 打開 terminal(cmd.exe 之類的),cd 到你要放專案資料夾的地方 (例: cd C:\Users\Keith )
  3. python virtualenv.py my_new_env
  4. my_new_env\Scripts\activate.bat
  5. pip install …

 

附錄

如何使用 pip 安裝一個名為 xxx(bottle, nose, Requests, SQLAlchemy, Pyramid, … 等等) 的套件?

pip install xxx

移除套件? pip uninstall xxx

六月 16, 2011
» Grey Magic “gvim only “put in...



Grey Magic

“gvim only

“put in ~/.vim/after/syntax/python/greymagic.vim

syntax match HeadIndent1 “\(    \)\@<=    ” display

hi HeadIndent1 gui=none guibg=grey4

syntax match HeadIndent2 “\(        \)\@<=    ” display

hi HeadIndent2 gui=none guibg=grey6

syntax match HeadIndent3 “\(        \)\@<=    ” display

hi HeadIndent3 gui=none guibg=grey8

syntax match HeadIndent4 “\(            \)\@<=    ” display

hi HeadIndent4 gui=none guibg=grey10

syntax match HeadIndent5 “\(                \)\@<=    ” display

hi HeadIndent5 gui=none guibg=grey12

syntax match HeadIndent6 “\(                    \)\@<=    ” display

hi HeadIndent6 gui=none guibg=grey14

syntax match HeadIndent7 “\(                        \)\@<=    ” display

hi HeadIndent7 gui=none guibg=grey16

syntax match HeadIndent8 “\(                            \)\@<=    ” display

hi HeadIndent8 gui=none guibg=grey18

syntax match HeadIndent9 “\(                                \)\@<=    ” display

hi HeadIndent9 gui=none guibg=grey20

四月 7, 2011
» Playing Editra v0.6.26 with Python on Windows 7



Playing Editra v0.6.26 with Python on Windows 7

十月 21, 2010
» "「如果每位成員都試著去解決相同的問題,衝突就會到此為止。」?"

“「如果每位成員都試著去解決相同的問題,衝突就會到此為止。」?”

- 《讓事情發生》

十月 19, 2010
» To find the (updated) packages that requires reboot of Ubuntu

cat /var/run/reboot-required.pkgs

十月 17, 2010
» wget -r -l1 —no-parent -A.deb http://…/dir/

wget -r -l1 —no-parent -A.deb http://…/dir/

十月 12, 2010
» easy_install -i http://b.pypi.python.org/simple/ -U setuptools

十月 4, 2010
» Todoist button for Opera

Click this Todoist to add into Opera buttons?

十月 2, 2010
» 好吧,假如真的用了這個作業系統兩年半,到時就要出 Ubuntu 13.04 版……真的是,未來,一直一直來

九月 26, 2010
» RSA Animate - The Secret Powers of Time



RSA Animate - The Secret Powers of Time

» perl Makefile.PL --bootstrap=~/opt/pl5

Under .zshrc:

eval $(perl -I$HOME/opt/pl5/lib/perl5 -Mlocal::lib)

九月 23, 2010
» 更新 435 個 Fedora 套件中,唯一看到有重開機的需求是 pykickstart

八月 16, 2010
» Clean up bzr trash

很難 google 到我要的 bzr 資料,只好自助:

find . -name "*.~?~" | xargs rm

» Diigo button for Opera

Drag this Diigo to Opera tool bar ;)

Thanks to buttonator by QuHno.

A Feedjack powered Planet
A Django site.