From 6afe45865fedaeb2e37dad5beaba3c817f8dfaef Mon Sep 17 00:00:00 2001 From: Kernc Date: Fri, 22 Apr 2016 11:41:47 +0200 Subject: [PATCH] setup.py: Install desktop file and icon on GNU/Linux/FreeBSD --- MANIFEST.in | 2 + distribute/orange-canvas.desktop | 12 +- distribute/orange-canvas.svg | 216 +++++++++++++++++++++++++++++++ setup.py | 33 +++++ 4 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 distribute/orange-canvas.svg diff --git a/MANIFEST.in b/MANIFEST.in index f71bc1ed02a..ab791a0e99e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -10,6 +10,8 @@ recursive-include Orange/canvas/application/tutorials *.ows recursive-include Orange/widgets *.png *.svg recursive-include Orange/widgets/utils/plot *.fs *.vs *.gs *.obj +recursive-include distribute *.svg *.desktop + include requirements*.txt include README.md diff --git a/distribute/orange-canvas.desktop b/distribute/orange-canvas.desktop index 4a381119ba3..d31c9910e43 100644 --- a/distribute/orange-canvas.desktop +++ b/distribute/orange-canvas.desktop @@ -1,11 +1,11 @@ [Desktop Entry] -Version=1.0 -Name=Orange Canvas +Type=Application +Name=Orange Data Mining GenericName=Data Mining Suite -Comment=Explore and analyze your data +Comment=Explore, analyze, and visualize your data Exec=orange-canvas Icon=orange-canvas Terminal=false -Type=Application -Categories=Education;Science;ArtificialIntelligence;DataVisualization;Qt; -X-GNOME-FullName=Orange Canvas Data Mining Suite +MimeType=application/x-extension-ows; +Categories=Science;Education;ArtificialIntelligence;DataVisualization;NumericalAnalysis;Qt; +Keywords=Machine Learning;Scientific Visualization;Statistical Analysis; diff --git a/distribute/orange-canvas.svg b/distribute/orange-canvas.svg new file mode 100644 index 00000000000..83041d731ce --- /dev/null +++ b/distribute/orange-canvas.svg @@ -0,0 +1,216 @@ + +image/svg+xml \ No newline at end of file diff --git a/setup.py b/setup.py index 54fe2cf2d7d..c02e52dfdc8 100755 --- a/setup.py +++ b/setup.py @@ -216,6 +216,38 @@ def run(self): ''', shell=True, cwd=os.path.dirname(os.path.abspath(__file__)))) +# Install desktop file and icon on GNU/Linux/BSD +DATA_FILES = [] +if any(sys.platform.startswith(platform) + for platform in ('linux', 'freebsd')): + # Patch desktop file executable to work with virtualenv + try: + sys.real_prefix + except AttributeError: + pass # Not in virtualenv + else: + with open(os.path.join(os.path.dirname(__file__), + 'distribute', + 'orange-canvas.desktop'), 'r+') as desktop: + spec = [] + for line in desktop: + if line.startswith('Exec='): + line = 'Exec="{}" -m Orange.canvas\n'.format(sys.executable) + spec.append(line) + desktop.seek(0) + desktop.truncate(0) + desktop.writelines(spec) + + usr_share = os.path.join(sys.prefix, "share") + if not usr_share.startswith('/usr/') or not os.access(usr_share, os.W_OK): + usr_share = os.environ.get('XDG_DATA_HOME', + os.path.expanduser('~/.local/share')) + DATA_FILES += [ + (os.path.join(usr_share, 'applications'), + ['distribute/orange-canvas.desktop']), + (os.path.join(usr_share, 'icons', 'hicolor', 'scalable', 'apps'), + ['distribute/orange-canvas.svg']) + ] def setup_package(): @@ -235,6 +267,7 @@ def setup_package(): package_data=PACKAGE_DATA, install_requires=INSTALL_REQUIRES, entry_points=ENTRY_POINTS, + data_files=DATA_FILES, zip_safe=False, test_suite='Orange.tests.test_suite', cmdclass={