You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.5 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "markdown",
"id": "d6326720",
"metadata": {},
"source": [
"# Работа offline #"
]
},
{
"cell_type": "markdown",
"id": "30e75439",
"metadata": {},
"source": [
"Отсутствие интернета не беда!\n",
"\n",
"В pypi репозитории 300 тысяч пакетов, 2,5 милионов релизов и порядка 4,5 милионов файлов что занимает более 2Тб. - это пакеты в исходном коде, колеса (whl), пакеты под разные платформы, версии Python и разные версии самого пакета.\n",
"\n",
"Для синхронизации репозитория pypi можно использовать пакет `bandersnatch`. Для развертывания локального pypi репозитория есть пакет `pypiserver`. Использовать его легко:\n",
"\n",
"```shell\n",
"pypi-server --port 8080 --interface 127.0.0.1 --root ~/path/packages --disable-fallback\n",
"```\n",
"\n",
"где в директории ~/path/packages находятся пакеты Python. Чтобы использовать данный pypi репозиторий необходимо настроить свой pip:\n",
"\n",
"```ini\n",
"; Linux: /etc/pip.conf\n",
"; Windows: C:\\Users\\User\\AppData\\Roaming\\pip\\pip.ini\n",
"\n",
"[global]\n",
"index = http://127.0.0.1:8080\n",
"index-url = http://127.0.0.1:8080/simple\n",
"trusted-host = 127.0.0.1\n",
"```\n",
"\n",
"Скачать определенный пакет с его зависимостями можно командой:\n",
"\n",
"```shell\n",
"pip download -d ~/path/packages <PACKAGE1> [<PACKAGE2> <PACKAGE3>]\n",
"```\n",
"\n",
"Установить пакет из директории можно вот так:\n",
"\n",
"```shell\n",
"pip install --no-index --find-links ~/path/packages <PACKAGE1> [<PACKAGE2> <PACKAGE3>]\n",
"```\n",
"\n",
"Для обновления самого pip используют команду:\n",
"\n",
"```shell\n",
"pip install --upgrade pip\n",
"```\n",
"\n",
"или (что в Windows чаще приходится делать):\n",
"```shell\n",
"python -m pip install --upgrade pip\n",
"```\n",
"\n",
"Сам pip можно получить разным способом (если конечно его нет в системе с самим Python):\n",
"\n",
"- установить из репозитория в Linux:\n",
"\n",
"```shell\n",
"yum install python3-pip\n",
"```\n",
"\n",
"- установить с помощью модуля Python:\n",
"\n",
"```shell\n",
"python3 -m ensurepip\n",
"```\n",
"\n",
"- скачать с сайта и установить.\n",
"\n",
"```shell\n",
"wget https://bootstrap.pypa.io/get-pip.py\n",
"python get-pip.py\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}