Skip to content

Commit

Permalink
setup.py: Install desktop file and icon on GNU/Linux/FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
kernc committed Apr 22, 2016
1 parent 226a1a4 commit 6afe458
Show file tree
Hide file tree
Showing 4 changed files with 257 additions and 6 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions distribute/orange-canvas.desktop
Original file line number Diff line number Diff line change
@@ -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;
216 changes: 216 additions & 0 deletions distribute/orange-canvas.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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={
Expand Down

0 comments on commit 6afe458

Please sign in to comment.