chrisjbillington / git-nautilus-icons

A nautilus Python extension to overlay icons on files in git repositories
BSD 2-Clause "Simplified" License
43 stars 4 forks source link

Installing on FreeBSD without a "regular" desktop environment #16

Closed Niklas81 closed 3 years ago

Niklas81 commented 3 years ago

I'm running FreeBSD with Openbox loaded through ~/.xinitrc by calling exec dbus-launch openbox-session at the end of it, rather than installing a full-blown desktop environment like Gnome / Cinnamon / MATE.

Launching Openbox this way fixed a number of issues, e.g. the trashcan and allowing me to change folder icons.

What remains is getting Nemo extensions to work, this one in particular.

I have managed to install all Python dependencies, so that calling pip list gives me a list that includes the following python packages:

git-nautilus-icons  2.0.0
NEMO                3.8.0
pip                 20.2.3
PyGObject           3.38.0

Running ls -la -R in /usr/home/niklas/.local/share/nemo-python then produces this:

total 5
drwxr-xr-x   3 niklas  niklas   3 mars  9 14:51 .
drwxr-xr-x  16 niklas  niklas  19 mars  9 14:39 ..
drwxr-xr-x   3 niklas  niklas   4 mars  9 14:51 extensions

./extensions:
total 38
drwxr-xr-x  2 niklas  niklas      3 mars  9 14:51 __pycache__
drwxr-xr-x  3 niklas  niklas      4 mars  9 14:51 .
drwxr-xr-x  3 niklas  niklas      3 mars  9 14:51 ..
-rw-r--r--  1 niklas  niklas  33785 mars  9 14:51 git-nautilus-icons.py

./extensions/__pycache__:
total 24
drwxr-xr-x  2 niklas  niklas      3 mars  9 14:51 .
drwxr-xr-x  3 niklas  niklas      4 mars  9 14:51 ..
-rw-r--r--  1 niklas  niklas  20809 mars  9 14:51 git-nautilus-icons.cpython-37.pyc

Running python git-nautilus-icons.py in /home/niklas/.local/share/nemo-python/extensions then produces:

  File "git-nautilus-icons.py", line 44, in <module>
    gi.require_version('Nautilus', '3.0')
  File "/usr/local/lib/python3.7/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Nautilus not available

However, modifying git-nautilus-icons.py like so:

# A string in sys.argv so that the worker process can identify itself:
WORKER_ARG = 'git-nautilus-icons-worker'
if WORKER_ARG not in sys.argv:
    # Only import the extension modules if we are not the worker process
    if sys.argv[0] == 'nemo':
        gi.require_version('Nemo', '3.0')
        from gi.repository import Nemo as Nautilus
    elif sys.argv[0] == 'caja':
        gi.require_version('Caja', '2.0')
        from gi.repository import Caja as Nautilus
    else:
        gi.require_version('Nemo', '3.0')
        from gi.repository import Nemo as Nautilus

This enables me to run it in command line like python git-nautilus-icons.py without any errors or output at all. I didn't understand how else to run it..

In either case, git-nautilus-icons doesn't show up in Nemo's list of extensions, and there are no git status icons shown when cloning a git repo to a local folder; in other words, I cannot get it to work.

How can I install it so I don't have to modify it, and how can I get Nemo to detect it? Or in other words, how can I get it to work? I really need this...

chrisjbillington commented 3 years ago

Though I haven't tested on freeBSD, if Nemo and Python are otherwise working, it should work. Whether you are running a "full" desktop environment or not should not be relevant.

One does not run the extension file directly, instead Nemo will run it itself (and you will not need to make these changes to the extension file).

You may be be missing the nemo python extension module. On Ubuntu for example this is called python3-nemo in the Ubuntu repositories. I don't think it is on PyPI, and I don't know what package managers FreeBSD has, so I can't provide advice on where to get it, but presumably you can get it in the same way that you got Nemo itself.

chrisjbillington commented 3 years ago

Oh sorry, I do see that you have NEMO as a Python package listed by pip. (I wouldn't have expected it in all caps - you sure that's the right package?)

In that case, I am unsure what's wrong. Do no other extensions work? Do you see any errors printed to the terminal when running Nemo from the command line?

chrisjbillington commented 3 years ago

Indeed, NEMO is unrelated to the file manager:

https://pypi.org/project/NEMO/

So yep, you'll need to install the nemo python extension module, which you can probably obtain from wherever you got Nemo itself, and not with pip.

Niklas81 commented 3 years ago

Thank you so much for your response! This is the first extension I'm trying to install, as it is the most important one for me. There is a nemo-extensions package available as well, which indeed includes the actual nemo package I need to make Nemo run your and a bunch of other extensions. That itself depends on ninja for building, which is available on FreeBSD, so I believe I can get this to work. Never would have any grip on what to do without your answers, much appriciated! Will get the buildprocess by looking at Arch Linux package for nemo-extensions.

I'll keep this open until I've fixed it! ;)

chrisjbillington commented 3 years ago

Good to hear and best of luck!

Niklas81 commented 3 years ago

Ok, so I managed to build the file libnemo-python.so, but it's still not working. When running meson it gave two complaints:

Did not find CMake 'cmake'
Found CMake: NO

and:

Run-time dependency python3-embed found: NO (tried pkgconfig and cmake)

I installed CMake before running ninja, and running ninja seems to have gone smooth:

niklas@TP50:/usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build ninja
[3/3] Linking target src/libnemo-python.so

I also ran sudo ninja install:

niklas@TP50:/usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build sudo ninja install
[0/1] Installing files.
Installing src/libnemo-python.so to /usr/local/lib/nemo/extensions-3.0
Installing /usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build/nemo-python.pc to /usr/lib/pkgconfig

Contents of /usr/lib/pkgconfig/nemo-python.pc:

Name: Nemo-Python
Description: Nemo-Python Components
Version: 4.8.0

prefix=/usr
libdir=${prefix}/lib
pythondir=${prefix}/share/nemo-python/extensions

But I probably need to install the run-time dependency python3-embed. Any idea how to do that?

I might add, I didn't fully understand what I was doing, reading the PKGBUILD from Arch Linux's AUR.. (https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=nemo-extensions-git) But it built the file libnemo-python.so (without me stating what file to build) and put it in a folder which I didn't specify - so something must have gone right?

Full output when running meson below:

niklas@TP50:/usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build meson --prefix=/usr \
                --libexecdir=/usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python \
                --buildtype=plain
The Meson build system
Version: 0.57.1
Source dir: /usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python
Build dir: /usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build
Build type: native build
Project name: python-nemo
Project version: 4.8.0
C compiler for the host machine: cc (clang 11.0.1 "FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)")
C linker for the host machine: cc ld.lld 11.0.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/local/bin/pkg-config (1.7.3)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency python3-embed found: NO (tried pkgconfig and cmake)
Run-time dependency python3 found: YES 3.7
Run-time dependency libnemo-extension found: YES 4.8.3
Run-time dependency pygobject-3.0 found: YES 3.38.0
Run-time dependency gtk+-3.0 found: YES 3.24.24
Run-time dependency glib-2.0 found: YES 2.66.7
Configuring config.h using configuration
Configuring nemo-python.pc using configuration
Message: |....................................................................
Message: |
Message: |  nemo-python version: 4.8.0
Message: |
Message: |  python version: 3.7
Message: |  targeting lib: /usr/lib/libpython3.7m.so.1.0
Message: |
Message: |  build docs: false
Message: |
Message: |  python extension dir: /usr/local/lib/nemo/extensions-3.0
Message: |
Message: |....................................................................
Build targets in project: 1

Found ninja-1.10.2 at /usr/local/bin/ninja
niklas@TP50:/usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build pkg search cmake
cmake-3.19.6                   Cross-platform Makefile generator
cmake-doc-3.19.6               HTML and Qt Creator helpfiles for CMake
cmake-fedora-2.9.2             Set of cmake modules for fedora developers
cmake-gui-3.19.6               Qt-based GUI for CMake
cmake-modules-webos-1.0.b      CMake modules needed to build WebOS components
gccmakedep-1.0.3               Create dependencies in makefiles using 'gcc -M'
icmake-9.02.08                 Intelligent C-like Maker
ignition-cmake-2.0.0           CMake modules to be used by the Ignition projects
kf5-extra-cmake-modules-5.79.0 Extra modules and scripts for CMake
kms-cmake-utils-6.15.0_1       CMake common files used to build all Kurento C/C++ projects
py37-cmakedoc-1.0.1            Command-line tool to read CMake documentation
niklas@TP50:/usr/home/niklas/Hämtningar/nemo-extensions-master/nemo-python/build sudo pkg install cmake
Lösenord:
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    cmake: 3.19.6
    rhash: 1.4.1

Number of packages to be installed: 2

The process will require 31 MiB more space.
6 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/2] Fetching cmake-3.19.6.txz: 100%    5 MiB   5.7MB/s    00:01
[2/2] Fetching rhash-1.4.1.txz: 100%  220 KiB 225.0kB/s    00:01
Checking integrity... done (0 conflicting)
[1/2] Installing rhash-1.4.1...
[1/2] Extracting rhash-1.4.1: 100%
[2/2] Installing cmake-3.19.6...
[2/2] Extracting cmake-3.19.6: 100%
Niklas81 commented 3 years ago

This might also help: https://cmake.org/cmake/help/latest/module/FindPython3.html

mtwebster commented 3 years ago

Python3-embed is optional, ignore it (it's for older python versions I think).

Installing src/libnemo-python.so to /usr/local/lib/nemo/extensions-3.0

I'm not familiar with your distro - did you build nemo or is it an existing package? Typically we use /usr as a prefix (not /usr/local) - nemo - like meson --prefix=/usr mybuilddir (this applies to all of our packages, and is typically required due to how most C libraries we use are utilized by python).

Check the output of:

pkg-config --variable=extensiondir libnemo-extension

That's the folder libnemo-python.so needs to go into. If it's not there, your python extensions won't get loaded.

Niklas81 commented 3 years ago

I fixed it, see https://github.com/linuxmint/nemo-extensions/issues/401