flatpak / flatpak-builder-tools

Various helper tools for flatpak-builder
196 stars 107 forks source link

flatpak-pip-generator not working for sqlalchemy #100

Open FlexW opened 4 years ago

FlexW commented 4 years ago

If I generate the json file for SQLAlchemy with ./flatpak-pip-generator SQLAlchemy I get the following file:

{
    "name": "python3-SQLAlchemy",
    "buildsystem": "simple",
    "build-commands": [
        "pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} SQLAlchemy"
    ],
    "sources": [
        {
            "type": "file",
            "url": "https://files.pythonhosted.org/packages/8c/30/4134e726dd5ed13728ff814fa91fc01c447ad8700504653fe99d91fdd34b/SQLAlchemy-1.3.15.tar.gz",
            "sha256": "c4cca4aed606297afbe90d4306b49ad3a4cd36feb3f87e4bfd655c57fd9ef445"
        }
    ]
}

However if I include this file in my manifest, I get the following error when building:

Downloading sources
Fetching full git repo file:///home/felix/workspace/projects/pyexpenses
Starting build of de.felixweilbach.pyexpenses
Cache miss, checking out last cache hit
========================================================================
Building module python3-SQLAlchemy in /home/felix/workspace/projects/pyexpenses/.flatpak-builder/build/python3-SQLAlchemy-1
========================================================================
Running: pip3 install --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} SQLAlchemy
Looking in links: file:///run/build/python3-SQLAlchemy
Collecting SQLAlchemy
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 /usr/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-d9x3xl0s/overlay --no-warn-script-location --no-binary :none: --only-binary :none: --no-index --find-links file:///run/build/python3-SQLAlchemy -- setuptools>=40.8.0 wheel:
  Looking in links: file:///run/build/python3-SQLAlchemy
  Collecting setuptools>=40.8.0
    Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: )
  No matching distribution found for setuptools>=40.8.0

  ----------------------------------------
Command "/usr/bin/python3 /usr/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-d9x3xl0s/overlay --no-warn-script-location --no-binary :none: --only-binary :none: --no-index --find-links file:///run/build/python3-SQLAlchemy -- setuptools>=40.8.0 wheel" failed with error code 1 in None
Error: module python3-SQLAlchemy: Child process exited with code 1

I use org.gnome.Platform with version 3.32 as runtime and if I inspect the runtime with flatpak run org.gnome.platform//3.32, I can see that setuptools 40.8.0 are already installed.

bauermann commented 4 years ago

This is because when pip installs build dependencies, it uses the --ignore-installed option which causes it to ignore the system site packages. If you manually run the command reported in the error message but without that option on the command line, then it will work.

According to pip's commit message, this is to "improve [the] build environment [...] better isolation (ignore system site packages)".

I tried applying this patch:

diff --git a/pip/flatpak-pip-generator b/pip/flatpak-pip-generator
index 2a565a94365b..e9d13dcd7eea 100755
--- a/pip/flatpak-pip-generator
+++ b/pip/flatpak-pip-generator
@@ -297,8 +297,6 @@ for package in packages:
         print('Warning: skipping invalid requirement specification {} because it is missing a name'.format(package.line), file=sys.stderr)
         print('Append #egg=<pkgname> to the end of the requirement line to fix', file=sys.stderr)
         continue
-    elif package.name in system_packages:
-        continue

     if len(package.extras) > 0:
         extras = '[' + ','.join(extra for extra in package.extras) + ']'

But unfortunately it still didn't solve the problem.