setup.py and adding file to /bin/

后端 未结 4 1503
你的背包
你的背包 2020-12-07 15:42

I can\'t figure out how to make setup.py add a scrip to the the user\'s /bin or /usr/bin or whatever.

E.g., I\'d like to add a

4条回答
  •  -上瘾入骨i
    2020-12-07 15:58

    If you're willing to build and install the entire python package, this is how I would go about it:

    • Edit the setup() function in setup.py to contain a parameter named scripts and set its argument as the location of the file(s) you wish to run from anywhere. e.g.

    setup(name='myproject',author='',author_email='',scripts=['bin/myscript.py'])

    • Within the directory that contains setup.py, create a bin directory by typing mkdir bin
    • Add myscript.py to this newly-created bin directory (and make sure it's executable!)
    • cd into the directory that contains setup.py again, and install the entire python package by typing python setup.py install
    • Once the package is installed, you should be able to run myscript.py from anywhere on the system!

提交回复
热议问题