Bug 46178

Summary: Игнорирует системные модули при запуске pip3 и python3 -m pip
Product: Sisyphus Reporter: Andrey Cherepanov <cas>
Component: python3-module-pipAssignee: Stanislav Levin <slev>
Status: CLOSED NOTABUG QA Contact: qa-sisyphus
Severity: normal    
Priority: P5 CC: antohami, cas, cow, evg, george, grenka, imz, kotopesutility, lav, nbr, qa_viy, rider, sem, shaba, sin, slev, toni, vitty, viy
Version: unstable   
Hardware: x86_64   
OS: Linux   

Description Andrey Cherepanov 2023-05-17 13:30:18 MSK
Собираю новый guake. Валится на установке:

pip3 -v install --prefix /usr/src/tmp/guake-buildroot . --no-index
Using pip 23.1.2 from /usr/lib64/python3/site-packages/pip (python 3.10)
Processing /usr/src/RPM/BUILD/guake-3.10
  Running command pip subprocess to install build dependencies
  ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)
  ERROR: No matching distribution found for setuptools>=40.8.0
  error: subprocess-exited-with-error
 
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python3 /usr/lib64/python3/site-packages/pip/__pip-runner__.py install --ignore-installed --no-user --prefix /usr/src/tmp/pip-build-env-fh6c2zel/overlay --no-warn-script-location --no-binary :none: --only-binary :none: --no-index -- 'setuptools>=40.8.0' wheel
  cwd: [inherit]
  Installing build dependencies ... error
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Смотрю код: /usr/lib64/python3/site-packages/pip/_internal/build_env.py +238
       args: List[str] = [
            sys.executable,
            pip_runnable,
            "install",
            "--ignore-installed",
            "--no-user",
            "--prefix",
            prefix.path,
            "--no-warn-script-location",
        ]
Вот почему --ignore-installed прибито, что не даёт использовать системные модули?
Comment 1 Stanislav Levin 2023-05-17 14:06:19 MSK
Для команды `pip3 -v install --prefix /usr/src/tmp/guake-buildroot . --no-index`
pip сначала собирет whl, затем установит его:
https://pip.pypa.io/en/stable/cli/pip_install/#overview

Для сборки по умолчанию используется изоляция через временную директорию:
https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#build-process

`--ignore-installed` прибито, чтобы установить *все* зависимости
https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-I
независимо от того, что установлено администратором или пользователем.

> For example, a project that needs an older version of setuptools to build can still be installed, even if the user has an newer version installed (and without silently replacing that version).


Почему вы не хотите/не можете воспользоваться имеющимися RPM макросами для сборки Python проектов в ALT?
Comment 2 Stanislav Levin 2023-05-17 17:38:45 MSK
Если по какой-то причине всё же нужно использовать pip для сборки и установки, то
можно использовать опцию `--no-build-isolation`:
https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-no-build-isolation

или её вариант через переменную окружения `PIP_NO_BUILD_ISOLATION=no`.
Comment 3 Andrey Cherepanov 2023-05-22 11:33:05 MSK
(Ответ для Stanislav Levin на комментарий #2)
> Если по какой-то причине всё же нужно использовать pip для сборки и
> установки, то
> можно использовать опцию `--no-build-isolation`:
> https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-no-build-isolation
> 
> или её вариант через переменную окружения `PIP_NO_BUILD_ISOLATION=no`.

Спасибо, работает с таким woraround. Проект не чисто python.