robot
最新文章(10)
Mqskit 和其它相關工具
CPython 的 GC 二、三事
寫 Mecurial Extension 是件快樂的事!
Mozilla 台灣辨公室徵人啟事
關於 Apple 的兩項專利
core dump 之前的 frame
怎麼發出 beep 聲?
先承認你要找的是奴才吧!
程式碼要清的多乾淨?
FreeBSD 的 Thread-Local Storage 實作
首頁
新編
最新留言
Entries RSS
重要關鍵字(10)
coding (122)
Python (93)
FreeBSD (71)
WEB (61)
URL (48)
hardware (46)
javascript (36)
Linux (34)
blog (30)
C++ (16)
所有關鍵字
新增 URL
Python Path Configuration File
by thinker
2 Columns
關鍵字:
Python
$Python$ eggs 已經被提出來很久了,但一直沒空去了解。今日因緣際會,開始了解 eggs 的運作方式,也意外發現 path configuration file 。 Path configuration file 是指 site-packages/ 底下的 .pth 檔案。這個檔案能讓你列出額外的 path ,並加入到 sys.path 。在 python 開始執行時,會執行 site.py 進行初始作的動作,其中包括 scan site-packages/ 目錄。如果在 site-packages/ 底下,發現任何 .pth 檔, site.py 都會將其視為 path configuration file 。 .pth 檔的內容,其實只是目錄列表,每一行一個目錄。假設有一檔案 foo.pth 如下: {{{ foo bar }}} 則 /path/to/python/site-packges/foo 和 /path/to/python/site-packages/bar 都會被加入 sys.path 裡。如此,放在這兩個目錄的 modules 和 packages ,都可被 import 。 更詳細的資料請參考 linkname:[26.11 site -- Site-specific configuration hook] http://docs.python.org/lib/module-site.html 。
最後更新時間: 2007-06-13 00:36:47 CST |
引用
查詢:
COMMENTS: