• python跨版本包管理方案(pyenv + pipenv)


    背景

    通过对pyenv的探索,已经掌握pyenv对python多版本的管理方法。

    同时pyenv可以集成virtualenv,实现多项目需求的独立环境的搭建,

    from(https://github.com/pyenv/pyenv-virtualenv)

    问题是,对于项目的管理, 我们缺少一个依赖的配置清单,类似 node的 package.json

    这个可以通过pip freeze来生成requirement.txt文件解决。

    但是这个方法,具有一些问题,每次pip install后,需要主动调用pip freeze来更新配置清单。

    针对这个问题,

    于是pipenv闪亮出场

    https://pipenv.pypa.io/en/latest/

    针对新的安装包, 只需要 pipenv install xxx, 就可以将新的文件更新到 pipfile中。

    体验跟node的npm类似。

    于是针对包管理的角度, 我们引入新的python跨版本包管理方案

    pyenv + pipenv

    pyenv -- 跨python版本的os环境管理。

    pipenv -- 跨多个项目的运行环境管理。

    pyenv

    https://github.com/pyenv/pyenv

    pyenv does...

    • Let you change the global Python version on a per-user basis.
    • Provide support for per-project Python versions.
    • Allow you to override the Python version with an environment variable.
    • Search commands from multiple versions of Python at a time. This may be helpful to test across Python versions with tox.

    pipenv

    https://pipenv.pypa.io/en/latest/

    The problems that Pipenv seeks to solve are multi-faceted:

    • You no longer need to use pip and virtualenv separately. They work together.
    • Managing a requirements.txt file can be problematic, so Pipenv uses Pipfile and Pipfile.lock to separate abstract dependency declarations from the last tested combination.
    • Hashes are used everywhere, always. Security. Automatically expose security vulnerabilities.
    • Strongly encourage the use of the latest versions of dependencies to minimize security risks arising from outdated components.
    • Give you insight into your dependency graph (e.g. $ pipenv graph).
    • Streamline development workflow by loading .env files.
  • 相关阅读:
    MYSQL把一张表的数据批量复制到另外一张表
    06:rpm 和 yum 执行卡住,解决方法
    su: cannot set user id: Resource temporarily unavailable 解决方法
    queue队列
    threading 两种调用方法
    paramiko 模块 linux
    socketserver 模块实现ftp功能
    socket实现简单的文件下载传输功能
    mysql使用update代替delete做伪删除
    mysql客户端命令mysqladmin介绍
  • 原文地址:https://www.cnblogs.com/lightsong/p/13754004.html
Copyright © 2020-2023  润新知