qtile: 0.16.0 -> 0.18.0

- Remove patches, to make it more update friendly
- Use python.withPackages to export environment
This commit is contained in:
Jonathan Ringer 2021-08-19 11:09:30 -07:00 committed by Jonathan Ringer
parent b097cb918f
commit 3cfa38874a
4 changed files with 62 additions and 177 deletions

View File

@ -1,31 +0,0 @@
diff --git a/libqtile/backend/x11/xcursors.py b/libqtile/backend/x11/xcursors.py
index 24454b83..ef37875c 100644
--- a/libqtile/backend/x11/xcursors.py
+++ b/libqtile/backend/x11/xcursors.py
@@ -107,7 +107,7 @@ class Cursors(dict):
def _setup_xcursor_binding(self):
try:
- xcursor = ffi.dlopen('libxcb-cursor.so.0')
+ xcursor = ffi.dlopen('@xcb-cursor@/lib/libxcb-cursor.so.0')
except OSError:
logger.warning("xcb-cursor not found, fallback to font pointer")
return False
diff --git a/libqtile/pangocffi.py b/libqtile/pangocffi.py
index dbae27ed..54c2c35f 100644
--- a/libqtile/pangocffi.py
+++ b/libqtile/pangocffi.py
@@ -52,10 +52,9 @@ try:
except ImportError:
raise ImportError("No module named libqtile._ffi_pango, be sure to run `./scripts/ffibuild`")
-gobject = ffi.dlopen('libgobject-2.0.so.0')
-pango = ffi.dlopen('libpango-1.0.so.0')
-pangocairo = ffi.dlopen('libpangocairo-1.0.so.0')
-
+gobject = ffi.dlopen('@glib@/lib/libgobject-2.0.so.0')
+pango = ffi.dlopen('@pango@/lib/libpango-1.0.so.0')
+pangocairo = ffi.dlopen('@pango@/lib/libpangocairo-1.0.so.0')
def patch_cairo_context(cairo_t):
def create_layout():

View File

@ -1,71 +0,0 @@
diff --git a/bin/qshell b/bin/qshell
index 5c652b7a..2d169eb2 100755
--- a/bin/qshell
+++ b/bin/qshell
@@ -28,5 +28,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.insert(0, base_dir)
if __name__ == '__main__':
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
from libqtile.scripts import qshell
qshell.main()
diff --git a/bin/qtile b/bin/qtile
index ebc8fab5..08a965ef 100755
--- a/bin/qtile
+++ b/bin/qtile
@@ -29,5 +29,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.insert(0, base_dir)
if __name__ == '__main__':
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
from libqtile.scripts import qtile
qtile.main()
diff --git a/bin/qtile-cmd b/bin/qtile-cmd
index a2136ee6..3d37a6d9 100755
--- a/bin/qtile-cmd
+++ b/bin/qtile-cmd
@@ -8,5 +8,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.insert(0, base_dir)
if __name__ == '__main__':
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
from libqtile.scripts import qtile_cmd
qtile_cmd.main()
diff --git a/bin/qtile-run b/bin/qtile-run
index ac4cb1fd..74c589cb 100755
--- a/bin/qtile-run
+++ b/bin/qtile-run
@@ -8,5 +8,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.insert(0, base_dir)
if __name__ == '__main__':
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
from libqtile.scripts import qtile_run
qtile_run.main()
diff --git a/bin/qtile-top b/bin/qtile-top
index a6251f27..0d524b1d 100755
--- a/bin/qtile-top
+++ b/bin/qtile-top
@@ -8,5 +8,6 @@ base_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.insert(0, base_dir)
if __name__ == '__main__':
+ __import__("importlib").import_module("libqtile.utils").restore_os_environment()
from libqtile.scripts import qtile_top
qtile_top.main()
diff --git a/libqtile/utils.py b/libqtile/utils.py
index 2628c898..05117be7 100644
--- a/libqtile/utils.py
+++ b/libqtile/utils.py
@@ -270,3 +270,10 @@ def guess_terminal():
return terminal
logger.error('Default terminal has not been found.')
+
+def restore_os_environment():
+ pythonpath = os.environ.pop("QTILE_SAVED_PYTHONPATH", "")
+ os.environ["PYTHONPATH"] = pythonpath
+ path = os.environ.pop("QTILE_SAVED_PATH", None)
+ if path:
+ os.environ["PATH"] = path

View File

@ -1,13 +0,0 @@
diff --git a/libqtile/core/manager.py b/libqtile/core/manager.py
index c22eeb6a..2ffe4eab 100644
--- a/libqtile/core/manager.py
+++ b/libqtile/core/manager.py
@@ -278,7 +278,7 @@ class Qtile(CommandObject):
logger.error("Unable to pickle qtile state")
argv = [s for s in argv if not s.startswith('--with-state')]
argv.append('--with-state=' + buf.getvalue().decode())
- self._restart = (sys.executable, argv)
+ self._restart = (os.environ.get("QTILE_WRAPPER", "@out@/bin/qtile"), argv[1:])
self.stop()
async def finalize(self):

View File

@ -1,66 +1,66 @@
{ lib, fetchFromGitHub, python37Packages, glib, cairo, pango, pkg-config, libxcb, xcbutilcursor }:
{ lib, fetchFromGitHub, python3, glib, cairo, pango, pkg-config, libxcb, xcbutilcursor }:
let cairocffi-xcffib = python37Packages.cairocffi.override {
let
enabled-xcffib = cairocffi-xcffib: cairocffi-xcffib.override {
withXcffib = true;
};
# make it easier to reference python
python = python3;
pythonPackages = python.pkgs;
unwrapped = pythonPackages.buildPythonPackage rec {
name = "qtile-${version}";
version = "0.18.0";
src = fetchFromGitHub {
owner = "qtile";
repo = "qtile";
rev = "v${version}";
sha256 = "sha256-S9G/EI18p9EAyWgI1ajDrLimeE+ETBC9feUDb/QthqI=";
};
postPatch = ''
substituteInPlace libqtile/pangocffi.py \
--replace libgobject-2.0.so.0 ${glib.out}/lib/libgobject-2.0.so.0 \
--replace libpangocairo-1.0.so.0 ${pango.out}/lib/libpangocairo-1.0.so.0 \
--replace libpango-1.0.so.0 ${pango.out}/lib/libpango-1.0.so.0
substituteInPlace libqtile/backend/x11/xcursors.py \
--replace libxcb-cursor.so.0 ${xcbutilcursor.out}/lib/libxcb-cursor.so.0
'';
SETUPTOOLS_SCM_PRETEND_VERSION = version;
nativeBuildInputs = [
pkg-config
] ++ (with pythonPackages; [
setuptools-scm
]);
propagatedBuildInputs = with pythonPackages; [
xcffib
(enabled-xcffib cairocffi)
setuptools
python-dateutil
dbus-python
mpd2
psutil
pyxdg
pygobject3
];
doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure.
meta = with lib; {
homepage = "http://www.qtile.org/";
license = licenses.mit;
description = "A small, flexible, scriptable tiling window manager written in Python";
platforms = platforms.linux;
maintainers = with maintainers; [ kamilchm ];
};
};
in
python37Packages.buildPythonApplication rec {
name = "qtile-${version}";
version = "0.16.0";
src = fetchFromGitHub {
owner = "qtile";
repo = "qtile";
rev = "v${version}";
sha256 = "1klv1k9847nyx71sfrhqyl1k51k2w8phqnp2bns4dvbqii7q125l";
};
patches = [
./0001-Substitution-vars-for-absolute-paths.patch
./0002-Restore-PATH-and-PYTHONPATH.patch
./0003-Restart-executable.patch
];
postPatch = ''
substituteInPlace libqtile/core/manager.py --subst-var-by out $out
substituteInPlace libqtile/pangocffi.py --subst-var-by glib ${glib.out}
substituteInPlace libqtile/pangocffi.py --subst-var-by pango ${pango.out}
substituteInPlace libqtile/backend/x11/xcursors.py --subst-var-by xcb-cursor ${xcbutilcursor.out}
'';
SETUPTOOLS_SCM_PRETEND_VERSION = version;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ glib libxcb cairo pango python37Packages.xcffib ];
pythonPath = with python37Packages; [
xcffib
cairocffi-xcffib
setuptools
setuptools-scm
python-dateutil
dbus-python
mpd2
psutil
pyxdg
pygobject3
];
postInstall = ''
wrapProgram $out/bin/qtile \
--run 'export QTILE_WRAPPER=$0' \
--run 'export QTILE_SAVED_PYTHONPATH=$PYTHONPATH' \
--run 'export QTILE_SAVED_PATH=$PATH'
'';
doCheck = false; # Requires X server #TODO this can be worked out with the existing NixOS testing infrastructure.
meta = with lib; {
homepage = "http://www.qtile.org/";
license = licenses.mit;
description = "A small, flexible, scriptable tiling window manager written in Python";
platforms = platforms.linux;
maintainers = with maintainers; [ kamilchm ];
};
}
(python.withPackages (ps: [ unwrapped ])).overrideAttrs (_: {
# export underlying qtile package
passthru = { inherit unwrapped; };
})