Nixpkgs: Package request: Ulauncher

Created on 25 Nov 2018  路  12Comments  路  Source: NixOS/nixpkgs

Ulauncher is an application launcher for Linux: https://ulauncher.io/

Tried to package it myself but I am a rookie and this seems like a bit painful for the first package.

GNOME package (new)

Most helpful comment

For those interested I made a derivation really quick.

However, if you build and execute it you'll realize there's definitely some problems.

All 12 comments

For those interested I made a derivation really quick.

However, if you build and execute it you'll realize there's definitely some problems.

More specifically, the first error I run into halts with the following stack trace:

Copying ulauncher.egg-info to build/bdist.linux-x86_64/wheel/ulauncher-_VERSION_-py2.7.egg-info
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
adding license file "AUTHORS" (matched pattern "AUTHORS*")
creating build/bdist.linux-x86_64/wheel/ulauncher-_VERSION_.dist-info/WHEEL
Traceback (most recent call last):
  File "nix_run_setup", line 8, in <module>
    exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
  File "setup.py", line 243, in <module>
    main()
  File "setup.py", line 235, in main
    cmdclass={'install': InstallAndUpdateDataDirectory}
  File "/nix/store/7gw78g26sz38kvwahbaba1x0ya426aa5-python2.7-distutils-extra-2.39/lib/python2.7/site-packages/DistUtilsExtra/auto.py", line 100, in setup
    distutils.core.setup(**attrs)
  File "/nix/store/5qm63py6n4bqhfmyb5nbvzf545arymwz-python-2.7.15/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/nix/store/5qm63py6n4bqhfmyb5nbvzf545arymwz-python-2.7.15/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/nix/store/5qm63py6n4bqhfmyb5nbvzf545arymwz-python-2.7.15/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/nix/store/hm8pfhfx85crksv99slgam8imvmh2pgg-python2.7-bootstrapped-pip-18.1/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 246, in run
    with WheelFile(wheel_path, 'w') as wf:
  File "/nix/store/hm8pfhfx85crksv99slgam8imvmh2pgg-python2.7-bootstrapped-pip-18.1/lib/python2.7/site-packages/wheel/wheelfile.py", line 40, in __init__
    raise WheelError("Bad wheel filename {!r}".format(basename))
wheel.cli.WheelError: Bad wheel filename 'ulauncher-_VERSION_-py2-none-any.whl'
builder for '/nix/store/07dd78v31ndz0mnj0g2z76lz5xhrfh8c-ulauncher-4.3.1.r4.drv' failed with exit code 1

Any ideas for workarounds?

If you just examine the result of the derivation you'll notice that things in $out/lib appear to be in the wrong locations. So that'll definitely make it not work.

There's probably something wrong with DistUtilsExtra.auto.setup and I don't think distutils_extra is maintained. So perhaps we can just change the build system if it's easy?

Maybe do what gnome-music is doing.

Looking at the beginning of the build log, I noticed:

/nix/store/hm8pfhfx85crksv99slgam8imvmh2pgg-python2.7-bootstrapped-pip-18.1/lib/python2.7/site-packages/setuptools/dist.py:407: UserWarning: The version specified ('%VERSION%') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
  "details." % self.metadata.version

Note that it thinks the version is %VERSION%.
Maybe this has to do with setup.py#L195?

DistUtilsExtra.auto.setup(
        name='ulauncher',
        version='%VERSION%',
        license='GPL-3',
        author='Aleksandr Gornostal',
        author_email='[email protected]',
        description='Application launcher for Linux',
        url='http://ulauncher.io',
[...]

I assume that %VERSION% is supposed to be replaced with something else at setup.py#L120

class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
    def run(self):
        DistUtilsExtra.auto.install_auto.run(self)

        target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
        target_pkgdata = target_data + 'share/ulauncher/'
        target_scripts = '/' + os.path.relpath(self.install_scripts,
                                               self.root) + '/'

        values = {'__ulauncher_data_directory__': "'%s'" % (target_pkgdata),
                  '__version__': "'%s'" % self.distribution.get_version()}
        update_config(self.install_lib, values)

        desktop_file = move_desktop_file(self.root, target_data, self.prefix)
        update_desktop_file(desktop_file, target_pkgdata, target_scripts)

But clearly something is not working. That's all I've got. Cheers

Very late edit, I managed to change this after the build via:

  fixupPhase = ''
  substituteInPlace $out/lib/python2.7/site-packages/ulauncher/config.py --replace "/ulauncher-4.3.1.post4.data/data" "$out"
  '';

But last executable still cries:

Traceback (most recent call last):
  File "/nix/store/swibhfni1iys81y4fsvqzp5jw1aaqn31-ulauncher/bin/ulauncher", line 27, in <module>
    from ulauncher.main import main
ImportError: No module named ulauncher.main

@seqizz Would you mind sharing your full nix expression?

I can't figure out how to get past the _VERSION_ issue. (I suspect you replaced it in config.py?)

Yes, but I did it after the build. Here is the last status (which is a wreck with too many unnecessary stuff probably, I gave up after trying a bit).

I'm not sure how to implement this in Nix, but we can get past the No module named ulauncher.main error by setting the PYTHONPATH environment variable to the generated site-packages folder (as done in bin/ulauncher).

In other words:

$ export out=/nix/store/16k13ils9hd2z10q98vz1jzirhqs7pyy-ulauncher-4.3.1.r4
$ PYTHONPATH=$out/lib/python2.7/site-packages/ $out/bin/ulauncher
Traceback (most recent call last):
  File "/nix/store/16k13ils9hd2z10q98vz1jzirhqs7pyy-ulauncher-4.3.1.r4/bin/ulauncher", line 27, in <module>
    from ulauncher.main import main
  File "/nix/store/16k13ils9hd2z10q98vz1jzirhqs7pyy-ulauncher-4.3.1.r4/lib/python2.7/site-packages/ulauncher/main.py", line 9, in <module>
    import gi
ImportError: No module named gi

We still get an error but I think this is a step forward?

:) I guess. I am still rookie on nixland and this made me confused since we have gobjectIntrospection defined under everything like crazy.

Just so we are on the same page, this is what I am currently using to build ulauncher: gist

I replaced the version substitution code to put the version number where I think the ulauncher source code intends for it to be put. Doing so does not break the build.

- substituteInPlace setup.py --replace "%VERSION%" "${version}"
+ substituteInPlace ulauncher/config.py --replace "VERSION" "${version}"

The ImportError: no package named gi means that the pgi python module is missing.

I'm working on creating a derivation to package pgi.

I've run into https://github.com/NixOS/nixpkgs/issues/7307, meaning that I needed to make a patch to load a few libraries with using _absolute_ paths.

I'm using the following to apply the patches:

patches = [
  (substituteAll {
    src = ./cdll.patch;
    ext = stdenv.hostPlatform.extensions.sharedLibrary;
    glib = glib.out;
    girepository = gnome3.gobjectIntrospection.out;
  })
];

Applying the patches is the only way I was able to manage getting pgi to build.

The patch was applied with substituteAll during build time. During runtime, however, the patch was applied, but without substitutions:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "pgi/__init__.py", line 10, in <module>
    from .importer import require_version, get_required_version
  File "pgi/importer.py", line 15, in <module>
    from .clib.gir import GIRepository
  File "pgi/clib/gir/__init__.py", line 8, in <module>
    from .giargument import GIArgument
  File "pgi/clib/gir/giargument.py", line 9, in <module>
    from ..glib import gboolean, gint8, guint8, gint16, guint16, gint32, guint32
  File "pgi/clib/glib.py", line 16, in <module>
    _glib = find_library("glib-2.0")
  File "pgi/clib/_utils.py", line 106, in find_library
    _internal[name] = CDLL(path)
  File "/nix/store/8s2bnyl956lhfcjmrrjy5albjki9i9vl-python-2.7.15-env/lib/python2.7/ctypes/__init__.py", line 366, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: @glib@/lib/libglib-2.0@ext@: cannot open shared object file: No such file or directory

How do we get the patch substitutions working for runtime?

gi module is provided by python3.pkgs.pygobject3 which we already have packaged. pgi definitely should not be used.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

retrry picture retrry  路  3Comments

rzetterberg picture rzetterberg  路  3Comments

tomberek picture tomberek  路  3Comments

chris-martin picture chris-martin  路  3Comments

lverns picture lverns  路  3Comments