Fix build #98

Closed
jflysohigh wants to merge 1 commit from jfly/fix-build into main
jflysohigh commented 2022-08-25 18:50:21 +02:00 (Migrated from gitlab.com)

When doing a python setup.py build on my machine, I found that
build/lib would not end up with a compiled gresource file until the
second invocation of python setup.py build.

Before:

$ python setup.py build
running build
running build_py
creating build
creating build/lib
creating build/lib/mcg
copying mcg/connectionpanel.py -> build/lib/mcg
copying mcg/shortcutsdialog.py -> build/lib/mcg
copying mcg/serverpanel.py -> build/lib/mcg
copying mcg/application.py -> build/lib/mcg
copying mcg/window.py -> build/lib/mcg
copying mcg/playlistpanel.py -> build/lib/mcg
copying mcg/utils.py -> build/lib/mcg
copying mcg/coverpanel.py -> build/lib/mcg
copying mcg/infodialog.py -> build/lib/mcg
copying mcg/librarypanel.py -> build/lib/mcg
copying mcg/client.py -> build/lib/mcg
copying mcg/zeroconf.py -> build/lib/mcg
copying mcg/mcg.py -> build/lib/mcg
copying mcg/__init__.py -> build/lib/mcg
copying mcg/albumheaderbar.py -> build/lib/mcg
package init file 'data/__init__.py' not found (or not a regular file)
compiling gresources
compiling gschemas

$ ls build/lib/mcg/data/
ls: cannot access 'build/lib/mcg/data/': No such file or directory

Note how there is no data directory at all. Now check out what happens
on the second build:

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        data/gschemas.compiled
        data/xyz.suruatoel.mcg.gresource

nothing added to commit but untracked files present (use "git add" to track)

$ python setup.py build
running build
running build_py
package init file 'data/__init__.py' not found (or not a regular file)
creating build/lib/mcg/data
copying data/xyz.suruatoel.mcg.gresource -> build/lib/mcg/data
compiling gresources
compiling gschemas

$ ls build/lib/mcg/data/
xyz.suruatoel.mcg.gresource

That's because the first build generated the compiled schemas and
resources (you can see evidence of that in git status), and then the
second build was able to copy the gresource file over according to the
package_data rules. The fix I've introduced here is to just do the
compilations before we call super(...).run(...). There might be
better ways of doing this, I'm not very familiar with packaging gtk
python applications.

Things were even worse for the gschemas.compiled file: in addition to
the ordering issue it's not even mentioned in data_files, so even if
it does exist, it doesn't have a chance to get copied over when
installed. So I've added it to the data_files section. I don't know if
that'll play nicely or not with the existing --no-compile-schemas
flag.

When doing a `python setup.py build` on my machine, I found that `build/lib` would not end up with a compiled gresource file until the second invocation of `python setup.py build`. Before: $ python setup.py build running build running build_py creating build creating build/lib creating build/lib/mcg copying mcg/connectionpanel.py -> build/lib/mcg copying mcg/shortcutsdialog.py -> build/lib/mcg copying mcg/serverpanel.py -> build/lib/mcg copying mcg/application.py -> build/lib/mcg copying mcg/window.py -> build/lib/mcg copying mcg/playlistpanel.py -> build/lib/mcg copying mcg/utils.py -> build/lib/mcg copying mcg/coverpanel.py -> build/lib/mcg copying mcg/infodialog.py -> build/lib/mcg copying mcg/librarypanel.py -> build/lib/mcg copying mcg/client.py -> build/lib/mcg copying mcg/zeroconf.py -> build/lib/mcg copying mcg/mcg.py -> build/lib/mcg copying mcg/__init__.py -> build/lib/mcg copying mcg/albumheaderbar.py -> build/lib/mcg package init file 'data/__init__.py' not found (or not a regular file) compiling gresources compiling gschemas $ ls build/lib/mcg/data/ ls: cannot access 'build/lib/mcg/data/': No such file or directory Note how there is no data directory at all. Now check out what happens on the second build: $ git status On branch main Your branch is up to date with 'origin/main'. Untracked files: (use "git add <file>..." to include in what will be committed) data/gschemas.compiled data/xyz.suruatoel.mcg.gresource nothing added to commit but untracked files present (use "git add" to track) $ python setup.py build running build running build_py package init file 'data/__init__.py' not found (or not a regular file) creating build/lib/mcg/data copying data/xyz.suruatoel.mcg.gresource -> build/lib/mcg/data compiling gresources compiling gschemas $ ls build/lib/mcg/data/ xyz.suruatoel.mcg.gresource That's because the first build generated the compiled schemas and resources (you can see evidence of that in `git status`), and then the second build was able to copy the gresource file over according to the `package_data` rules. The fix I've introduced here is to just do the compilations *before* we call `super(...).run(...)`. There might be better ways of doing this, I'm not very familiar with packaging gtk python applications. Things were even worse for the gschemas.compiled file: in addition to the ordering issue it's not even mentioned in `data_files`, so even if it does exist, it doesn't have a chance to get copied over when installed. So I've added it to the `data_files` section. I don't know if that'll play nicely or not with the existing `--no-compile-schemas` flag.
jflysohigh commented 2022-08-25 18:51:00 +02:00 (Migrated from gitlab.com)

mentioned in merge request jflysohigh/mcg!1

mentioned in merge request jflysohigh/mcg!1
coderkun commented 2022-08-26 09:09:36 +02:00 (Migrated from gitlab.com)

Thanks for your patch, @jflysohigh, it looks good to me. I will test it next week or at the weekend.

Please note that I am also working on Meson (see #32), which will overhaul the build process.

Thanks for your patch, @jflysohigh, it looks good to me. I will test it next week or at the weekend. Please note that I am also working on Meson (see #32), which will overhaul the build process.
jflysohigh commented 2022-08-26 16:10:59 +02:00 (Migrated from gitlab.com)

Thanks, @coderkun. And good luck with meson!

Thanks, @coderkun. And good luck with meson!
coderkun commented 2022-09-11 12:15:44 +02:00 (Migrated from gitlab.com)

The changes look good, I merged them into the main branch. I only removed the removal of a blank line.

The changes look good, I merged them into the main branch. I only removed the removal of a blank line.

Pull request closed

Sign in to join this conversation.
No description provided.