2019-08-06 16:30:04 +03:00
|
|
|
import sys
|
2020-02-22 14:26:59 +03:00
|
|
|
import os
|
2020-02-22 16:49:43 +03:00
|
|
|
import os.path as osp
|
|
|
|
import platform
|
|
|
|
import tempfile
|
2018-11-26 20:41:23 +03:00
|
|
|
from setuptools import setup, find_packages
|
2020-02-14 02:34:09 +03:00
|
|
|
from maestral import __version__, __author__, __url__
|
2018-12-03 04:42:57 +03:00
|
|
|
|
2019-08-06 16:30:04 +03:00
|
|
|
|
2020-02-22 14:26:59 +03:00
|
|
|
# check for running daemons before updating to prevent
|
|
|
|
# incompatible versions of CLI / GUI and daemon
|
|
|
|
|
2020-02-22 16:49:43 +03:00
|
|
|
def get_home_dir():
|
|
|
|
try:
|
|
|
|
path = osp.expanduser('~')
|
|
|
|
except Exception:
|
|
|
|
path = ''
|
|
|
|
|
|
|
|
if osp.isdir(path):
|
|
|
|
return path
|
|
|
|
else:
|
|
|
|
for env_var in ('HOME', 'USERPROFILE', 'TMP'):
|
|
|
|
path = os.environ.get(env_var, '')
|
|
|
|
if osp.isdir(path):
|
|
|
|
return path
|
|
|
|
else:
|
|
|
|
path = ''
|
|
|
|
|
|
|
|
if not path:
|
|
|
|
raise RuntimeError('Please set the environment variable HOME to '
|
|
|
|
'your user/home directory.')
|
|
|
|
|
|
|
|
|
|
|
|
_home_dir = get_home_dir()
|
|
|
|
|
|
|
|
|
|
|
|
def _to_full_path(path, subfolder, filename, create):
|
|
|
|
|
|
|
|
if subfolder:
|
|
|
|
path = osp.join(path, subfolder)
|
|
|
|
|
|
|
|
if create:
|
|
|
|
os.makedirs(path, exist_ok=True)
|
|
|
|
|
|
|
|
if filename:
|
|
|
|
path = osp.join(path, filename)
|
|
|
|
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
|
|
def get_conf_path(subfolder=None, filename=None, create=True):
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
conf_path = osp.join(get_home_dir(), 'Library', 'Application Support')
|
|
|
|
else:
|
|
|
|
fallback = osp.join(get_home_dir(), '.config')
|
|
|
|
conf_path = os.environ.get('XDG_CONFIG_HOME', fallback)
|
|
|
|
|
|
|
|
return _to_full_path(conf_path, subfolder, filename, create)
|
|
|
|
|
|
|
|
|
|
|
|
def get_runtime_path(subfolder=None, filename=None, create=True):
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
runtime_path = get_conf_path(create=False)
|
|
|
|
else:
|
|
|
|
fallback = os.environ.get('XDG_CACHE_HOME', osp.join(_home_dir, '.cache'))
|
|
|
|
runtime_path = os.environ.get('XDG_RUNTIME_DIR', fallback)
|
|
|
|
|
|
|
|
return _to_full_path(runtime_path, subfolder, filename, create)
|
|
|
|
|
|
|
|
|
|
|
|
def get_old_runtime_path(subfolder=None, filename=None, create=True):
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
runtime_path = tempfile.gettempdir()
|
|
|
|
else:
|
|
|
|
fallback = os.environ.get('XDG_CACHE_HOME', osp.join(_home_dir, '.cache'))
|
|
|
|
runtime_path = os.environ.get('XDG_RUNTIME_DIR', fallback)
|
|
|
|
|
|
|
|
return _to_full_path(runtime_path, subfolder, filename, create)
|
|
|
|
|
|
|
|
|
|
|
|
def list_configs():
|
|
|
|
configs = []
|
|
|
|
for file in os.listdir(get_conf_path('maestral')):
|
|
|
|
if file.endswith('.ini'):
|
|
|
|
configs.append(os.path.splitext(os.path.basename(file))[0])
|
|
|
|
|
|
|
|
return configs
|
|
|
|
|
|
|
|
|
2020-02-22 14:26:59 +03:00
|
|
|
running_daemons = []
|
|
|
|
|
|
|
|
for config in list_configs():
|
2020-02-22 16:49:43 +03:00
|
|
|
pid_file = get_runtime_path('maestral', config + '.pid')
|
|
|
|
old_pid_file = get_old_runtime_path('maestral', config + '.pid')
|
|
|
|
if osp.exists(pid_file) or osp.exists(old_pid_file):
|
2020-02-22 14:26:59 +03:00
|
|
|
running_daemons.append(config)
|
|
|
|
|
|
|
|
if running_daemons:
|
|
|
|
sys.stderr.write(f"""
|
|
|
|
Maestral daemons with the following configs are running:
|
|
|
|
|
|
|
|
{', '.join(running_daemons)}
|
|
|
|
|
2020-02-22 15:37:34 +03:00
|
|
|
Please stop the daemons before updating to ensure a clean upgrade
|
|
|
|
of config files and compatibility been the CLI and daemon.
|
2020-02-22 14:26:59 +03:00
|
|
|
""")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
2020-02-22 16:49:43 +03:00
|
|
|
# proceed with actual install
|
|
|
|
|
2018-12-03 04:42:57 +03:00
|
|
|
setup(
|
2020-01-29 22:26:57 +03:00
|
|
|
name='maestral',
|
2019-08-20 14:23:14 +03:00
|
|
|
version=__version__,
|
2020-01-29 22:26:57 +03:00
|
|
|
description='Open-source Dropbox client for macOS and Linux.',
|
2020-02-14 02:34:09 +03:00
|
|
|
url=__url__,
|
2020-01-29 22:26:57 +03:00
|
|
|
author='Sam Schott',
|
2020-02-14 02:34:09 +03:00
|
|
|
author_email=__author__,
|
2020-01-29 22:26:57 +03:00
|
|
|
license='MIT',
|
|
|
|
long_description=open('README.md').read(),
|
2019-07-16 15:50:24 +03:00
|
|
|
long_description_content_type='text/markdown',
|
2018-12-03 04:42:57 +03:00
|
|
|
packages=find_packages(),
|
|
|
|
package_data={
|
2020-02-08 01:42:19 +03:00
|
|
|
'maestral': [
|
2020-02-17 20:16:13 +03:00
|
|
|
'resources/*',
|
2020-02-21 03:01:58 +03:00
|
|
|
],
|
|
|
|
},
|
2020-01-29 22:26:57 +03:00
|
|
|
setup_requires=['wheel'],
|
2018-12-03 04:42:57 +03:00
|
|
|
install_requires=[
|
2020-02-11 00:04:27 +03:00
|
|
|
'atomicwrites',
|
2020-01-29 22:26:57 +03:00
|
|
|
'bugsnag',
|
|
|
|
'click>=7.0',
|
|
|
|
'dropbox>=9.4.0',
|
2020-02-18 21:55:55 +03:00
|
|
|
'importlib_metadata;python_version<"3.8"',
|
2020-01-29 22:26:57 +03:00
|
|
|
'keyring>=19.0.0',
|
|
|
|
'keyrings.alt>=3.0.0',
|
|
|
|
'lockfile',
|
|
|
|
'Pyro5>=5.7',
|
|
|
|
'requests',
|
|
|
|
'rubicon-objc>=0.3.1;sys_platform=="darwin"',
|
2020-02-17 20:17:02 +03:00
|
|
|
'sdnotify',
|
2020-01-29 22:26:57 +03:00
|
|
|
'u-msgpack-python',
|
|
|
|
'watchdog>=0.9.0',
|
2019-08-14 20:42:11 +03:00
|
|
|
],
|
2019-09-15 14:43:12 +03:00
|
|
|
extras_require={
|
2020-02-17 20:17:02 +03:00
|
|
|
'syslog': [
|
2020-02-01 18:03:04 +03:00
|
|
|
'systemd-python',
|
|
|
|
],
|
|
|
|
'gui': [
|
2020-02-11 00:57:18 +03:00
|
|
|
'maestral-cocoa==0.1.1-dev1;sys_platform=="darwin"',
|
|
|
|
'maestral-qt==0.6.1-dev1;sys_platform=="linux"'
|
2020-02-01 18:03:04 +03:00
|
|
|
],
|
2019-09-15 14:43:12 +03:00
|
|
|
},
|
2018-12-03 04:42:57 +03:00
|
|
|
zip_safe=False,
|
|
|
|
entry_points={
|
2020-02-21 03:01:58 +03:00
|
|
|
'console_scripts': ['maestral=maestral.cli:main'],
|
2019-08-14 20:42:11 +03:00
|
|
|
},
|
2019-02-26 14:46:00 +03:00
|
|
|
python_requires='>=3.6',
|
2019-08-06 16:25:54 +03:00
|
|
|
classifiers=[
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Operating System :: Unix',
|
|
|
|
'Programming Language :: Python',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Programming Language :: Python :: 3.6',
|
|
|
|
'Programming Language :: Python :: 3.7',
|
2019-10-23 23:20:14 +03:00
|
|
|
'Programming Language :: Python :: 3.8',
|
2019-08-06 16:25:54 +03:00
|
|
|
'Programming Language :: Python :: 3 :: Only',
|
|
|
|
],
|
2020-02-17 20:16:13 +03:00
|
|
|
data_files=[
|
2020-02-17 20:17:13 +03:00
|
|
|
('share/icons/hicolor/512x512/apps', ['maestral/resources/maestral.png'])
|
2020-02-17 20:16:13 +03:00
|
|
|
],
|
2019-08-14 20:42:11 +03:00
|
|
|
)
|