flatpak / flatpak-builder

Tool to build flatpaks from source
GNU Lesser General Public License v2.1
141 stars 93 forks source link

[Bug]: Python packages vanished after installed with pip #548

Closed derekdai closed 1 year ago

derekdai commented 1 year ago

Checklist

flatpak-builder version

1.2.3

Flatpak version

1.14.4

How to reproduce

With this manifest

app-id: org.flatpak.Hello
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
command: hello.sh
modules:
  - name: hello
    buildsystem: simple
    build-commands:
      - pip install httpie
      - pip show httpie
    sources:
      - type: file
        path: hello.sh
    build-options:
      build-args:
        - --share=network

Build with command below

$ touch hello.sh
$ flatpak-builder build-dir org.flatpak.Hello.yml

The package and its dependencies will download and install successfully, but pip show httpie report not found.

Expected Behavior

packages install through pip can be found and used.

Actual Behavior

Installed packages can't be found.

Additional Information

$ flatpak-builder build-dir org.flatpak.Hello.yml
Downloading sources
Starting build of org.flatpak.Hello
Cache miss, checking out last cache hit
========================================================================
Building module hello in /home/user/xxx/.flatpak-builder/build/hello-2
========================================================================
Running: pip install httpie
Defaulting to user installation because normal site-packages is not writeable
Collecting httpie
  Downloading httpie-3.2.1-py3-none-any.whl (124 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 125.0/125.0 kB 293.8 kB/s eta 0:00:00
Requirement already satisfied: pip in /usr/lib/python3.10/site-packages (from httpie) (23.1)
Collecting charset-normalizer>=2.0.0 (from httpie)
  Downloading charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.3/199.3 kB 1.0 MB/s eta 0:00:00
Collecting defusedxml>=0.6.0 (from httpie)
  Downloading defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Collecting requests[socks]>=2.22.0 (from httpie)
  Downloading requests-2.29.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.5/62.5 kB 3.6 MB/s eta 0:00:00
Requirement already satisfied: Pygments>=2.5.2 in /usr/lib/python3.10/site-packages (from httpie) (2.15.1)
Collecting requests-toolbelt>=0.9.1 (from httpie)
  Downloading requests_toolbelt-0.10.1-py2.py3-none-any.whl (54 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.5/54.5 kB 3.0 MB/s eta 0:00:00
Collecting multidict>=4.7.0 (from httpie)
  Downloading multidict-6.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (114 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 114.5/114.5 kB 3.0 MB/s eta 0:00:00
Requirement already satisfied: setuptools in /usr/lib/python3.10/site-packages (from httpie) (67.6.1)
Collecting rich>=9.10.0 (from httpie)
  Downloading rich-13.3.5-py3-none-any.whl (238 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 238.7/238.7 kB 2.8 MB/s eta 0:00:00
Collecting idna<4,>=2.5 (from requests[socks]>=2.22.0->httpie)
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 2.9 MB/s eta 0:00:00
Collecting urllib3<1.27,>=1.21.1 (from requests[socks]>=2.22.0->httpie)
  Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.9/140.9 kB 2.9 MB/s eta 0:00:00
Collecting certifi>=2017.4.17 (from requests[socks]>=2.22.0->httpie)
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 2.9 MB/s eta 0:00:00
Collecting PySocks!=1.5.7,>=1.5.6 (from requests[socks]>=2.22.0->httpie)
  Downloading PySocks-1.7.1-py3-none-any.whl (16 kB)
Collecting markdown-it-py<3.0.0,>=2.2.0 (from rich>=9.10.0->httpie)
  Downloading markdown_it_py-2.2.0-py3-none-any.whl (84 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.5/84.5 kB 3.0 MB/s eta 0:00:00
Collecting mdurl~=0.1 (from markdown-it-py<3.0.0,>=2.2.0->rich>=9.10.0->httpie)
  Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Installing collected packages: urllib3, PySocks, multidict, mdurl, idna, defusedxml, charset-normalizer, certifi, requests, markdown-it-py, rich, requests-toolbelt, httpie
  WARNING: The script normalizer is installed in '/home/user/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script markdown-it is installed in '/home/user/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts http, httpie and https are installed in '/home/user/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed PySocks-1.7.1 certifi-2022.12.7 charset-normalizer-3.1.0 defusedxml-0.7.1 httpie-3.2.1 idna-3.4 markdown-it-py-2.2.0 mdurl-0.1.2 multidict-6.0.4 requests-2.29.0 requests-toolbelt-0.10.1 rich-13.3.5 urllib3-1.26.15
Running: pip show httpie
WARNING: Package(s) not found: httpie
Error: module hello: Child process exited with code 1
TingPing commented 1 year ago

Use this tool: https://github.com/flatpak/flatpak-builder-tools/tree/master/pip

It generally does the right thing. In this case you need --prefix=${FLATPAK_DEST}

derekdai commented 1 year ago

Ah, thanks, I didn't realize it had a --build-only parameter.