How to distribute `.desktop` files and icons for a Python package in Gnome (with distutils or setuptools)?

前端 未结 4 1482
灰色年华
灰色年华 2020-12-16 02:33

Currently I\'m using the auto-tools to build/install and package a project of mine, but I would really like to move to something that feels more \"pythonic\".

My pro

4条回答
  •  佛祖请我去吃肉
    2020-12-16 03:26

    I managed to get this to work, but it kinda feels to me more like a workaround.

    Don't know what's the preferred way to handle this...

    I used the following setup.py file (full version is here):

    from setuptools import setup
    
    setup(
      # ...
      data_files=[
        ('share/icons/hicolor/scalable/apps', ['data/mypackage.svg']),
        ('share/applications', ['data/mypackage.desktop'])
      ],
      entry_points={
        'console_scripts': ['startit=mypackage.cli:run']
      }
    )
    

    The starter script trough entry_points works. But the data_files where put in an egg file and not in the folders specified, so they can't be accessed by the desktop shell.

    To work around this, I used the following setup.cfg file:

    [install]
    single-version-externally-managed=1
    record=install.txt
    

    This works. Both data files are created in the right place and the .desktop file is recognized by Gnome.

提交回复
热议问题