Skip to content Skip to sidebar Skip to footer

Setup.py - Symlink A Module To /usr/bin After Installation

I've almost finished developing a python package and have also written a basic setup.py using distutils: #!/usr/bin/env python #@author: Prahlad Yeri #@description: Small daemon to

Solution 1:

Just use the scripts parameter like this:

#!/usr/bin/env python#@author: Prahlad Yeri#@description: Small daemon to create a wifi hotspot on linux#@license: MITimport cli

#INSTALL ITfrom distutils.core import setup
setup(name='hotspotd',
    version='0.1',
    description='Small daemon to create a wifi hotspot on linux',
    license='MIT',
    author='Prahlad Yeri',
    author_email='prahladyeri@yahoo.com',
    url='https://github.com/prahladyeri/hotspotd',
    package_dir={'hotspotd': ''},
    packages=['hotspotd'],
    data_files=[('config',['run.dat'])],
    scripts=["scriptname"], # Here the Magic Happens
    )

#CONFIGURE IT

Now the file scriptname will be copied to /usr/bin/scriptname the shebang will be replaced by the python version calling the setup.py Script. So write your script wisely.

Solution 2:

Nowadays you should use console_scripts to make your script end up in /usr/bin. The format is:

from setuptools import setup

setup(
    ...
    console_scripts=[
        'hotspotd = hotspotd:my_main_func',
    ],
    ...
)

Solution 3:

Entry points may now be specified in setuptools:

setup(
# other arguments here...
entry_points={
    'console_scripts': [
        'foo = my_package.some_module:main_func',
        'bar = other_module:some_func',
    ],
    'gui_scripts': [
        'baz = my_package_gui:start_func',
    ]
}

)

Post a Comment for "Setup.py - Symlink A Module To /usr/bin After Installation"