跳转到主要内容

这是一个用于通过锁文件管理的简单下载Python包的工具。

项目描述

PyPI PyPI - Python Version License

py.lockfile

安装

pip install py.lockfile2

py.lockfile 是一个用于在各种操作系统、CPU和Python版本中下载Python包的工具。

动机

pipenvpoetrypdm 管理的Python项目使用锁文件来冻结特定版本的包,这对整个项目的稳定性非常有用。然而,为了安装这些冻结的包,我们必须使用所提到的包管理器,这会带来许多不必要的依赖关系。特别是对于构建Docker容器来说,这很不方便。

该工具接受 Pipfile.lock/poetry.lock/pdm.lock 文件,并将所有所需的包(针对特定操作系统、CPU和Python版本)下载到目标目录。然后我们可以通过简单的 pip 安装它们。

使用示例

> py.lockfile -s tests/poetry.lock -t wheels/
📦 cffi 1.15.1  cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

> pip install wheels/*
cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

高级选项

该工具接受许多参数,最常用的有 --python-version--platform。它们可以帮助我们下载适用于不同Python版本或操作系统平台的包。获取系统正确的 --platform 属性可能很复杂。此命令可以帮助 py_lockfile --help | grep 'Your current platform'

> py.lockfile --help
usage: py_lockfile [-h] [-s SOURCEFILE] [-t TARGET] [-g GROUP] [-p PYTHON_VERSION] [--platform PLATFORM] [--python-implementation {cp,ip,pp,jy}] [--ignore-missing] [--ignore-hash] [--no-binary] [--dryrun] [--no-color]

Python package downloader.
---------------------------------

This is a simple tool for download python packages managed by lock file.
Repository credentials can be set by environment variables
(PYLF_<NAME>_USERNAME, PYLF_<NAME>_PASSWORD and PYLF_<NAME>_URL).

Supported:
    * Pipfile.lock - Pipenv.
    * poetry.lock - Poetry, the repository credentials are automatically loaded
                    from ~/.config/pypoetry/auth.toml.
    * pdm.lock - PDM, the repository credentials are automatically loaded from
                 pyproject.toml

optional arguments:
  -h, --help            show this help message and exit
  -s SOURCEFILE, --sourcefile SOURCEFILE
                        source file (e.g. Pipfile.lock, poetry.lock or pdm.lock)
  -t TARGET, --target TARGET
                        Download folder (default: ./wheels)
  -g GROUP, --group GROUP
                        Append optional group of packages (e.g. dev)
  -p PYTHON_VERSION, --python-version PYTHON_VERSION
                        Download packages for python version (default: 3.9.5).
  --platform PLATFORM   Download packages for platform (default: manylinux_2_28_x86_64).
  --python-implementation {cp,ip,pp,jy}
                        Download packages for python implementation (default: cp).
  --ignore-missing      Skip missing packages.
  --ignore-hash         Ignore package hash checking.
  --no-binary           Download only source packages.
  --dryrun              Dry run. No download will be performed.
  --no-color            Disable color output.

SOURCEFILE:
    Automatically try to find supported files in current folder.

PLATFORM:
    Your current platform is 'manylinux_2_28_x86_64'
    See more https://peps.pythonlang.cn/pep-0491/#file-name-convention
    e.g.:
        * macosx_10_9_x86_64
        * win_amd64
        * manylinux_2_17_x86_64    # glib linux systems (RHEL based system) https://peps.pythonlang.cn/pep-0600/
        * musllinux_1_1_x86_64     # musl linux systems (AlpineLinux) https://peps.pythonlang.cn/pep-0656/

PYTHON_IMPLEMENTATION:
   * 'cp' - CPython
   * 'pp' - Pypy
   * 'ip' - IronPython
   * 'jy' - Jython

默认情况下,--python-version--platform--python-implementation 的值设置为当前的Python配置。然而,您也可以下载适用于不同配置的包。

> py.lockfile -s tests/poetry.lock -t wheels/ --python-version 2.7 --platform win_amd64
📦 cffi 1.15.1  cffi-1.15.1-cp27-cp27m-win_amd64.whl

从私有仓库下载包

凭据将自动从 pypoetry/auth.tomlpyproject.toml 加载,或者我们可以通过环境变量覆盖它们。

PYLF_<REPO_NAME>_USERNAME=user PYLF_<REPO_NAME>_PASSWORD=password  py.lockfile ...

可选地,我们还可以设置 PYLF_<REPO_NAME>_URL,以便添加自定义的 PyPI 入口点。

项目详情


下载文件

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

源代码分发

py_lockfile2-0.3.0.tar.gz (11.0 kB 查看哈希值)

上传时间 源代码

构建分发

py_lockfile2-0.3.0-py3-none-any.whl (11.2 kB 查看哈希值)

上传时间 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面