【转载】poetry离线安装

文章介绍了如何在没有互联网连接的机器上安装Poetry。首先在有网络的机器上选择所需版本,下载Poetry及其依赖的wheel文件,然后打包传输到无网络的机器上。在无网络的机器上,解压文件,卸载可能已存在的Poetry版本,再使用修改后的安装脚本从本地文件安装Poetry。过程中提到了解决依赖包不匹配的问题。
摘要由CSDN通过智能技术生成

转自:https://labdmitriy.github.io/blog/poetry-installation-offline/

MotivationPermalink

What if you are using Poetry and due to some restrictions should install it on machine without internet?

After searching for the existing solutions, I only found GitHub issues like that with the same questions but without exact answers, so I decided to research it myself.

Finally I found pipeline for installing poetry offline with new installer for the current Poetry implementation.

AssumptionsPermalink

Let’s assume for the next steps that:

For the installation we choose poetry version 1.1.13
Ubuntu 20.04 is used
Python is installed
Source and destination directories are located in /tmp/poetry_dist
Machine with internetPermalink
Create and navigate to the directory where distribution will be prepared:

cd /tmp && mkdir poetry_dist && cd poetry_dist

Choose poetry version required for installation.
You can easily check which poetry versions are available for pip >= 21.2 (for older versions you can find corresponding method here):

pip index versions poetry

Save current installation code to the local file:

curl -o poetry_install.py -sSL https://install.python-poetry.org

Modify code to use local folder with wheels to install (Poetry and its dependencies):

sed -i 's/"install", specification/"install", "--no-index", "--find-links=.", specification/g' poetry_install.py

Select version and download all required packages:

env VERSION=1.1.13 bash -c 'pip download poetry==$VERSION'

Archive required files:

tar -czvf poetry_dist.tar.gz poetry_install.py *.whl --remove-files

Copy archive to the machine without internet to the destination folder:

/tmp/poetry_dist

Machine without internetPermalink

Navigate to the directory where distribution archive is located:

cd /tmp/poetry_dist

Extract archive:

tar -xzvf poetry_dist.tar.gz

Uninstall existing version of poetry (if any):

python poetry_install.py --uninstall

Install poetry from local file:

env VERSION=1.1.13 bash -c 'python poetry_install.py --path $(ls poetry-$VERSION*.whl)'

Delete intermediate files

rm poetry_install.py *.whl

Check that installation was successful

poetry --version

ConclusionPermalink

Probably it will be great to be able to pass pip arguments to install_poetry() function to reproduce these steps without installation code modification.

Shell scriptsPermalink

Also I created shell scripts in repository to automate these steps:

poetry_dist_prepare.sh
Prepare distribution for specific Poetry version in /tmp/poetry_dist folder.
Usage example (on machine with internet):

./poetry_dist_prepare.sh 1.1.13

poetry_dist_install.sh
Extract distribution archive located in /tmp/poetry_dist folder and install Poetry offline. Usage example (on machine without internet):

./poetry_dist_install.sh 1.1.13

以下为遇到的问题

换源

临时:
pip3 install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

安装的依赖:

在离线环境install时遇到依赖三方包没有的问题

*ERROR: Could not find a version that satisfies the requirement dulwich<0.22.0,>=0.21.2 (from poetry) (from versions: none)
ERROR: No matching distribution found for dulwich<0.22.0,>=0.21.2*

pip3 download xxx
backports.cached_property=>dulwich=》setuptools=>wheel=>msgpack=>Cython=>rapidfuzz
(pip3 download rapidfuzz==2.15.1)

依赖包不符合=》给改成了none-any.whl就可以了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值