Python模块分发将可执行文件安装到路径

2024-03-29 04:57:16 发布

您现在位置:Python中文网/ 问答频道 /正文

在过去,我在PyPI上看到Python模块发行版,当您使用pip安装它们时,它会将一个可执行文件安装到路径中,不幸的是,我再也找不到这样的版本了。你知道吗

我想知道这怎么可能。你会在你的setup.py里这样做吗?你能让它在多个平台上工作吗?你知道吗

一个链接到一个模块这样做也会很有帮助。你知道吗

我说的不是将python模块安装到python路径,而是将可执行文件安装到系统路径!


Tags: 模块pippy路径版本pypi可执行文件链接
1条回答
网友
1楼 · 发布于 2024-03-29 04:57:16

看看http://python-packaging.readthedocs.org/en/latest/command-line-scripts.html

The scripts Keyword Argument

The first approach is to write your script in a separate file, such as you might write a shell script.:

funniest/
     funniest/
         __init__.py
         ...
     setup.py
     bin/
         funniest-joke

... The funniest-joke script just looks like this:

#!/usr/bin/env python

import funniest print funniest.joke()

Then we can declare the script in setup() like this:

setup(
    ...
    scripts=['bin/funniest-joke'],
    ... ) 

When we install the package, setuptools will copy the script to our PATH and make it available for general use.

相关问题 更多 >