跳转到主要内容

一个用于在虚拟环境边界安装包的项目。

项目描述

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

摘要

莫克 是一个用于在虚拟环境中安装和查询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'

🐉 在虚拟环境中运行命令

>>> 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

阅读文档.

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

mork-0.1.4.tar.gz (14.8 kB 查看哈希值)

上传时间

构建分布

mork-0.1.4-py2.py3-none-any.whl (8.4 kB 查看哈希值)

上传时间 Python 2 Python 3

支持