推荐学习书目
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
peanuts7660
V2EX  ›  Python

有什么方法能批量将 py 文件 生成 pyd 文件吗?

  •  
  •   peanuts7660 · Jul 24, 2019 · 3998 views
  •   The specified image does not exist
    This topic created in 2524 days ago, the information mentioned may be changed or developed.

    目录结构如下

    │  main.py
    │
    └─src
        ├─pack1
        │  ├─module1
        │  │      mod1.py
        │  │      __init__.py
        │  │
        │  └─module2
        │          mod2.py
        │          __init__.py
        │
        └─pack2
            ├─module3
            │      3.py
            │      __init__.py
            │
            └─module4
                    4.py
                    __init__.py
    

    入口文件为 main.py

    src 目录下存在着各个模块。

    现在想批量将 src 目录中的 py 文件转为 pyd 文件,请问下有什么方法吗?

    网上搜索的都是将一个文件转为 pyd,求大家指导。

    6 replies    2019-07-25 22:49:34 +08:00
    Osk
        1
    Osk  
       Jul 24, 2019
    pyd?

    但看 lz 的描述是生成 pyc 啊?
    python -m compileall -f -b dir
    edsion996
        2
    edsion996  
       Jul 24, 2019
    网上搜索的都是将一个文件转为 pyd

    写个脚本,遍历一下所有文件,按照你说的单个文件转 pyd 的方式转一遍啊。
    limuyan44
        3
    limuyan44  
       Jul 24, 2019 via Android
    你写 py 的还想不到怎么批量处理任务吗。。
    txfly
        4
    txfly  
       Jul 24, 2019 via iPhone
    除了 main.py ,其它部分可以用 cython 生成 pyd。
    gotham
        5
    gotham  
       Jul 25, 2019 via Android
    pyd 是 python 的 c 语言 so 文件或者 dll,py 生成的是 pyc
    1462326016
        6
    1462326016  
       Jul 25, 2019
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5546 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 95ms · UTC 08:31 · PVG 16:31 · LAX 01:31 · JFK 04:31
    ♥ Do have faith in what you're doing.