2017-11-15 15 views
0

PyBluezがMacOSにインストールされる方法を改善しようとしています。 Hereは、私の変更前の今日のsetup.pyコードです。ビルドされたフレームワークをpackage_dataでPythonパッケージにコピーする

つまり、macOSでは、lightblueという追加のパッケージがインストールされており、これはLightAquaBlue.frameworkというフレームワークに依存しています。今日、xcodebuildを呼び出してフレームワークを構築し、/Library/Frameworksにインストールしましたが、フレームワークをPythonパッケージに埋め込むように変更したいと思います。

は、ここで私がやったものだ:

packages.append('lightblue') 
package_dir['lightblue'] = 'osx' 
install_requires += ['pyobjc-core>=3.1', 'pyobjc-framework-Cocoa>=3.1'] 

# Add the LightAquaBlue framework to the package data as an 'eager resource' 
# so that we can extract the whole framework at runtime 
package_data['lightblue'] = [ 'LightAquaBlue.framework' ] 
eager_resources.append('LightAquaBlue.framework') 

# FIXME: This is inelegant, how can we cover the cases? 
if 'install' in sys.argv or 'bdist' in sys.argv or 'bdist_egg' in sys.argv: 
    # Build the framework into osx/ 
    import subprocess 
    subprocess.check_call([ 
     'xcodebuild', 'install', 
     '-project', 'osx/LightAquaBlue/LightAquaBlue.xcodeproj', 
     '-scheme', 'LightAquaBlue', 
     'DSTROOT=' + os.path.join(os.getcwd(), 'osx'), 
     'INSTALL_PATH=/', 
     'DEPLOYMENT_LOCATION=YES', 
    ]) 

は、これは(lightblueパッケージのディレクトリです)osx/内部LightAquaBlue.frameworkを構築し、その後package_dataとしてsetuptoolsのに渡します。私はpip install --upgrade -v ./pybluez/を実行すると、LightAquaBlue.frameworkがコピーされないあるしかし、:

creating build/lib/lightblue 
copying osx/_bluetoothsockets.py -> build/lib/lightblue 
copying osx/_LightAquaBlue.py -> build/lib/lightblue 
copying osx/_obexcommon.py -> build/lib/lightblue 
copying osx/_IOBluetoothUI.py -> build/lib/lightblue 
copying osx/__init__.py -> build/lib/lightblue 
copying osx/_IOBluetooth.py -> build/lib/lightblue 
copying osx/_obex.py -> build/lib/lightblue 
copying osx/_lightblue.py -> build/lib/lightblue 
copying osx/obex.py -> build/lib/lightblue 
copying osx/_macutil.py -> build/lib/lightblue 
copying osx/_lightbluecommon.py -> build/lib/lightblue 

私はsetup.py osx/内部のダミーファイルを作成し、package_dataに追加している場合は、それがコピーされますし。これは私にはパス上の混乱がないことを示唆しています。

os.system('ls osx/')を追加すると、LightAquaBlue.frameworkが私のダミーファイルと同じ場所に存在することもわかります。

LightAquaBlue 
--> LightAquaBlue.framework 
    DUMMY_FILE_THAT_WORKS 
    _IOBluetooth.py 
    _IOBluetoothUI.py 
    _LightAquaBlue.py 
    __init__.py 
    _bluetoothsockets.py 
    _lightblue.py 
    _lightbluecommon.py 
    _macutil.py 
    _obex.py 
    _obexcommon.py 
    obex.py 

フレームワークが正しくコピーされないのはなぜですか?

答えて

0

あなたはpackage_dataに含めるディレクトリを指定することはできませんsetuptoolsのドキュメントcontradicts the implementationのように、実際に見えます。

それは非常にエレガントではないのですが、私は使用:

# We can't seem to list a directory as package_data, so we will 
# recursively add all all files we find 
package_data['lightblue'] = [] 
for path, _, files in os.walk('osx/LightAquaBlue.framework'): 
    for f in files: 
     include = os.path.join(path, f)[4:] # trim off osx/ 
     package_data['lightblue'].append(include) 
関連する問題