V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
0clickjacking0
V2EX  ›  Python

请问 python3.7 的一个项目在 macos 上如何打包才可以让 windows 的用户也能使用

  •  
  •   0clickjacking0 · 2019-10-21 20:01:03 +08:00 · 4221 次点击
    这是一个创建于 1620 天前的主题,其中的信息可能已经有所发展或是发生改变。

    楼主是 macos 的系统,用了 pyinstaller 在 mac 上打包一个比较简单的 python3.7 的项目,不含 gui,打包出来的程序是Mach-O 64-bit executable x86_64,windows 的用户并不能使用,请问如何打包才可以让 windows 的用户也能体验呢,最差的情况就只能在我 windows 的虚拟机上打包了,各位大佬有什么办法吗

    17 条回复    2019-10-22 15:05:27 +08:00
    lbp0200
        1
    lbp0200  
       2019-10-21 20:05:46 +08:00 via iPhone
    让我想起了 goagent
    111111111111
        2
    111111111111  
       2019-10-21 20:08:37 +08:00 via Android
    如果打包出来的是二进制文件想要跨平台的话,就很为难了…
    cyyzero
        3
    cyyzero  
       2019-10-21 20:12:00 +08:00 via Android   ❤️ 1
    docker
    VDimos
        4
    VDimos  
       2019-10-21 20:13:20 +08:00 via Android
    用 ci 呗,有支持 windows 的 ci 吧
    tomczhen
        5
    tomczhen  
       2019-10-21 20:17:31 +08:00 via Android
    文档里面说得很清楚了,得在 Windows 上打包。
    fannas
        6
    fannas  
       2019-10-21 20:27:36 +08:00 via Android
    docker
    ClericPy
        7
    ClericPy  
       2019-10-21 20:54:37 +08:00
    如果真那么刚需, 用嵌入式的绿色版 Python 解释器加 shiv 来打包吧, 我打过这种倒是

    https://github.com/ClericPy/distribute-python-on-windows

    以前随手撸的, 不知道还能跑不能... 说白了就是解释器指望绿色版 Python, package 指望 shiv 使用 PEP 441 协议打包成一个 pyz 文件, 就酱
    hushao
        8
    hushao  
       2019-10-21 22:26:51 +08:00
    源码无关的话,直接给源码跑起来不好么,要是源码不能给的话,你折腾来折腾去还不如找一台 win 机临时打包一下,或者就用你那虚拟机,,,
    chih758
        9
    chih758  
       2019-10-21 22:37:07 +08:00
    用 go 重构
    chih758
        10
    chih758  
       2019-10-21 22:40:03 +08:00
    一次获取 linux-amd64 linux-386 darwin-amd64 darwin-386 windows-amd64 windows-386 freebsd-amd64 freebsd-386 linux-arm linux-arm64 架构的二进制文件
    ebingtel
        11
    ebingtel  
       2019-10-22 08:36:47 +08:00
    在 windows 的 docker 镜像里面打包呗……
    hkitdog
        12
    hkitdog  
       2019-10-22 09:53:21 +08:00 via iPhone
    @ebingtel Windows 的 docker images (windows server core)不是只能在 windows 的主機運行嗎
    laike9m
        13
    laike9m  
       2019-10-22 13:22:13 +08:00
    @ClericPy 唯一一个靠谱的答案,其它都是强答。
    laike9m
        14
    laike9m  
       2019-10-22 13:23:24 +08:00
    补充一个 shiv 的链接
    https://github.com/linkedin/shiv
    ClericPy
        15
    ClericPy  
       2019-10-22 13:28:25 +08:00
    @laike9m 哈哈, V 站划水比例 1:9
    另外, shiv 没试过打包 C lib 会不会跪, 理论上应该会凉
    wozhizui
        16
    wozhizui  
       2019-10-22 14:32:22 +08:00
    pyinstaller 就是这样,在哪个环境打包,就只能在哪个环境运行。
    我当时 win 的 x64 打包,x86 都不能用,最后用了个什么命令强制设置 python 环境为 32 位,然后打包后,还找了个 32 位机器测试。麻烦的很。
    laike9m
        17
    laike9m  
       2019-10-22 15:05:27 +08:00
    @ClericPy 这种坑都不会少,只能慢慢踩,看人品
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1583 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:58 · PVG 00:58 · LAX 09:58 · JFK 12:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.