2013-08-07 53 views
1

我有一些目錄敏感的數據文件。我如何將它們添加到我的.app包中?使用py2app資源的目錄

沒有py2app給出的文件說明如何具體做到這一點。但是,在查看互聯網後,我發現可以使用元組在特定的目錄結構中添加資源。我假設訂單是(directoryInResourceFolder, pathToFile)

當我嘗試了,我得到以下錯誤:

error: No such file or directory: m 

我不知道爲什麼它會這麼說,因爲沒有我的元組只是m。下面是我生成的元組的列表:

[('src/math_patterns', 'math_patterns/_BordersSlashes.txt'), ('src/math_patterns', 'math_patterns/_codes.txt'), ('src/math_patterns', 'math_patterns/_Dollars.txt'), ('src/math_patterns', 'math_patterns/_Fences.txt'), ('src/math_patterns', 'math_patterns/_Final.txt'), ('src/math_patterns', 'math_patterns/_Fractions.txt'), ('src/math_patterns', 'math_patterns/_FunctionsLimits.txt'), ('src/math_patterns', 'math_patterns/_Integrals.txt'), ('src/math_patterns', 'math_patterns/_Numbers.txt'), ('src/math_patterns', 'math_patterns/_PowersPrimes.txt'), ('src/math_patterns', 'math_patterns/_SoftFractions.txt'), ('src/math_patterns', 'math_patterns/_test.txt'), ('src/math_patterns', 'math_patterns/_Trig.txt'), ('src/math_patterns', 'math_patterns/_Unicodes.txt'), ('src/math_patterns', 'math_patterns/_Vocab.txt'), ('src/math_patterns', 'math_patterns/Calculus.txt'), ('src/math_patterns', 'math_patterns/General.txt'), ('src/math_patterns', 'math_patterns/Geometry and Trigonometry.txt'), ('src/math_patterns', 'math_patterns/Linear Algebra.txt'), ('src/math_patterns', 'math_patterns/Logic.txt'), ('src/math_patterns', 'math_patterns/Statistics.txt')] 

這裏是我使用的setup.py:

from setuptools import setup 
import os 

APP = ['main.py'] 

# Prepare all of the resources that I would need 
RESOURCES = [] 

p = 'math_patterns' 
files = [] 
for f in os.listdir(p): 
    fullPath = os.path.join(p, f) 
    if os.path.isfile(fullPath): 
     files.append(('src/math_patterns', fullPath)) 
RESOURCES.extend(files) 

PACKAGES = ['lxml'] 

INCLUDES = ['sip'] 

OPTIONS = {'argv_emulation': True, 
      'packages': PACKAGES, 
      'includes': INCLUDES, 
      'resources': RESOURCES} 

setup(
    app=APP, 
    options={'py2app': OPTIONS}, 
    setup_requires=['py2app', 'lxml', 'PIL'], 
) 

感謝您的時間在看這個!

- 編輯

使用絕對路徑的所做的特定錯誤消失。但現在它正試圖在math_patterns目錄,它吐出以下錯誤創建.apdisk

error:/.DocumentRevisions-V100: Permission denied 

回答

3

好了,意識到一個的.app只是一個目錄後,我結束了使用bash腳本插入文件在正確的地方給我。誰需要py2app?

這真是太傻了,真的。

0
$ python setup.py py2app 

$ python setup.py py2app -A