跨virtualenv边界安装包的项目。

mork的Python项目详细描述


https://img.shields.io/pypi/v/mork.svghttps://img.shields.io/pypi/l/mork.svghttps://api.travis-ci.com/sarugaku/mork.svg?branch=masterhttps://ci.appveyor.com/api/projects/status/5mo40rneihk6y8po/branch/master?svg=truehttps://img.shields.io/pypi/pyversions/mork.svghttps://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svgDocumentation Status

摘要

Mork是一个用于在虚拟机中安装和查询python包的库 环境。

查看安装了什么

>>> import mork
>>> venv = mork.VirtualEnv.from_project_path('/home/user/git/pipenv')
>>> dists = venv.get_distributions()
>>> [dist for dist in dists][:3]
[wheel 0.31.1 (/home/user/.virtualenvs/pipenv-MfOPs1lW/lib/python3.7/site-packages), Werkzeug 0.14.1 (/home/user/.virtualenvs/pipenv-MfOPs1lW/lib/python3.7/site-packages), vistir 0.1.4 (/home/user/.virtualenvs/pipenv-MfOPs1lW/lib/python3.7/site-packages)]

安装一个包

>>> from requirementslib.models.requirements import Requirement
>>> r = Requirement.from_line("requests")
>>> venv.install(r, editable=False)

卸载软件包

>>> pkg = "pytz"
>>> with venv.uninstall(pkg, auto_confirm=True) as uninstall:
        if uninstall.paths:
            cleaned = pkg
>>> print("Removed package: %s" % cleaned)

显示有关python的信息

>>> venv.python
'/home/user/.virtualenvs/pipenv-MfOPs1lW/bin/python'
>>> venv.python_version
'3.7'

在virtualenv内部运行命令

>>> cmd = venv.run("env")
>>> [line for line in cmd.out.splitlines() if line.startswith("VIRTUAL_ENV")]
['VIRTUAL_ENV=/user/hawk/.virtualenvs/pipenv-MfOPs1lW']
>>> cmd = venv.run_py(["import os; print(os.environ.get('VIRTUAL_ENV'))"])
Deactivating virtualenv...
>>> cmd.out
'/home/user/.virtualenvs/pipenv-MfOPs1lW\n'
>>> with venv.activated():
        print(os.environ["VIRTUAL_ENV"])
/home/hawk/.virtualenvs/pipenv-MfOPs1lW

Read the documentation

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在Eclipse中使用多个调用在一行上打印java   javajackson序列化问题。只有同一实体的第一个对象可以很好地序列化   Java中Deflate函数的等价充气   使用customlitview的java Android actionbar搜索   java“<T>T get()”是什么意思?(它有用吗?)   目标c使用CommonCrypto使用AES256加密,使用OpenSSL或Java解密   java在运行时更新资源文件   fileinputstream在java中访问并将数据写入现有文件   带集群的java Android Mapbox我希望每个功能都有不同的标记图像   java JDK8>JDK10:PKIX路径生成失败:SunCertPathBuilderException:找不到请求目标的有效证书路径   java使用Hk2生成具有指定构造函数参数的实例   为什么这个系统。出来Java中的println()打印到控制台?   java目录和文件名连接不起作用   使用mockito和通配符绘图的java