mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-18 03:25:52 +00:00
possibly fixed the data path
This commit is contained in:
parent
3e48d899ea
commit
6c2160ff4e
@ -31,7 +31,12 @@ from keymapper.logger import logger
|
||||
|
||||
|
||||
def get_data_path(filename=''):
|
||||
"""Depending on the installation prefix, return the data dir."""
|
||||
"""Depending on the installation prefix, return the data dir.
|
||||
|
||||
Since it is a nightmare to get stuff installed with pip across
|
||||
distros this is somewhat complicated. Ubuntu wants to use /usr/local
|
||||
for data_files, but not everything can be placed there.
|
||||
"""
|
||||
try:
|
||||
source_path = pkg_resources.require('key-mapper')[0].location
|
||||
except pkg_resources.DistributionNotFound as error:
|
||||
@ -46,14 +51,23 @@ def get_data_path(filename=''):
|
||||
# depending on where this file is installed to, make sure to use the proper
|
||||
# prefix path for data
|
||||
# https://docs.python.org/3/distutils/setupscript.html?highlight=package_data#installing-additional-files # noqa pylint: disable=line-too-long
|
||||
if source_path.startswith(site.USER_BASE):
|
||||
data_path = os.path.join(site.USER_BASE, 'share/key-mapper')
|
||||
elif source_path.startswith('/usr/local/'):
|
||||
data_path = '/usr/local/share/key-mapper'
|
||||
elif source_path.startswith('/usr/'):
|
||||
data_path = '/usr/share/key-mapper'
|
||||
else:
|
||||
# installed with -e, running from the cloned git source
|
||||
|
||||
candidates = [
|
||||
os.path.join(site.USER_BASE, 'share/key-mapper'),
|
||||
'/usr/local/share/key-mapper',
|
||||
'/usr/share/key-mapper'
|
||||
]
|
||||
|
||||
print('source_path', source_path)
|
||||
if '/site-packages' not in source_path:
|
||||
# probably installed with -e, running from the cloned git source
|
||||
data_path = os.path.join(source_path, 'data')
|
||||
else:
|
||||
# try any of the options
|
||||
for candidate in candidates:
|
||||
if os.path.exists(candidate):
|
||||
data_path = candidate
|
||||
break
|
||||
logger.error('Could not find the application data')
|
||||
|
||||
return os.path.join(data_path, filename)
|
||||
|
1
setup.py
1
setup.py
@ -39,6 +39,7 @@ setup(
|
||||
('/usr/share/key-mapper/', glob.glob('data/*')),
|
||||
('/usr/share/applications/', ['data/key-mapper.desktop']),
|
||||
('/etc/xdg/autostart/', ['data/key-mapper-service.desktop']),
|
||||
# manjaro installs the executables with pip, ubuntu doesn't.
|
||||
('/usr/bin/', ['bin/key-mapper-gtk']),
|
||||
('/usr/bin/', ['bin/key-mapper-service']),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user