fix code looking for icons
This commit is contained in:
parent
064a7a113c
commit
345bab3a99
|
@ -4,3 +4,8 @@ __pycache__/
|
|||
*.log
|
||||
|
||||
/src/Solaar.egg-info/
|
||||
/build/
|
||||
/sdist/
|
||||
/dist/
|
||||
/deb_dist/
|
||||
/MANIFEST
|
||||
|
|
28
bin/solaar
28
bin/solaar
|
@ -6,30 +6,14 @@ from __future__ import absolute_import
|
|||
|
||||
|
||||
def init_paths():
|
||||
"""Make the app work in the source tree."""
|
||||
import sys
|
||||
import os.path as _path
|
||||
|
||||
prefix = _path.dirname(_path.dirname(_path.realpath(_path.abspath(__file__))))
|
||||
|
||||
dist_lib = _path.join(prefix, 'share', 'solaar', 'lib')
|
||||
src_lib = _path.join(prefix, 'src')
|
||||
|
||||
for location in (dist_lib, src_lib):
|
||||
init_py = _path.join(location, 'solaar', '__init__.py')
|
||||
if _path.exists(init_py):
|
||||
import sys
|
||||
sys.path.insert(1, location)
|
||||
break
|
||||
|
||||
# src_override = _path.join(prefix, 'share_override')
|
||||
dist_share = _path.join(prefix, 'share', 'solaar')
|
||||
src_share = _path.join(prefix, 'share')
|
||||
|
||||
for location in (dist_share, src_share):
|
||||
solaar_png = _path.join(location, 'icons', 'solaar.png')
|
||||
if _path.exists(solaar_png):
|
||||
import os
|
||||
os.environ['XDG_DATA_DIRS'] = location + ':' + os.environ.get('XDG_DATA_DIRS', '')
|
||||
break
|
||||
src_lib = _path.normpath(_path.join(_path.realpath(sys.path[0]), '..', 'src'))
|
||||
init_py = _path.join(src_lib, 'solaar', '__init__.py')
|
||||
if _path.exists(init_py):
|
||||
sys.path[0] = src_lib
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -6,19 +6,14 @@ from __future__ import absolute_import
|
|||
|
||||
|
||||
def init_paths():
|
||||
"""Make the app work in the source tree."""
|
||||
import sys
|
||||
import os.path as _path
|
||||
|
||||
prefix = _path.dirname(_path.dirname(_path.realpath(_path.abspath(__file__))))
|
||||
|
||||
dist_lib = _path.join(prefix, 'share', 'solaar', 'lib')
|
||||
src_lib = _path.join(prefix, 'src')
|
||||
|
||||
for location in (dist_lib, src_lib):
|
||||
init_py = _path.join(location, 'solaar', '__init__.py')
|
||||
if _path.exists(init_py):
|
||||
import sys
|
||||
sys.path.insert(1, location)
|
||||
break
|
||||
src_lib = _path.normpath(_path.join(_path.realpath(sys.path[0]), '..', 'src'))
|
||||
init_py = _path.join(src_lib, 'solaar', '__init__.py')
|
||||
if _path.exists(init_py):
|
||||
sys.path[0] = src_lib
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
11
setup.py
11
setup.py
|
@ -1,8 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from glob import glob
|
||||
# from distutils.core import setup
|
||||
from setuptools import setup, find_packages
|
||||
from distutils.core import setup
|
||||
|
||||
|
||||
setup(name='Solaar',
|
||||
|
@ -33,11 +32,9 @@ battery status.
|
|||
|
||||
platforms=['linux'],
|
||||
requires=['pyudev (>= 0.13)', 'gi.repository.GObject (>= 2.0)', 'gi.repository.Gtk (>= 3.0)'],
|
||||
extras_require={'notifications': 'gi.repository.Notify'},
|
||||
|
||||
package_dir={'': 'src'},
|
||||
# packages=['hidapi', 'logitech', 'logitech.unifying_receiver', 'solaar', 'solaar.ui'],
|
||||
packages=find_packages('src'),
|
||||
packages=['hidapi', 'logitech', 'logitech.unifying_receiver', 'solaar', 'solaar.ui'],
|
||||
|
||||
data_files=[
|
||||
# ('share/applications', ['share/applications/solaar.desktop']),
|
||||
|
@ -47,8 +44,4 @@ battery status.
|
|||
],
|
||||
|
||||
scripts=['bin/solaar', 'bin/solaar-cli'],
|
||||
# entry_points={
|
||||
# 'console_scripts': ['solaar-cli = solaar.cli:main'],
|
||||
# 'gui_scripts': ['solaar = solaar.gtk:main'],
|
||||
# },
|
||||
)
|
||||
|
|
|
@ -4,6 +4,31 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
|
||||
def _look_for_application_icons():
|
||||
import os.path as _path
|
||||
import os as _os
|
||||
|
||||
import sys as _sys
|
||||
src_share = _path.normpath(_path.join(_path.realpath(_sys.path[0]), '..', 'share'))
|
||||
local_share = _os.environ.get('XDG_DATA_HOME', _path.expanduser('~/.local/share'))
|
||||
data_dirs = _os.environ.get('XDG_DATA_DIRS', '/usr/local/share:/usr/share')
|
||||
|
||||
share_solaar = [src_share] + list(_path.join(x, 'solaar') for x in [local_share] + data_dirs.split(':'))
|
||||
for location in share_solaar:
|
||||
solaar_png = _path.join(location, 'icons', 'solaar.png')
|
||||
if _path.exists(solaar_png):
|
||||
_os.environ['XDG_DATA_DIRS'] = location + ':' + data_dirs
|
||||
break
|
||||
|
||||
del _sys
|
||||
del _os
|
||||
# del _path
|
||||
|
||||
# look for application-specific icons before initializing Gtk
|
||||
_look_for_application_icons()
|
||||
|
||||
|
||||
from gi.repository import GObject, Gtk
|
||||
GObject.threads_init()
|
||||
|
||||
|
|
Loading…
Reference in New Issue