How to check for python GObject Introspection modules in Autotools

When we are using compiled languages – we are usually depending on pkg-config files. For example, “PKG_CHECK_MODULES(GLIB, glib2)”, but what if we are using Python?

Autoconf Archive has AX_PYTHON_MODULE macros. We can use it very easy.

How about Python + GObject Introspection? Let’s take GTK+ as an example. I wrote special m4 file (see below), you can place it in “m4” directory. Then you just need add “AX_PYTHON_GI(Gtk, 3.0)” into “configure.ac” and autoconf will check if GI works and Gtk-3.0.typelib is usable.

P.S. note that I’m not m4 expert, but it works for me.

# SYNOPSIS
#
#   AX_PYTHON_GI(gi_module, version[, python])
#
# DESCRIPTION
#
#   Checks for Python GObject Introspection and GI module with the given
#   version.
#
# LICENSE
#
#    Copyright (C) 2015 Igor Gnatenko <ignatenko@src.gnome.org>
#
#    Copying and distribution of this file, with or without modification, are
#    permitted in any medium without royalty provided the copyright notice
#    and this notice are preserved. This file is offered as-is, without any
#    warranty.

AC_DEFUN([AX_PYTHON_GI], [
    AC_MSG_CHECKING([for bindings for GObject Introspection])
    AX_PYTHON_MODULE([gi], [required], [$3])
    AC_MSG_CHECKING([for version $2 of $1 GObject Introspection module])
    $PYTHON -c "import gi; gi.require_version('$1', '$2')" 2> /dev/null
    AS_IF([test $? -eq 0], [], [
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([You need version $2 of the $1 GObject Introspection module.])
    ])
    AC_MSG_RESULT([yes])
])

How to use development version of tracker?

Due to my work on GNOME News project, I need to use development version of tracker. But making RPM with latest commits every time when I trying to test patch not easy I need a way to start my patched RSS miner. Carlos Garnacho gave me this way in IRC today.

Stop working RSS miner

$ killall tracker-miner-rss

Start my own RSS miner with debug mode enabled (I’m using JHBuild prefix)

$ ~/jhbuild/install/libexec/tracker-miner-rss -v 3

In this way you can follow for all DBus services I think.

Fedora, tracker RSS miner and sqlite FTS support

Hi readers, as you might know Allan Day gave us initial mockups for new GNOME project – News. This post is not about first preview working application, this post is about how we started writing application and how we helping other GNOME and Fedora projects :)

GNOME News mockup

With Vadim Rutkovsky we started working on this app yesterday’s night. We did choose to use tracker as storage backend and libgrss as our fetcher engine.

But we found some issues with them:

  • libgrss ships its .gir and .typelib in wrong directory – FIX. I spotted this when packaged libgrss, not when we started coding
  • libgrss introspection a bit wrong because it’s provides us gpointer instead of GrssFeedItem – FIX
  • tracker wants older name of libgrss (libgrss-0.6), but API/ABI have not broken and 0.5 version doesn’t work for us – FIX

Okay, we fixed this in upstream, cherry-picked changes to Fedora, but after enabling FTS support in Fedora’s sqlite – tracker doesn’t work on my laptop. I’ve spent a lot of time with trying to decide what happens there.

I gave SSH to my laptop for Carlos Garnacho and he realized that FTS support at compile-time was not enabled and tracker tries to load its own FTS, but actually FTS module from sqlite already loaded, so we got trying to load 2 the same modules (from sqlite and from tracker) twice.

Then I started rebuilding tracker in Fedora and got the same FTS not enabled at compile-time. The problem was with broken CFLAGS/LDFLAGS in m4 macro. In parallel I also found that /usr/bin/tracker-control has no executable flag and there are no tracker-compat binary. All those fixed in 1.5.0. Finally I updated tracker in Fedora to 1.5.0 with enabled FTS and RSS support – Koji build.

Feel free to join our channel in IRC: #gnome-news at GimpNet

Sources
Continue reading →

Meson and 3rd party dependencies. Wrap DB is here

In previous post I showed how to correctly use 3rd party dependencies. While I wrote that post I realized that making we need to do many things: create wrap file, create meson.build file, get checksums and upload archive with meson.build file to any http/ftp server. So we started thinking how to make it more easy for developers who just want to use dependency.

We discussed it and created web application which taking a care about making project.wrap and archive with meson.build available to developers – Wrap DB. It’s creating something like tags when pull request are merged in github. Let’s look at example.

Example project

Suppose you have a project that depends on the zlib compression library. First you go to http://wrapdb.mesonbuild.com and find the list of provided projects. After a few clicks you’ll get to the actual build definition, which can be found here: http://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.8/4/get_wrap

Then you just add the contents of that page to the subprojects directory called zlib.wrap. The second step is to declare in your main build definition that you wish to use the subproject. That is all you need to do.

We feel that this is a great step in reducing dependency problems that plaque native code development. We hope you do too. Enjoy!

Common questions about Wrap

Q: Isn’t this just Go get or Rust cargo but for C and C++?
A: Yes. But our aim is to provide this experience for projects that do not support it natively.

Q: How can I contribute?
A: The simplest thing is to just use the service and give us your feedback. If you want to do more, we recommend creating your own wraps and submitting them to the database. The process is extremely simple and fully documented in wiki.

Q: Isn’t it unsafe to download and execute random source packages?
A: Wrap definition files are plain text so they are easy to audit. All downloaded files are checksum verified so you know that you are not man-in-the-middled.

Q: How is this different from existing dependency systems (biicode etc)?
A: To our knowledge this is the first system of its kind that combines the following features:

  • based on source code rather than prebuilt binaries
  • build system having a native concept of subproject embedding
  • multiplatform
  • fully open source and community-driven, no CLAs

Q: What about subprojects that themselves use subprojects?
A: This is fully supported of course. If you have two subprojects that use a common subsubproject, Meson will automatically detect this and do the right thing.

Q: What if I’m too lazy to search projects through the web ui?
A: We are working on a client that allows you to search and add subprojects directly from the command line.

Q: Can I run an internal version of the server for mirroring and keeping my internal projects?
A: Sure, the code is available. You might not even need the server, though, because hosting wrap files only requires putting a few files on an intranet server. Wrap also supports using Git checkouts as subprojects.

P.S. Original post (doesn’t have my thoughts and histories) is in maillist.

P.P.S. Web interface for Wrap DB is not good, we will make it nicer in the near future ;)

Python q

q is python module for Quick-and-dirty debugging output for tired programmers. Did you know about it? Toshio Kuratomi said about q yesterday and I use it now everywhere when I’m trying to debug things.

It allow you to easy print variables, function arguments, function returns to temp file when you executing code. Let’s see example:

#!/usr/bin/env python3
import q

@q
def q_test(var1=None, var2=None):
    print(q|var1 + var2)

def main():
    s = {'test': list(range(6))}
    q_test('arg', 'next')
    q.q(s)

if __name__ == '__main__':
    main()

After execution /tmp/q looks like:
Python q output

Meson and 3rd party dependencies. Only one correct way

Intro

As you know, many projects bundling libs (including source code of 3rd party libs). For example, SuperTuxKart bundles angelscript, bullet, enet, glew, irrlicht, jpeglib, libpng, wiiuse, zlib. All of this libs package in my favorite distro Fedora.

As Fedora maintainer I need to check what changed in bundled libs code, if nothing – write patch to use system lib, if few changes – write patch to use system lib and report bug against this lib in Fedora, if big changes – try to understand what changed, why it’s not in upstream, create FPC ticket and they will accept bundle – use bundle. If all devs will allow to use system libs – this will be great (0 A.D. and Xonotic does this). Yes, this is also cross-platform games.

In CMake I need to write custom FindSomething.cmake and fix some things in CMakeLists.txt. Providing switch between system and bundled sources is not easy. For example, in stuntrally to unbundle ~ 50% of libs I should Showing 49 changed files with 238 additions and 108 deletions. I hate it.

In Autotools I never tried to do this, I think I will kill myself if will try.

With Meson it’s really simple. Meson is designed to be simple for developers, maintainers and fast. Hi to m4 and that black magic.

I don’t want to write more here, please read manual at official meson wiki. Much better to see real example.

Example

If we don’t have library in system (I renamed libenet to libent to not delete enet from my system):
Meson wrap bundled
If we have library in system:
Meson wrap system

Feedback

Please do not hesitate to contact us via IRC (#mesonbuild on freenode) or send patches/issues via GitHub (https://github.com/jpakkane/meson)

P.S. When I wrote this example I found some missing functionality and minor bugs and sent patches[1][2]. If you want to try this example – you need apply those patches.

SuperTuxKart 0.9 landed in Fedora

As you probably noticed that SuperTuxKart 0.9 released ~ 1 month ago. I tried to build it in the same day, but build failed on ARM architecture. I looked at build logs and found that they again added another bundled library – angelscript. I didn’t have time to fix it, but I got some free days in this week. I added new package with angelscript in Fedora and built new version of supertuxkart today for rawhide and will do the same for F22 at next week.
SuperTuxKart 0.9

If you are interested – please read more long story..
Continue reading →

css.php