V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
eightqueen
V2EX  ›  Python

python 如何根据环境打包?

  •  
  •   eightqueen · Oct 15, 2015 · 4593 views
    This topic created in 3857 days ago, the information mentioned may be changed or developed.
    java 的 maven 很容易做这个事情,写好配置文件,打包的时候指定环境名称(测试、开发、线上)就可以了。
    6 replies    2017-04-10 15:49:34 +08:00
    hahasong
        1
    hahasong  
       Oct 15, 2015
    venv freez 一个 requirents 清单
    kamushin
        2
    kamushin  
       Oct 15, 2015
    用 pip wheel+requirements. 线上一般不能访问 pip 仓库的时候, wheel 就有用了
    curiouslfq
        3
    curiouslfq  
       Oct 15, 2015
    tox
    tinyproxy
        4
    tinyproxy  
       Oct 15, 2015 via iPhone
    docker
    owendev
        5
    owendev  
       Oct 16, 2015
    可以使用这两条命令:
    pip freeze > requirements.txt ## 到处依赖到文件
    pip install -r requirements.txt ## 读取依赖文件,安装依赖
    JhOOOn
        6
    JhOOOn  
       Apr 10, 2017
    有时候, 需要部署 Python 应用的服务器没有网络连接, 这时候, 你就要把整个 Python 应用做成离线安装包.
    借助 wheel, 很容易就可以实现.

    首先, 你的开发机器上要安装 wheel:

    pip install wheel
    接下来, 下载依赖包的 wheel 文件:

    pip wheel -r requirements.txt
    默认情况下, 上述命令会下载 requirements.txt 中每个包的 wheel 包到当前目录的 wheelhouse 文件夹, 包括依赖的依赖.
    现在你可以把这个 wheelhouse 文件夹打包到你的安装包中. 在你的安装脚本中执行:

    pip install --use-wheel --no-index --find-links=wheelhouse -r requirements.txt
    就可以实现离线安装了. 当然, 还要考虑 pip 以及 wheel 自身的安装.

    参考: http://guoqiao.me/post/2015/1212-pip-install-offline-via-wheels
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3803 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 04:53 · PVG 12:53 · LAX 21:53 · JFK 00:53
    ♥ Do have faith in what you're doing.