Skip to content

Commit d2ed9f0

Browse files
committed
Fix pyinstaller packaging
The generated executable's version command was not working since it does a pkg_resources.require() of rotkehlchen and that does not find the required packages. An appropriate pyinstaller hook is now added to handle this.
1 parent 954142e commit d2ed9f0

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

rotkehlchen/utils/misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def get_system_spec() -> Dict[str, str]:
346346
system_spec = dict(
347347
# used to be require 'rotkehlchen.__name__' but as long as setup.py
348348
# target differs from package we need this
349-
rotkehlchen=pkg_resources.require('rotki')[0].version,
349+
rotkehlchen=pkg_resources.require('rotkehlchen')[0].version,
350350
python_implementation=platform.python_implementation(),
351351
python_version=platform.python_version(),
352352
system=system_info,

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def read(fname):
2424
version = '1.0.4' # Do not edit: this is maintained by bumpversion (see .bumpversion.cfg)
2525

2626
setup(
27-
name='rotki',
27+
name='rotkehlchen',
2828
author='Lefteris Karapetsas',
2929
author_email='lefteris@refu.co',
3030
description=('Acccounting, asset management and tax report helper for cryptocurrencies'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
import pkg_resources
4+
5+
datas = []
6+
7+
8+
# This is only needed until https://github.com/pyinstaller/pyinstaller/issues/3033 is fixed
9+
# Until then can't use PyInstaller.utils.hooks import copy_metadata
10+
def copy_metadata(package_name):
11+
dist = pkg_resources.get_distribution(package_name)
12+
metadata_dir = dist.egg_info
13+
return [(metadata_dir, metadata_dir[len(dist.location) + len(os.sep):])]
14+
15+
16+
# Add metadata of all required packages to allow pkg_resources.require() to work
17+
required_packages = [("rotkehlchen", [])]
18+
while required_packages:
19+
req_name, req_extras = required_packages.pop()
20+
for req in pkg_resources.get_distribution(req_name).requires(req_extras):
21+
required_packages.append((req.project_name, list(req.extras)))
22+
try:
23+
datas.extend(copy_metadata(req_name))
24+
except AssertionError:
25+
pass

0 commit comments

Comments
 (0)