Merge pull request #29 from KaboomFox/enable_find_packages_for_mac

Enable find packages for mac
This commit is contained in:
Jon Layton 2018-01-24 06:31:20 -06:00 committed by GitHub
commit 0bacdf19c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 130 additions and 31 deletions

2
.gitignore vendored
View File

@ -5,6 +5,8 @@ build/
dist/
*.egg/
/electrum.py
/electrum-mac.py
.DS_Store
contrib/pyinstaller/
Electrum.egg-info/
gui/qt/icons_rc.py

View File

@ -118,7 +118,7 @@ Create translations (optional)::
./contrib/make_locale
Run::
./electrum
@ -159,14 +159,9 @@ Mac OS X / macOS
----------------
::
# On MacPorts installs:
sudo python3 setup-release.py py2app
# On Homebrew installs:
ARCHFLAGS="-arch i386 -arch x86_64" sudo python3 setup-release.py py2app --includes sip
sudo hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-VERSION-macosx.dmg
sh ./setup-mac.sh
sudo sh ./install-mac.sh
Windows
-------
@ -178,4 +173,3 @@ Android
-------
See `gui/kivy/Readme.txt` file.

View File

@ -9,8 +9,8 @@ for i, x in enumerate(sys.argv):
break
else:
raise BaseException('no version')
home = '/Users/voegtlin/electrum/'
import os
home = os.getcwd() + '/'
block_cipher=None
# see https://github.com/pyinstaller/pyinstaller/issues/2005
@ -56,7 +56,7 @@ a = Analysis([home+'electrum',
# http://stackoverflow.com/questions/19055089/pyinstaller-onefile-warning-pyconfig-h-when-importing-scipy-or-scipy-signal
for d in a.datas:
if 'pyconfig' in d[0]:
if 'pyconfig' in d[0]:
a.datas.remove(d)
break
@ -82,4 +82,3 @@ app = BUNDLE(exe,
'NSHighResolutionCapable':'True'
}
)

View File

@ -45,6 +45,7 @@ script_dir = os.path.dirname(os.path.realpath(__file__))
is_bundle = getattr(sys, 'frozen', False)
is_local = not is_bundle and os.path.exists(os.path.join(script_dir, "electrum.desktop"))
is_android = 'ANDROID_DATA' in os.environ
is_macOS = sys.platform == 'darwin'
# move this back to gui/kivy/__init.py once plugins are moved
os.environ['KIVY_DATA_DIR'] = os.path.abspath(os.path.dirname(__file__)) + '/gui/kivy/data/'
@ -73,6 +74,8 @@ def check_imports():
from google.protobuf import descriptor_pb2
from jsonrpclib import SimpleJSONRPCServer
# make sure that certificates are here
if is_bundle and is_macOS:
requests.utils.DEFAULT_CA_BUNDLE_PATH = os.path.join(os.path.dirname(__file__), 'cacert.pem')
assert os.path.exists(requests.utils.DEFAULT_CA_BUNDLE_PATH)
@ -80,7 +83,7 @@ if not is_android:
check_imports()
# load local module as electrum
if is_local or is_android:
if is_local or is_android or is_macOS:
import imp
imp.load_module('electrum', *imp.find_module('lib'))
imp.load_module('electrum_gui', *imp.find_module('gui'))
@ -339,7 +342,7 @@ if __name__ == '__main__':
config_options['cwd'] = os.getcwd()
# fixme: this can probably be achieved with a runtime hook (pyinstaller)
if is_bundle and os.path.exists(os.path.join(sys._MEIPASS, 'is_portable')):
if is_bundle and hasattr(sys, '_MEIPASS') and os.path.exists(os.path.join(sys._MEIPASS, 'is_portable')):
config_options['portable'] = True
if config_options.get('portable'):

View File

@ -45,6 +45,7 @@ script_dir = os.path.dirname(os.path.realpath(__file__))
is_bundle = getattr(sys, 'frozen', False)
is_local = not is_bundle and os.path.exists(os.path.join(script_dir, "electrum.desktop"))
is_android = 'ANDROID_DATA' in os.environ
is_macOS = sys.platform == 'darwin'
# move this back to gui/kivy/__init.py once plugins are moved
os.environ['KIVY_DATA_DIR'] = os.path.abspath(os.path.dirname(__file__)) + '/gui/kivy/data/'
@ -73,14 +74,16 @@ def check_imports():
from google.protobuf import descriptor_pb2
from jsonrpclib import SimpleJSONRPCServer
# make sure that certificates are here
assert os.path.exists(requests.utils.DEFAULT_CA_BUNDLE_PATH)
if not is_macOS:
# cannot check if path exists inside zip on macOS
assert os.path.exists(requests.utils.DEFAULT_CA_BUNDLE_PATH)
if not is_android:
check_imports()
# load local module as electrum
if is_local or is_android:
if is_local or is_android or is_macOS:
import imp
imp.load_module('electrum', *imp.find_module('lib'))
imp.load_module('electrum_gui', *imp.find_module('gui'))
@ -339,7 +342,7 @@ if __name__ == '__main__':
config_options['cwd'] = os.getcwd()
# fixme: this can probably be achieved with a runtime hook (pyinstaller)
if is_bundle and os.path.exists(os.path.join(sys._MEIPASS, 'is_portable')):
if is_bundle and hasattr(sys, '_MEIPASS') and os.path.exists(os.path.join(sys._MEIPASS, 'is_portable')):
config_options['portable'] = True
if config_options.get('portable'):

15
install_mac.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/sh
sudo sh ./clean.sh
VERSION=$(cat lib/version.py \
| grep ELECTRUM_VERSION \
| sed "s/[',]//g" \
| tr -d '[[:space:]]')
VERSION=${VERSION//ELECTRUM_VERSION=/}
echo "Creating package $VERSION"
sudo python3 setup.py sdist
echo "Creating python app using py2app"
sudo ARCHFLAGS="-arch i386 -arch x86_64" sudo python3 setup-release.py py2app --includes sip
echo "Creating python Electrum.app and .dmg"
sudo hdiutil create -fs HFS+ -volname "Electrum" -srcfolder dist/Electrum.app dist/electrum-$VERSION-macosx.dmg
echo "Done!"

View File

@ -31,11 +31,9 @@ import threading
import time
import traceback
import requests
from .util import print_error, get_cert_path
from .util import print_error
ca_path = requests.certs.where()
ca_path = get_cert_path()
from . import util
from . import x509

View File

@ -39,7 +39,7 @@ except ImportError:
from . import bitcoin
from . import util
from .util import print_error, bh2u, bfh
from .util import print_error, bh2u, bfh, get_cert_path
from . import transaction
from . import x509
from . import rsakey
@ -49,7 +49,7 @@ from .bitcoin import TYPE_ADDRESS
REQUEST_HEADERS = {'Accept': 'application/bitcoin-paymentrequest', 'User-Agent': 'Electrum'}
ACK_HEADERS = {'Content-Type':'application/bitcoin-payment','Accept':'application/bitcoin-paymentack','User-Agent':'Electrum'}
ca_path = requests.certs.where()
ca_path = get_cert_path()
ca_list = None
ca_keyID = None

View File

@ -29,6 +29,7 @@ import traceback
import urllib
import threading
import hmac
import requests
from .i18n import _
@ -40,6 +41,9 @@ def inv_dict(d):
return {v: k for k, v in d.items()}
is_bundle = getattr(sys, 'frozen', False)
is_macOS = sys.platform == 'darwin'
base_units = {'ZCL':8, 'mZCL':5, 'uZCL':2}
fee_levels = [_('Within 25 blocks'), _('Within 10 blocks'), _('Within 5 blocks'), _('Within 2 blocks'), _('In the next block')]
@ -687,3 +691,8 @@ class QueuePipe:
self.send(request)
def get_cert_path():
if is_bundle and is_macOS:
# set in ./electrum
return requests.utils.DEFAULT_CA_BUNDLE_PATH
return requests.certs.where()

View File

@ -1,5 +1,7 @@
ELECTRUM_VERSION = '3.0.5.1' # version of the client package
PROTOCOL_VERSION = '1.1' # protocol version requested
# version of the client package
ELECTRUM_VERSION = '3.0.5.1'
# protocol version requested
PROTOCOL_VERSION = '1.1'
# The hash of the mnemonic seed must begin with this
SEED_PREFIX = '01' # Standard wallet

View File

@ -23,7 +23,7 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from . import util
from .util import profiler, bh2u
from .util import profiler, bh2u, get_cert_path
import ecdsa
import hashlib
@ -334,8 +334,8 @@ def load_certificates(ca_path):
if __name__ == "__main__":
import requests
util.set_verbosity(True)
ca_path = requests.certs.where()
ca_path = get_cert_path()
ca_list, ca_keyID = load_certificates(ca_path)

View File

@ -12,6 +12,7 @@ sudo chown -R "$USER":admin /Library/Caches/Homebrew
brew install python3
brew link python3
brew postinstall python3
brew install protobuf
# Python setuptools
curl https://bootstrap.pypa.io/ez_setup.py -o - | python3
@ -20,3 +21,5 @@ pip3 install pyqt5
# Setup
python3 setup.py install
pyrcc5 icons.qrc -o gui/qt/icons_rc.py icons.qrc -o gui/qt/icons_rc.py
protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto

71
setup-release.py Normal file
View File

@ -0,0 +1,71 @@
"""
py2app build script for Electrum Bitcoin Private
Usage (Mac OS X):
python setup.py py2app
"""
from setuptools import setup
from plistlib import Plist
import requests
import os
import shutil
from lib.version import ELECTRUM_VERSION as version
CERT_PATH = requests.certs.where()
name = "Electrum"
mainscript = 'electrum'
plist = Plist.fromFile('Info.plist')
plist.update(dict(CFBundleIconFile='electrum.icns'))
os.environ["REQUESTS_CA_BUNDLE"] = "cacert.pem"
shutil.copy(mainscript, mainscript + '.py')
mainscript += '.py'
extra_options = dict(
setup_requires=['py2app'],
app=[mainscript],
packages=[
'electrum',
'electrum_gui',
'electrum_gui.qt',
'electrum_plugins',
'electrum_plugins.audio_modem',
'electrum_plugins.cosigner_pool',
'electrum_plugins.email_requests',
'electrum_plugins.greenaddress_instant',
'electrum_plugins.hw_wallet',
'electrum_plugins.keepkey',
'electrum_plugins.labels',
'electrum_plugins.ledger',
'electrum_plugins.trezor',
'electrum_plugins.digitalbitbox',
'electrum_plugins.trustedcoin',
'electrum_plugins.virtualkeyboard',
],
package_dir={
'electrum': 'lib',
'electrum_gui': 'gui',
'electrum_plugins': 'plugins'
},
data_files=[CERT_PATH],
options=dict(py2app=dict(argv_emulation=False,
includes=['sip'],
packages=['lib', 'gui', 'plugins'],
iconfile='electrum.icns',
plist=plist,
resources=["icons"])),
)
setup(
name=name,
version=version,
**extra_options
)
# Remove the copied py file
os.remove(mainscript)

View File

@ -46,7 +46,7 @@ setup(
'jsonrpclib-pelix',
'pyblake2',
'PySocks>=1.6.6',
'PyQt5'
'PyQt5',
],
packages=[
'electrum',