flatpak-builder icon indicating copy to clipboard operation
flatpak-builder copied to clipboard

Add distutils support to builder

Open alexlarsson opened this issue 8 years ago • 13 comments

From @TingPing on June 21, 2016 9:0

Quite a lot of Python projects use distutils/setuptools and would be nice to support that. Something like:

"modules": [
  {
    "name": "...",
    "no-autogen": true,
    "distutils": true
  }
]

That seems consistent with cmake. It would check for setup.py, run ./setup.py build --prefix=... and ./setup.py install --prefix=... --optimize=1 --skip-build. Though some projects don't have an exectuable setup.py so there would have to be another variable for python2 vs python3 in that case...

Copied from original issue: flatpak/flatpak#134

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

See also https://github.com/flatpak/flatpak/issues/39

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

From @bochecha on December 19, 2016 18:10

Though some projects don't have an exectuable setup.py so there would have to be another variable for python2 vs python3 in that case...

How about running $PYTHON setup.py ... instead?

The PYTHON env var could be set to /usr/bin/python2 by default, and each JSON manifest could set it to something else instead? It would even help with finding a different Python version in /app as well.

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

From @TingPing on December 19, 2016 22:26

Possible. @alexlarsson also mentioned the idea of a "simple" buildsystem type where you just directly give it the configure and make commands which would be sufficient for this.

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

Yes, having a buildsystem type that basically does nothing, but lets you list some commandlines to run, similar to post-install, or maybe even actually use post-install.

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

From @TheBiggerGuy on January 25, 2017 8:13

For reference I have found this the most effect pattern for Python packages.

{
  "name": "cheetah",
  "no-autogen": true,
  "sources": [
    {
      "type": "archive",
      "url": "https://pypi.python.org/packages/cd/b0/c2d700252fc251e91c08639ff41a8a5203b627f4e0a2ae18a6b662ab32ea/Cheetah-2.4.4.tar.gz",
      "sha256": "be308229f0c1e5e5af4f27d7ee06d90bb19e6af3059794e5fd536a6f29a9b550"
    }, {
      "type": "shell",
      "commands": [ "echo 'all:\n\ninstall:\n\tpython ./setup.py install --prefix=/app' > makefile" ]
    }
  ]
}

Naturally full support for Python as a first class build system would be preferably. This would be ideal.

{
  "name": "cheetah",
  "buildsystem": "setup.py",
  "sources": [
    {
      "type": "archive",
      "url": "https://pypi.python.org/packages/cd/b0/c2d700252fc251e91c08639ff41a8a5203b627f4e0a2ae18a6b662ab32ea/Cheetah-2.4.4.tar.gz",
      "sha256": "be308229f0c1e5e5af4f27d7ee06d90bb19e6af3059794e5fd536a6f29a9b550"
    }
  ]
}

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

Alternatively we could have a buildsystem: "simple", which just lets you type in an array of commands to run.

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

From @TingPing on January 26, 2017 9:12

Python modules are fairly common to the point where a built-in option for it would be nice though.

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

From @bochecha on January 26, 2017 10:26

Python modules are fairly common to the point where a built-in option for it would be nice though.

Except some work with python setup.py build -j X, but others fail as they don't know this option (because distutils vs setuptools).

And some work fine when you split python setup.py build and python setup.py install --skip-build, but others don't. (e.g numpy)

Etc...

And in the future, Python modules will have a pyproject.toml file and the Python packaging will probably change a lot (started with PEP 518, but there's still lots to do), to the point where setup.py files might disappear entirely.

So maybe for now the "buildsystem": "simple" approach is still the simplest for flatpak.

Plus, it's needed for other things than Python anyway. (I'm looking at you Boost and your b2 tool)

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

So, who wants to do "buildsystem": "simple"? :)

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

From @bochecha on May 10, 2017 8:39

Should we close this now that we have the simple buildsystem?

alexlarsson avatar Aug 25 '17 09:08 alexlarsson

I'm still having problems with this with more than one python module, they all want to write into easy-install.pth, but only the first one is allowed to because it's a read only file system after the first one.

I couldn't find anything in the docs to force writing into the file..

dcbaker avatar Aug 25 '17 19:08 dcbaker

@dcbaker This should help (some modules also use setuptools.pth):

"buildsystem": "simple",
"ensure-writable": [
    "/lib/python3.6/site-packages/easy-install.pth",
    "/lib/python3.6/site-packages/setuptools.pth"
],
...

jiri-janousek avatar Sep 01 '17 17:09 jiri-janousek

Thanks. I did find that option, but I hadn't thought to add setuptools.pth as well, but I'm sure I'll run into that before too much longer.

dcbaker avatar Sep 01 '17 23:09 dcbaker