fastpip


Namefastpip JSON
Version 1.7.0 PyPI version JSON
download
home_pagehttps://github.com/hrpzcf/fastpip
Summary一个 pip 命令包,帮助你实现使用 Python 编程的方式进行包管理操作。
upload_time2023-03-13 03:36:52
maintainer
docs_urlNone
authorhrpzcf
requires_python>=3.7
licenseMIT License
keywords pip package
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fastpip

## 简介

------

一个 pip 命令包,帮助你实现使用 Python 编程的方式进行包管理操作。

<br />

## 如何安装

------

`注:fastpip 仅支持 Windows 系统。`

<br />

> 打开命令窗口或 PowerShell 窗口,使用 pip 命令安装:

```cmd
pip install -U fastpip
```

<br /><br />

## 如何使用

------

示例1:使用 fastpip 升级 Python 环境中的包

```python
import sys

# 导入 PyEnv 类
from fastpip import PyEnv

# 创建 PyEnv 实例:PyEnv(_path)
# 参数 _path 是一个路径,指向 Python 解释器(python.exe)所在目录
# 例如 env = PyEnv(r'C:\Anaconda3\envs\py35')

# 不带参数或者 PyEnv(None) 则使用系统环境变量 PATH 中第一个 Py 环境路径
env = PyEnv()

# 调用 PyEnv 类实例的 outdated 方法获取可更新的包列表
# 参数 output 控制是否在终端显示 pip 命令输出
# 如果在 GUI 程序中使用 fastpip 请将这个参数设置为 False(默认)
# outdated 返回值结构:
# [
# (包名, 已安装版本, 最新版本, 安装包类型),
# ...
# ]
outdated_pkgs = env.outdated(output=1)

# 询问是否安装所有可更新的包,回答非 y 则退出
if input('\n确认更新?y/[n]:').lower() != 'y':
    sys.exit(0)

for name, *_ in outdated_pkgs:
    # 调用目标环境的 PyEnv 实例的 install 方法进行安装。
    # upgrade 参数为 True:
    # 以升级模式安装,如果目标环境已安装该包且该包有新版本,则安装新版本,否则跳过。
    # upgrade 参数为 False:
    # 如果目标环境已安装,不管该包有没有新版本都不会重新安装,直接跳过。
    env.install(name, upgrade=1, output=1)

print('全部更新完成!')

```

示例2:
```python
from fastpip import PyEnv, all_py_paths, cur_py_path, index_urls

# 打印预置的几个国内 PyPi 镜像地址:
print(index_urls)
# {'aliyun': 'https://mirrors.aliyun.com/pypi/simple/',
# 'tencent': 'https://mirrors.cloud.tencent.com/pypi/simple',
# 'douban': 'https://pypi.doubanio.com/simple/',
# 'huawei': 'https://mirrors.huaweicloud.com/repository/pypi/simple',
# 'opentuna': 'https://opentuna.cn/pypi/web/simple',
# 'tsinghua': 'https://pypi.tuna.tsinghua.edu.cn/simple',
# 'netease': 'https://mirrors.163.com/pypi/simple/'}

# 当前系统环境变量 PATH 中第一个 Python 环境路径:
print(cur_py_path())
# C:\Python37\ (具体与个人系统环境变量 PATH 设置有关)

# 在常用安装位置查找 Python 目录:
print(all_py_paths())
# ['C:\\Python37\\',
# 'C:\\Anaconda3\\',
# 'C:\\Anaconda3\\envs\\py35\\',
# 'C:\\Anaconda3\\envs\\py36\\',
# 'C:\\Anaconda3\\envs\\py37\\',
# 'C:\\Anaconda3\\envs\\py38\\',
# 'C:\\Anaconda3\\envs\\py39\\']

# PyEnv 类:
##########
# 实例化一个 PyEnv 类:
target = PyEnv('C:\\Python37\\')
# target = PyEnv() 与上面一行代码效果是一样的,省略参数时 PyEnv 内部会调用 cur_py_path 函数获取系统环境变量 PATH 中第一个 Python 目录路径,如果 Python 路径还未设置到 PATH 中,则创建一个不指向任何 Python 目录路径的 PyEnv 空实例,实例的所有方法被调用时都将返回空值(不同的方法返回的数据类型也不同,但都是可以判为 False 的空值,例如空列表、空字符串)

# 在该环境中安装模块(例如安装 fastpip):
print(target.install('fastpip', upgrade=1))
# 安装成功返回 True,否则返回 False。
# upgrade=1 代表以升级模式安装最新版本,否则如果环境中已安装 fastpip,install 方法将不会再安装一次 fastpip。
# 如果有需要,也可以增加以下关键字参数:
# index_url:str,例如 index_url='https://mirrors.cloud.tencent.com/pypi/simple'。本次安装从镜像地址 index_url 处下载安装,否则从本地设置的全局镜像源地址安装,如果本地未设置全局镜像源地址,则从官方源 PyPi 安装,国内用户下载速度非常慢甚至可能因连接超时导致安装失败。
# timeout:int 或 float 或 None,例如 timeout=30,表示设置安装超时限制30秒,如果安装用时超过30秒,则安装失败。None 代表不设超时限制(默认)。
# output:bool,例如 output=True,表示在安装过程中,在终端上打印安装时的输出信息。
```

更多使用方法请查看源代码或者用 help:

```python
import fastpip

help(fastpip)
```

------

<br />

## 贡献

感谢 liangzai450 的贡献!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hrpzcf/fastpip",
    "name": "fastpip",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "pip,package",
    "author": "hrpzcf",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/34/b3/f5b871a7005a796f56c18e18ec0b8e65adfd18194f5befa759949e4621d0/fastpip-1.7.0.tar.gz",
    "platform": "win32",
    "description": "# fastpip\r\n\r\n## \u7b80\u4ecb\r\n\r\n------\r\n\r\n\u4e00\u4e2a pip \u547d\u4ee4\u5305\uff0c\u5e2e\u52a9\u4f60\u5b9e\u73b0\u4f7f\u7528 Python \u7f16\u7a0b\u7684\u65b9\u5f0f\u8fdb\u884c\u5305\u7ba1\u7406\u64cd\u4f5c\u3002\r\n\r\n<br />\r\n\r\n## \u5982\u4f55\u5b89\u88c5\r\n\r\n------\r\n\r\n`\u6ce8\uff1afastpip \u4ec5\u652f\u6301 Windows \u7cfb\u7edf\u3002`\r\n\r\n<br />\r\n\r\n> \u6253\u5f00\u547d\u4ee4\u7a97\u53e3\u6216 PowerShell \u7a97\u53e3\uff0c\u4f7f\u7528 pip \u547d\u4ee4\u5b89\u88c5\uff1a\r\n\r\n```cmd\r\npip install -U fastpip\r\n```\r\n\r\n<br /><br />\r\n\r\n## \u5982\u4f55\u4f7f\u7528\r\n\r\n------\r\n\r\n\u793a\u4f8b1\uff1a\u4f7f\u7528 fastpip \u5347\u7ea7 Python \u73af\u5883\u4e2d\u7684\u5305\r\n\r\n```python\r\nimport sys\r\n\r\n# \u5bfc\u5165 PyEnv \u7c7b\r\nfrom fastpip import PyEnv\r\n\r\n# \u521b\u5efa PyEnv \u5b9e\u4f8b\uff1aPyEnv(_path)\r\n# \u53c2\u6570 _path \u662f\u4e00\u4e2a\u8def\u5f84\uff0c\u6307\u5411 Python \u89e3\u91ca\u5668(python.exe)\u6240\u5728\u76ee\u5f55\r\n# \u4f8b\u5982 env = PyEnv(r'C:\\Anaconda3\\envs\\py35')\r\n\r\n# \u4e0d\u5e26\u53c2\u6570\u6216\u8005 PyEnv(None) \u5219\u4f7f\u7528\u7cfb\u7edf\u73af\u5883\u53d8\u91cf PATH \u4e2d\u7b2c\u4e00\u4e2a Py \u73af\u5883\u8def\u5f84\r\nenv = PyEnv()\r\n\r\n# \u8c03\u7528 PyEnv \u7c7b\u5b9e\u4f8b\u7684 outdated \u65b9\u6cd5\u83b7\u53d6\u53ef\u66f4\u65b0\u7684\u5305\u5217\u8868\r\n# \u53c2\u6570 output \u63a7\u5236\u662f\u5426\u5728\u7ec8\u7aef\u663e\u793a pip \u547d\u4ee4\u8f93\u51fa\r\n# \u5982\u679c\u5728 GUI \u7a0b\u5e8f\u4e2d\u4f7f\u7528 fastpip \u8bf7\u5c06\u8fd9\u4e2a\u53c2\u6570\u8bbe\u7f6e\u4e3a False\uff08\u9ed8\u8ba4\uff09\r\n# outdated \u8fd4\u56de\u503c\u7ed3\u6784\uff1a\r\n# [\r\n# (\u5305\u540d, \u5df2\u5b89\u88c5\u7248\u672c, \u6700\u65b0\u7248\u672c, \u5b89\u88c5\u5305\u7c7b\u578b),\r\n# ...\r\n# ]\r\noutdated_pkgs = env.outdated(output=1)\r\n\r\n# \u8be2\u95ee\u662f\u5426\u5b89\u88c5\u6240\u6709\u53ef\u66f4\u65b0\u7684\u5305\uff0c\u56de\u7b54\u975e y \u5219\u9000\u51fa\r\nif input('\\n\u786e\u8ba4\u66f4\u65b0\uff1fy/[n]\uff1a').lower() != 'y':\r\n    sys.exit(0)\r\n\r\nfor name, *_ in outdated_pkgs:\r\n    # \u8c03\u7528\u76ee\u6807\u73af\u5883\u7684 PyEnv \u5b9e\u4f8b\u7684 install \u65b9\u6cd5\u8fdb\u884c\u5b89\u88c5\u3002\r\n    # upgrade \u53c2\u6570\u4e3a True\uff1a\r\n    # \u4ee5\u5347\u7ea7\u6a21\u5f0f\u5b89\u88c5\uff0c\u5982\u679c\u76ee\u6807\u73af\u5883\u5df2\u5b89\u88c5\u8be5\u5305\u4e14\u8be5\u5305\u6709\u65b0\u7248\u672c\uff0c\u5219\u5b89\u88c5\u65b0\u7248\u672c\uff0c\u5426\u5219\u8df3\u8fc7\u3002\r\n    # upgrade \u53c2\u6570\u4e3a False\uff1a\r\n    # \u5982\u679c\u76ee\u6807\u73af\u5883\u5df2\u5b89\u88c5\uff0c\u4e0d\u7ba1\u8be5\u5305\u6709\u6ca1\u6709\u65b0\u7248\u672c\u90fd\u4e0d\u4f1a\u91cd\u65b0\u5b89\u88c5\uff0c\u76f4\u63a5\u8df3\u8fc7\u3002\r\n    env.install(name, upgrade=1, output=1)\r\n\r\nprint('\u5168\u90e8\u66f4\u65b0\u5b8c\u6210\uff01')\r\n\r\n```\r\n\r\n\u793a\u4f8b2\uff1a\r\n```python\r\nfrom fastpip import PyEnv, all_py_paths, cur_py_path, index_urls\r\n\r\n# \u6253\u5370\u9884\u7f6e\u7684\u51e0\u4e2a\u56fd\u5185 PyPi \u955c\u50cf\u5730\u5740\uff1a\r\nprint(index_urls)\r\n# {'aliyun': 'https://mirrors.aliyun.com/pypi/simple/',\r\n# 'tencent': 'https://mirrors.cloud.tencent.com/pypi/simple',\r\n# 'douban': 'https://pypi.doubanio.com/simple/',\r\n# 'huawei': 'https://mirrors.huaweicloud.com/repository/pypi/simple',\r\n# 'opentuna': 'https://opentuna.cn/pypi/web/simple',\r\n# 'tsinghua': 'https://pypi.tuna.tsinghua.edu.cn/simple',\r\n# 'netease': 'https://mirrors.163.com/pypi/simple/'}\r\n\r\n# \u5f53\u524d\u7cfb\u7edf\u73af\u5883\u53d8\u91cf PATH \u4e2d\u7b2c\u4e00\u4e2a Python \u73af\u5883\u8def\u5f84\uff1a\r\nprint(cur_py_path())\r\n# C:\\Python37\\ (\u5177\u4f53\u4e0e\u4e2a\u4eba\u7cfb\u7edf\u73af\u5883\u53d8\u91cf PATH \u8bbe\u7f6e\u6709\u5173)\r\n\r\n# \u5728\u5e38\u7528\u5b89\u88c5\u4f4d\u7f6e\u67e5\u627e Python \u76ee\u5f55\uff1a\r\nprint(all_py_paths())\r\n# ['C:\\\\Python37\\\\',\r\n# 'C:\\\\Anaconda3\\\\',\r\n# 'C:\\\\Anaconda3\\\\envs\\\\py35\\\\',\r\n# 'C:\\\\Anaconda3\\\\envs\\\\py36\\\\',\r\n# 'C:\\\\Anaconda3\\\\envs\\\\py37\\\\',\r\n# 'C:\\\\Anaconda3\\\\envs\\\\py38\\\\',\r\n# 'C:\\\\Anaconda3\\\\envs\\\\py39\\\\']\r\n\r\n# PyEnv \u7c7b\uff1a\r\n##########\r\n# \u5b9e\u4f8b\u5316\u4e00\u4e2a PyEnv \u7c7b\uff1a\r\ntarget = PyEnv('C:\\\\Python37\\\\')\r\n# target = PyEnv() \u4e0e\u4e0a\u9762\u4e00\u884c\u4ee3\u7801\u6548\u679c\u662f\u4e00\u6837\u7684\uff0c\u7701\u7565\u53c2\u6570\u65f6 PyEnv \u5185\u90e8\u4f1a\u8c03\u7528 cur_py_path \u51fd\u6570\u83b7\u53d6\u7cfb\u7edf\u73af\u5883\u53d8\u91cf PATH \u4e2d\u7b2c\u4e00\u4e2a Python \u76ee\u5f55\u8def\u5f84\uff0c\u5982\u679c Python \u8def\u5f84\u8fd8\u672a\u8bbe\u7f6e\u5230 PATH \u4e2d\uff0c\u5219\u521b\u5efa\u4e00\u4e2a\u4e0d\u6307\u5411\u4efb\u4f55 Python \u76ee\u5f55\u8def\u5f84\u7684 PyEnv \u7a7a\u5b9e\u4f8b\uff0c\u5b9e\u4f8b\u7684\u6240\u6709\u65b9\u6cd5\u88ab\u8c03\u7528\u65f6\u90fd\u5c06\u8fd4\u56de\u7a7a\u503c(\u4e0d\u540c\u7684\u65b9\u6cd5\u8fd4\u56de\u7684\u6570\u636e\u7c7b\u578b\u4e5f\u4e0d\u540c\uff0c\u4f46\u90fd\u662f\u53ef\u4ee5\u5224\u4e3a False \u7684\u7a7a\u503c\uff0c\u4f8b\u5982\u7a7a\u5217\u8868\u3001\u7a7a\u5b57\u7b26\u4e32)\r\n\r\n# \u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u6a21\u5757(\u4f8b\u5982\u5b89\u88c5 fastpip)\uff1a\r\nprint(target.install('fastpip', upgrade=1))\r\n# \u5b89\u88c5\u6210\u529f\u8fd4\u56de True\uff0c\u5426\u5219\u8fd4\u56de False\u3002\r\n# upgrade=1 \u4ee3\u8868\u4ee5\u5347\u7ea7\u6a21\u5f0f\u5b89\u88c5\u6700\u65b0\u7248\u672c\uff0c\u5426\u5219\u5982\u679c\u73af\u5883\u4e2d\u5df2\u5b89\u88c5 fastpip\uff0cinstall \u65b9\u6cd5\u5c06\u4e0d\u4f1a\u518d\u5b89\u88c5\u4e00\u6b21 fastpip\u3002\r\n# \u5982\u679c\u6709\u9700\u8981\uff0c\u4e5f\u53ef\u4ee5\u589e\u52a0\u4ee5\u4e0b\u5173\u952e\u5b57\u53c2\u6570\uff1a\r\n# index_url\uff1astr\uff0c\u4f8b\u5982 index_url='https://mirrors.cloud.tencent.com/pypi/simple'\u3002\u672c\u6b21\u5b89\u88c5\u4ece\u955c\u50cf\u5730\u5740 index_url \u5904\u4e0b\u8f7d\u5b89\u88c5\uff0c\u5426\u5219\u4ece\u672c\u5730\u8bbe\u7f6e\u7684\u5168\u5c40\u955c\u50cf\u6e90\u5730\u5740\u5b89\u88c5\uff0c\u5982\u679c\u672c\u5730\u672a\u8bbe\u7f6e\u5168\u5c40\u955c\u50cf\u6e90\u5730\u5740\uff0c\u5219\u4ece\u5b98\u65b9\u6e90 PyPi \u5b89\u88c5\uff0c\u56fd\u5185\u7528\u6237\u4e0b\u8f7d\u901f\u5ea6\u975e\u5e38\u6162\u751a\u81f3\u53ef\u80fd\u56e0\u8fde\u63a5\u8d85\u65f6\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002\r\n# timeout\uff1aint \u6216 float \u6216 None\uff0c\u4f8b\u5982 timeout=30\uff0c\u8868\u793a\u8bbe\u7f6e\u5b89\u88c5\u8d85\u65f6\u9650\u523630\u79d2\uff0c\u5982\u679c\u5b89\u88c5\u7528\u65f6\u8d85\u8fc730\u79d2\uff0c\u5219\u5b89\u88c5\u5931\u8d25\u3002None \u4ee3\u8868\u4e0d\u8bbe\u8d85\u65f6\u9650\u5236(\u9ed8\u8ba4)\u3002\r\n# output\uff1abool\uff0c\u4f8b\u5982 output=True\uff0c\u8868\u793a\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u5728\u7ec8\u7aef\u4e0a\u6253\u5370\u5b89\u88c5\u65f6\u7684\u8f93\u51fa\u4fe1\u606f\u3002\r\n```\r\n\r\n\u66f4\u591a\u4f7f\u7528\u65b9\u6cd5\u8bf7\u67e5\u770b\u6e90\u4ee3\u7801\u6216\u8005\u7528 help\uff1a\r\n\r\n```python\r\nimport fastpip\r\n\r\nhelp(fastpip)\r\n```\r\n\r\n------\r\n\r\n<br />\r\n\r\n## \u8d21\u732e\r\n\r\n\u611f\u8c22 liangzai450 \u7684\u8d21\u732e\uff01\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "\u4e00\u4e2a pip \u547d\u4ee4\u5305\uff0c\u5e2e\u52a9\u4f60\u5b9e\u73b0\u4f7f\u7528 Python \u7f16\u7a0b\u7684\u65b9\u5f0f\u8fdb\u884c\u5305\u7ba1\u7406\u64cd\u4f5c\u3002",
    "version": "1.7.0",
    "split_keywords": [
        "pip",
        "package"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d40f2784e78fc784f1aeb9b848854093842a290b85df66f6bcaf63921637fc49",
                "md5": "aecdc8530f92f5762105f8ad74b3efea",
                "sha256": "0117a2164a61ec79fff1c30f9ed04c88478a81dfea824d545f0e9351007e8686"
            },
            "downloads": -1,
            "filename": "fastpip-1.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aecdc8530f92f5762105f8ad74b3efea",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 27682,
            "upload_time": "2023-03-13T03:36:51",
            "upload_time_iso_8601": "2023-03-13T03:36:51.146248Z",
            "url": "https://files.pythonhosted.org/packages/d4/0f/2784e78fc784f1aeb9b848854093842a290b85df66f6bcaf63921637fc49/fastpip-1.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "34b3f5b871a7005a796f56c18e18ec0b8e65adfd18194f5befa759949e4621d0",
                "md5": "2cf8cd730c1178a30280e75588087c2d",
                "sha256": "5866d9ddeb6b71d783eef94068f1e85659563080d57693225591ff8f05d1b717"
            },
            "downloads": -1,
            "filename": "fastpip-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2cf8cd730c1178a30280e75588087c2d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 24947,
            "upload_time": "2023-03-13T03:36:52",
            "upload_time_iso_8601": "2023-03-13T03:36:52.629616Z",
            "url": "https://files.pythonhosted.org/packages/34/b3/f5b871a7005a796f56c18e18ec0b8e65adfd18194f5befa759949e4621d0/fastpip-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-13 03:36:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "hrpzcf",
    "github_project": "fastpip",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "fastpip"
}
        
Elapsed time: 0.04454s