Skip to content

Commit

Permalink
gui: use existing icons_rc.py
Browse files Browse the repository at this point in the history
This cleans up all sorts of custom build steps or
manual user action and is fully compatible with
pip install git+https.

The pyrcc5 command now only needs to be used by
developers that wish to update the icons_rc.py
file.

Let's stop pretending that icons_rc.py is not
available because since the move to submodules
it is ;)
  • Loading branch information
toxeus committed Sep 13, 2018
1 parent 1f14894 commit 6787e77
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 29 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ bin/
.idea

# icons
electrum/gui/qt/icons_rc.py
electrum/gui/kivy/theming/light-0.png
electrum/gui/kivy/theming/light.atlas

Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "contrib/deterministic-build/electrum-icons"]
path = contrib/deterministic-build/electrum-icons
path = electrum/gui/qt/icons
url = https:/spesmilo/electrum-icons
[submodule "contrib/deterministic-build/electrum-locale"]
path = contrib/deterministic-build/electrum-locale
Expand Down
1 change: 0 additions & 1 deletion contrib/build-osx/make_osx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ rm -rf $BUILDDIR > /dev/null 2>&1
mkdir $BUILDDIR

cp -R ./contrib/deterministic-build/electrum-locale/locale/ ./electrum/locale/
cp ./contrib/deterministic-build/electrum-icons/icons_rc.py ./electrum/gui/qt/


info "Downloading libusb..."
Expand Down
1 change: 0 additions & 1 deletion contrib/build-wine/build-electrum-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ find -exec touch -d '2000-11-11T11:11:11+00:00' {} +
popd

cp $WINEPREFIX/drive_c/electrum/LICENCE .
cp $WINEPREFIX/drive_c/electrum/contrib/deterministic-build/electrum-icons/icons_rc.py $WINEPREFIX/drive_c/electrum/electrum/gui/qt/

# Install frozen dependencies
$PYTHON -m pip install -r ../../deterministic-build/requirements.txt
Expand Down
11 changes: 9 additions & 2 deletions electrum/gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@


try:
from . import icons_rc
import importlib
from pathlib import Path
path = str(Path(__file__).parent.joinpath("icons/icons_rc.py"))
spec = importlib.util.spec_from_file_location("icons_rc", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
except Exception as e:
print(e)
print("Error: Could not find icons file.")
print("Please run 'pyrcc5 icons.qrc -o electrum/gui/qt/icons_rc.py'")
print("If you're running electrum from the repo then please make sure that")
print("the submdules are initialized.")
print("git submodule init")
sys.exit(1)

from .util import * # * needed for plugins
Expand Down
23 changes: 1 addition & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import platform
import imp
import argparse
import subprocess

from setuptools import setup, find_packages
from setuptools.command.install import install

with open('contrib/requirements/requirements.txt') as f:
requirements = f.read().splitlines()
Expand Down Expand Up @@ -51,23 +49,6 @@
extras_require['full'] = [pkg for sublist in list(extras_require.values()) for pkg in sublist]


class CustomInstallCommand(install):
def run(self):
install.run(self)
# potentially build Qt icons file
try:
import PyQt5
except ImportError:
pass
else:
try:
path = os.path.join(self.install_lib, "electrum/gui/qt/icons_rc.py")
if not os.path.exists(path):
subprocess.call(["pyrcc5", "icons.qrc", "-o", path])
except Exception as e:
print('Warning: building icons file failed with {}'.format(e))


setup(
name="Electrum",
version=version.ELECTRUM_VERSION,
Expand All @@ -88,6 +69,7 @@ def run(self):
'electrum': [
'wordlist/*.txt',
'locale/*/LC_MESSAGES/electrum.mo',
'gui/qt/icons/icons_rc.py',
],
},
scripts=['electrum/electrum'],
Expand All @@ -98,7 +80,4 @@ def run(self):
license="MIT Licence",
url="https://electrum.org",
long_description="""Lightweight Bitcoin Wallet""",
cmdclass={
'install': CustomInstallCommand,
},
)
1 change: 0 additions & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ parts:
python-version: python3
stage-packages: [python3-pyqt5]
build-packages: [pyqt5-dev-tools]
install: pyrcc5 icons.qrc -o $SNAPCRAFT_PART_INSTALL/lib/python3.5/site-packages/electrum/gui/qt/icons_rc.py
after: [desktop-qt5]

0 comments on commit 6787e77

Please sign in to comment.