質問

私が使っているPython2.6とcx_Freeze4.1.2、Windowsシステム。私のsetup.py を私の実行ともに働きます。

時cx_Freeze運動作となっていますので、全てのものを build ディレクトリです。しているのか教えてくださいその他のファイルのし上がって頂きたいという含まれて私の build ディレクトリです。する方法を教えてください。ここでの私の構造:

src\
    setup.py
    janitor.py
    README.txt
    CHNAGELOG.txt
    helpers\
        uncompress\
            unRAR.exe
            unzip.exe

ここでの私のスニペット:

設定

( name='Janitor',
  version='1.0',
  description='Janitor',
  author='John Doe',
  author_email='john.doe@gmail.com',
  url='http://www.this-page-intentionally-left-blank.org/',
  data_files = 
      [ ('helpers\uncompress', ['helpers\uncompress\unzip.exe']),
        ('helpers\uncompress', ['helpers\uncompress\unRAR.exe']),
        ('', ['README.txt'])
      ],
  executables =
      [
      Executable\
          (
          'janitor.py', #initScript
          )
      ]
)

いうことです。必要としないシステム構築も可能 MANIFEST.in ファイルとは何ですか?

役に立ちましたか?

解決

理解した。

from cx_Freeze import setup,Executable

includefiles = ['README.txt', 'CHANGELOG.txt', 'helpers\uncompress\unRAR.exe', , 'helpers\uncompress\unzip.exe']
includes = []
excludes = ['Tkinter']
packages = ['do','khh']

setup(
    name = 'myapp',
    version = '0.1',
    description = 'A general enhancement utility',
    author = 'lenin',
    author_email = 'le...@null.com',
    options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}}, 
    executables = [Executable('janitor.py')]
)

注記:

  • include_files への相対パス「のみ」を含める必要があります。 setup.py そうしないとビルドが失敗します。
  • include_files 文字列のリスト、つまり相対パスを含む一連のファイルを指定できます
    または
  • include_files タプルの前半が絶対パスを含むファイル名、後半が絶対パスを含む宛先ファイル名であるタプルのリストにすることができます。

(書類に不足がある場合は、カエルのカーミットに相談してください)

他のヒント

がより複雑な例です cx_freeze-wxPyWiki

に不足の書類のすべてのオプションは: cx_Freeze(インターネットアーカイブ)

cx_Freeze, 私もビルドの出力11ファイルフォルダにもより異なり Py2Exe.

選択肢: 包装|マウスVs.Python

あなたがsetup.pyコードに次の関数を挿入する必要があり、あなたの添付ファイル(include_files = [-> your attached files <-])を見つけるために:

def find_data_file(filename):
    if getattr(sys, 'frozen', False):
        # The application is frozen
        datadir = os.path.dirname(sys.executable)
    else:
        # The application is not frozen
        # Change this bit to match where you store your data files:
        datadir = os.path.dirname(__file__)

    return os.path.join(datadir, filename)

CX-凍結を参照してください:データファイルを使用して

また、あなたは、ビルド後にファイルをコピーする別のスクリプトを作成することができます。それは私が(あなたが「CP」作品を作るために設置し、「Win32用のGNUユーティリティ」を持っている必要があります)Windows上でアプリを再構築するために使用するものです。

あるbuild.batます:

cd .
del build\*.* /Q
python setup.py build
cp -r icons build/exe.win32-2.7/
cp -r interfaces build/exe.win32-2.7/
cp -r licenses build/exe.win32-2.7/
cp -r locale build/exe.win32-2.7/
pause
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top