推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
MiketsuSmasher
V2EX  ›  Python

Python 项目怎么打包,可以在安装时根据操作系统生成对应的可执行脚本/文件?

  •  
  •   MiketsuSmasher · Dec 3, 2021 · 2740 views
    This topic created in 1761 days ago, the information mentioned may be changed or developed.

    项目目录下面有一个包,这个包可以用 python -m 运行。

    现在希望在其它系统上安装这个包的时候,如果是 Windows 就生成 exe 文件,其它系统就生成一个可执行的脚本文件,而且放在系统的 PATH 下面,从命令行直接敲脚本名就能运行这个包。

    做到这一点,需要怎么打包?或者其它一些额外工作?

    5 replies  •  2022-02-01 13:19:11 +08:00
    Trim21
        2
    Trim21  
       Dec 3, 2021 via Android
    你想打成什么包? pip 包只要写好 entry_points 在安装的时候本来就能自动生成对应的可执行文件
    ClericPy
        3
    ClericPy  
       Dec 4, 2021
    如果是 Windows 就生成 exe 文件... 你这似乎在说那些安装后在 Scripts 里面带上可执行文件的包吧, 类似 pip, pipx, shiv 这些. 人家都提前编译好了让你下的, 不是现场编译...
    fkue587
        4
    fkue587  
       Dec 5, 2021 via Android
    直接.bat
    learningman
        5
    learningman  
       Feb 1, 2022
    setup.py 里面配置一下 entry_points 就好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   899 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 21:39 · PVG 05:39 · LAX 14:39 · JFK 17:39
    ♥ Do have faith in what you're doing.