From a33c17a25b2c4ee5a5747dd77a51dac940258f3a Mon Sep 17 00:00:00 2001
From: tfuxu <73042332+tfuxu@users.noreply.github.com>
Date: Tue, 13 Sep 2022 18:29:43 +0200
Subject: [PATCH 1/6] feat: local build support
---
.gitignore | 2 ++
Makefile | 2 +-
build-aux/meson_post_install.py | 9 ++++++
data/meson.build | 2 +-
data/ui/meson.build | 2 +-
{src => gradience}/__init__.py | 0
{src => gradience}/app_type_dialog.py | 0
{src => gradience}/builtin_preset_row.py | 0
{src => gradience}/constants.py.in | 0
{src => gradience}/custom_css_group.py | 0
{src => gradience}/error.py | 0
{src => gradience}/explore_preset_row.py | 0
{src => gradience}/gradience.in | 31 +++++++++----------
{src => gradience}/main.py | 0
{src => gradience}/meson.build | 10 ++++--
{src => gradience}/modules/__init__.py | 0
{src => gradience}/modules/css.py | 0
{src => gradience}/modules/custom_presets.py | 0
.../modules/flatpak_overrides.py | 0
{src => gradience}/modules/run_async.py | 0
{src => gradience}/modules/utils.py | 0
{src => gradience}/option.py | 0
{src => gradience}/palette_shades.py | 0
{src => gradience}/plugin.py | 0
{src => gradience}/plugin_row.py | 0
{src => gradience}/plugins_list.py | 0
{src => gradience}/preferences.py | 0
{src => gradience}/preset_row.py | 0
{src => gradience}/presets_manager_window.py | 0
{src => gradience}/repo_row.py | 0
{src => gradience}/setting.py | 0
{src => gradience}/settings_schema.py | 0
{src => gradience}/welcome.py | 2 +-
{src => gradience}/window.py | 0
local.sh | 11 +++++--
meson.build | 19 +++++++++++-
requirements.txt | 2 ++
37 files changed, 64 insertions(+), 28 deletions(-)
create mode 100644 build-aux/meson_post_install.py
rename {src => gradience}/__init__.py (100%)
rename {src => gradience}/app_type_dialog.py (100%)
rename {src => gradience}/builtin_preset_row.py (100%)
rename {src => gradience}/constants.py.in (100%)
rename {src => gradience}/custom_css_group.py (100%)
rename {src => gradience}/error.py (100%)
rename {src => gradience}/explore_preset_row.py (100%)
rename {src => gradience}/gradience.in (71%)
rename {src => gradience}/main.py (100%)
rename {src => gradience}/meson.build (88%)
rename {src => gradience}/modules/__init__.py (100%)
rename {src => gradience}/modules/css.py (100%)
rename {src => gradience}/modules/custom_presets.py (100%)
rename {src => gradience}/modules/flatpak_overrides.py (100%)
rename {src => gradience}/modules/run_async.py (100%)
rename {src => gradience}/modules/utils.py (100%)
rename {src => gradience}/option.py (100%)
rename {src => gradience}/palette_shades.py (100%)
rename {src => gradience}/plugin.py (100%)
rename {src => gradience}/plugin_row.py (100%)
rename {src => gradience}/plugins_list.py (100%)
rename {src => gradience}/preferences.py (100%)
rename {src => gradience}/preset_row.py (100%)
rename {src => gradience}/presets_manager_window.py (100%)
rename {src => gradience}/repo_row.py (100%)
rename {src => gradience}/setting.py (100%)
rename {src => gradience}/settings_schema.py (100%)
rename {src => gradience}/welcome.py (99%)
rename {src => gradience}/window.py (100%)
diff --git a/.gitignore b/.gitignore
index 2c4d807e..3a915a31 100644
--- a/.gitignore
+++ b/.gitignore
@@ -214,3 +214,5 @@ cython_debug/
.vscode/
flatpak-pip-generator
+
+gradience/constants.py
diff --git a/Makefile b/Makefile
index fa0a6bf2..54fe8032 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,6 @@ global:
sudo ninja -C builddir install
user:
- meson builddir --prefix="$(shell pwd)/builddir/testdir" --wipe
+ meson builddir --prefix="$(shell pwd)/builddir" --buildtype=debug --wipe
ninja -C builddir install
ninja -C builddir run
\ No newline at end of file
diff --git a/build-aux/meson_post_install.py b/build-aux/meson_post_install.py
new file mode 100644
index 00000000..5a61fc2d
--- /dev/null
+++ b/build-aux/meson_post_install.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+build_root = os.environ.get('MESON_BUILD_ROOT')
+source_root = os.environ.get('MESON_SOURCE_ROOT')
+
+subprocess.call(['mv', build_root, 'gradience/constants.py', source_root, 'gradience/constants.py'])
diff --git a/data/meson.build b/data/meson.build
index e4e1e3d2..8c296d23 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -28,7 +28,7 @@ gnome.compile_resources('gradience',
source_dir: meson.current_build_dir(),
install: true,
install_dir: PKGDATA_DIR,
- dependencies: blueprints,
+ dependencies: blueprints
)
appstream_file = i18n.merge_file(
diff --git a/data/ui/meson.build b/data/ui/meson.build
index 6828ee77..740733de 100644
--- a/data/ui/meson.build
+++ b/data/ui/meson.build
@@ -16,5 +16,5 @@ blueprints = custom_target('blueprints',
'repo_row.blp',
),
output: '.',
- command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
+ command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@']
)
diff --git a/src/__init__.py b/gradience/__init__.py
similarity index 100%
rename from src/__init__.py
rename to gradience/__init__.py
diff --git a/src/app_type_dialog.py b/gradience/app_type_dialog.py
similarity index 100%
rename from src/app_type_dialog.py
rename to gradience/app_type_dialog.py
diff --git a/src/builtin_preset_row.py b/gradience/builtin_preset_row.py
similarity index 100%
rename from src/builtin_preset_row.py
rename to gradience/builtin_preset_row.py
diff --git a/src/constants.py.in b/gradience/constants.py.in
similarity index 100%
rename from src/constants.py.in
rename to gradience/constants.py.in
diff --git a/src/custom_css_group.py b/gradience/custom_css_group.py
similarity index 100%
rename from src/custom_css_group.py
rename to gradience/custom_css_group.py
diff --git a/src/error.py b/gradience/error.py
similarity index 100%
rename from src/error.py
rename to gradience/error.py
diff --git a/src/explore_preset_row.py b/gradience/explore_preset_row.py
similarity index 100%
rename from src/explore_preset_row.py
rename to gradience/explore_preset_row.py
diff --git a/src/gradience.in b/gradience/gradience.in
similarity index 71%
rename from src/gradience.in
rename to gradience/gradience.in
index a4368333..698f68a1 100755
--- a/src/gradience.in
+++ b/gradience/gradience.in
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!/usr/bin/env python3
# gradience.in
#
@@ -9,12 +9,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
@@ -24,18 +24,20 @@ import signal
import locale
import gettext
+is_local = @local_build@
+
+if is_local:
+ # In the local use case, use gradience module from the sourcetree
+ sys.path.insert(1, '@PYTHON@')
+
+ # In the local use case the installed schemas go in /data
+ os.environ["XDG_DATA_DIRS"] = '@SCHEMAS_DIR@:' + os.environ.get("XDG_DATA_DIRS", "")
+
pkgdatadir = '@PKGDATA_DIR@'
localedir = '@LOCALE_DIR@'
-builddir = os.environ.get('MESON_BUILD_ROOT')
+sys.dont_write_bytecode = True
-if builddir:
- sys.dont_write_bytecode = True
- sys.path.insert(1, os.environ['MESON_SOURCE_ROOT'])
- data_dir = os.path.join(builddir, '@DATA_DIR@')
- os.putenv('XDG_DATA_DIRS', '%s:%s' % (data_dir, os.getenv('XDG_DATA_DIRS', '/usr/local/share/:/usr/share/')))
-
-sys.path.insert(1, pkgdatadir)
signal.signal(signal.SIGINT, signal.SIG_DFL)
gettext.install('gradience', localedir)
@@ -51,15 +53,10 @@ if __name__ == '__main__':
gi.require_version('Xdp', '1.0')
gi.require_version('XdpGtk4', '1.0')
- if '@BUILD_TYPE@' == "debug":
- sys.path.append("/usr/local/local/lib/python3.10/site-packages")
-
from gi.repository import Gio
resource = Gio.Resource.load(
os.path.join(pkgdatadir, 'gradience.gresource'))
- resource._register()
-
- sys.path.append("/usr/local/lib/python3.10/site-packages/")
+ Gio.Resource._register(resource)
from gradience import main
sys.exit(main.main())
diff --git a/src/main.py b/gradience/main.py
similarity index 100%
rename from src/main.py
rename to gradience/main.py
diff --git a/src/meson.build b/gradience/meson.build
similarity index 88%
rename from src/meson.build
rename to gradience/meson.build
index 1e3385b9..e5f00349 100644
--- a/src/meson.build
+++ b/gradience/meson.build
@@ -2,10 +2,15 @@ configure_file(
input: 'gradience.in',
output: 'gradience',
configuration: conf,
- install: true,
install_dir: get_option('bindir')
)
+configure_file(
+ input: 'gradience.in',
+ output: 'local-gradience',
+ configuration: local_conf
+)
+
configure_file(
input: 'constants.py.in',
output: 'constants.py',
@@ -23,7 +28,7 @@ configure_file(
install_dir: PY_INSTALLDIR.get_install_dir() / 'gradience',
)
-launcher = join_paths(meson.project_build_root(), 'src', meson.project_name())
+launcher = join_paths(meson.project_build_root(), 'gradience', 'local-' + meson.project_name())
run_target('run',
command: [launcher]
@@ -54,7 +59,6 @@ gradience_sources = [
]
PY_INSTALLDIR.install_sources(gradience_sources, subdir: 'gradience')
-#install_data(gradience_sources, install_dir: MODULE_DIR)
# Install modules
gradience_modules = [
diff --git a/src/modules/__init__.py b/gradience/modules/__init__.py
similarity index 100%
rename from src/modules/__init__.py
rename to gradience/modules/__init__.py
diff --git a/src/modules/css.py b/gradience/modules/css.py
similarity index 100%
rename from src/modules/css.py
rename to gradience/modules/css.py
diff --git a/src/modules/custom_presets.py b/gradience/modules/custom_presets.py
similarity index 100%
rename from src/modules/custom_presets.py
rename to gradience/modules/custom_presets.py
diff --git a/src/modules/flatpak_overrides.py b/gradience/modules/flatpak_overrides.py
similarity index 100%
rename from src/modules/flatpak_overrides.py
rename to gradience/modules/flatpak_overrides.py
diff --git a/src/modules/run_async.py b/gradience/modules/run_async.py
similarity index 100%
rename from src/modules/run_async.py
rename to gradience/modules/run_async.py
diff --git a/src/modules/utils.py b/gradience/modules/utils.py
similarity index 100%
rename from src/modules/utils.py
rename to gradience/modules/utils.py
diff --git a/src/option.py b/gradience/option.py
similarity index 100%
rename from src/option.py
rename to gradience/option.py
diff --git a/src/palette_shades.py b/gradience/palette_shades.py
similarity index 100%
rename from src/palette_shades.py
rename to gradience/palette_shades.py
diff --git a/src/plugin.py b/gradience/plugin.py
similarity index 100%
rename from src/plugin.py
rename to gradience/plugin.py
diff --git a/src/plugin_row.py b/gradience/plugin_row.py
similarity index 100%
rename from src/plugin_row.py
rename to gradience/plugin_row.py
diff --git a/src/plugins_list.py b/gradience/plugins_list.py
similarity index 100%
rename from src/plugins_list.py
rename to gradience/plugins_list.py
diff --git a/src/preferences.py b/gradience/preferences.py
similarity index 100%
rename from src/preferences.py
rename to gradience/preferences.py
diff --git a/src/preset_row.py b/gradience/preset_row.py
similarity index 100%
rename from src/preset_row.py
rename to gradience/preset_row.py
diff --git a/src/presets_manager_window.py b/gradience/presets_manager_window.py
similarity index 100%
rename from src/presets_manager_window.py
rename to gradience/presets_manager_window.py
diff --git a/src/repo_row.py b/gradience/repo_row.py
similarity index 100%
rename from src/repo_row.py
rename to gradience/repo_row.py
diff --git a/src/setting.py b/gradience/setting.py
similarity index 100%
rename from src/setting.py
rename to gradience/setting.py
diff --git a/src/settings_schema.py b/gradience/settings_schema.py
similarity index 100%
rename from src/settings_schema.py
rename to gradience/settings_schema.py
diff --git a/src/welcome.py b/gradience/welcome.py
similarity index 99%
rename from src/welcome.py
rename to gradience/welcome.py
index 1a840262..afe31d31 100644
--- a/src/welcome.py
+++ b/gradience/welcome.py
@@ -21,7 +21,7 @@ import time
from gi.repository import Gtk, Adw, Gio
-from .run_async import RunAsync
+from .modules.run_async import RunAsync
from .modules.utils import buglog
from .modules.flatpak_overrides import (
create_gtk_user_override,
diff --git a/src/window.py b/gradience/window.py
similarity index 100%
rename from src/window.py
rename to gradience/window.py
diff --git a/local.sh b/local.sh
index 19b85fe1..5407b064 100755
--- a/local.sh
+++ b/local.sh
@@ -1,7 +1,9 @@
#!/usr/bin/bash
+
+# local.sh
#
# Change the look of Adwaita, with ease
-# Copyright (C) 2022 Gradience Team
+# Copyright (C) 2022 Gradience Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,8 +21,11 @@
read -p "Do you want to install Python requirements? (yes, no): " answer
+#is_venv = "python -c 'import sys; print(sys.prefix == sys.base_prefix)'"
+
+#if [[ "$is_venv" == "True" ]]; then
if [[ "$answer" == "yes" ]]; then
- pip3 install --user -r requirements.txt
+ pip3 install -r requirements.txt
elif [[ "$answer" == "no" ]]; then
echo "Skipping requirements installation"
fi
@@ -30,7 +35,7 @@ rm -r builddir
echo "Rebuilding"
meson builddir
-meson configure builddir -Dprefix="$(pwd)/builddir/testdir" -Dbuildtype=debug
+meson configure builddir -Dprefix="$(pwd)/builddir" -Dbuildtype=debug
ninja -C builddir install
echo "Running"
diff --git a/meson.build b/meson.build
index 6396105e..85c8b3c0 100644
--- a/meson.build
+++ b/meson.build
@@ -60,12 +60,29 @@ conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir'))
conf.set('PYTHON', PY_INSTALLDIR.full_path())
conf.set('VERSION', meson.project_version() + VERSION_SUFFIX)
conf.set('BUILD_TYPE', get_option('buildtype'))
+conf.set('SCHEMAS_DIR', PKGDATA_DIR)
+
+conf.set('local_build', 'False')
+
+# Local install configuration data
+local_conf = configuration_data()
+local_conf.set('APP_ID', APPLICATION_ID)
+local_conf.set('PKGDATA_DIR', join_paths(meson.current_build_dir(), 'data'))
+local_conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale'))
+local_conf.set('PYTHON', meson.current_source_dir())
+local_conf.set('VERSION', meson.project_version() + VERSION_SUFFIX)
+local_conf.set('BUILD_TYPE', get_option('buildtype'))
+local_conf.set('SCHEMAS_DIR', join_paths(meson.current_build_dir(), 'data'))
+
+local_conf.set('local_build', 'True')
# Subdirs
+subdir('gradience')
subdir('data')
-subdir('src')
subdir('po')
+#meson.add_install_script('build-aux/meson_post_install.py')
+
gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
diff --git a/requirements.txt b/requirements.txt
index caf463a9..bc0d6142 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -21,6 +21,8 @@
# chmod +x flatpak-pip-generator
# Then run:
# ./flatpak-pip-generator --requirements-file=requirements.txt --output pypi-dependencies
+# And move output file to build-aux directory:
+# mv pypi-dependencies.json build-aux/flatpak/
#
# or more simply, just push and the bot will do this for you.
From 667be40bb041e7ab68e6136a149f231e65db7449 Mon Sep 17 00:00:00 2001
From: 0xMRTT <0xMRTT@tuta.io>
Date: Tue, 13 Sep 2022 20:12:13 +0200
Subject: [PATCH 2/6] fix: add cssutils
Signed-off-by: 0xMRTT <0xMRTT@tuta.io>
---
requirements.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/requirements.txt b/requirements.txt
index bc0d6142..e0e77c8d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -31,3 +31,4 @@ material-color-utilities-python
aiohttp
svglib
yapsy
+cssutils
From a81b3955d54a6bd5efdbd106349a0f55e97a771c Mon Sep 17 00:00:00 2001
From: AdwCustomizer
Date: Tue, 13 Sep 2022 18:12:42 +0000
Subject: [PATCH 3/6] ci: update Flatpak pypi dependencies
---
build-aux/flatpak/pypi-dependencies.json | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/build-aux/flatpak/pypi-dependencies.json b/build-aux/flatpak/pypi-dependencies.json
index 77836d99..cce5b954 100644
--- a/build-aux/flatpak/pypi-dependencies.json
+++ b/build-aux/flatpak/pypi-dependencies.json
@@ -36,8 +36,8 @@
},
{
"type": "file",
- "url": "https://files.pythonhosted.org/packages/fb/aa/390071f384435ae3bbda1c30ae8b1ca97575b154694d5ec092bca45d97ef/regex-2022.9.11.tar.gz",
- "sha256": "36dc03da451c2aef9a3ea521a453faa43474fc6c1d8b46706aee6c31a57d3552"
+ "url": "https://files.pythonhosted.org/packages/f8/43/b85d103acc0bfb54939f801908bf83354085579e8422eeaa22c017950c02/regex-2022.9.13.tar.gz",
+ "sha256": "f07373b6e56a6f3a0df3d75b651a278ca7bd357a796078a26a958ea1ce0588fd"
}
]
},
@@ -152,6 +152,20 @@
"sha256": "d8113d9f9c74eacf65b4663c9c037d278c9cb273b5eee5f0e1803baeedb23f8b"
}
]
+ },
+ {
+ "name": "python3-cssutils",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"cssutils\" --no-build-isolation"
+ ],
+ "sources": [
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/28/4e/6c6d07b1ab43f7b8b939406b562c652c651a66699b8a01fc6b774cbf69de/cssutils-2.6.0-py3-none-any.whl",
+ "sha256": "30c72f3a5c5951a11151640600aae7b3bf10e4c0d5c87f5bc505c2cd4a26e0c2"
+ }
+ ]
}
]
}
\ No newline at end of file
From 5b5e87dfac1ca88d3ed2818e896f7af80006ba1d Mon Sep 17 00:00:00 2001
From: "deepsource-autofix[bot]"
<62050782+deepsource-autofix[bot]@users.noreply.github.com>
Date: Tue, 13 Sep 2022 17:00:35 +0000
Subject: [PATCH 4/6] Format code with black and autopep8
This commit fixes the style issues introduced in c47694b according to the output
from black and autopep8.
Details: https://deepsource.io/gh/GradienceTeam/Gradience/transform/cc6dc755-139e-444b-ad6e-feac87d7e0bf/
---
gradience/modules/css.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/gradience/modules/css.py b/gradience/modules/css.py
index 8988f28b..909b21ce 100644
--- a/gradience/modules/css.py
+++ b/gradience/modules/css.py
@@ -39,5 +39,6 @@ def load_preset_from_file(path):
css += f"\n{rule.cssText}"
return css, variables, palette
+
# if __name__ == "__main__":
# load_preset_from_file("/home/user/.config/gtk-4.0/gtk.css")
From d4a542f907b2618f7f58fe1d860f8e789661d76b Mon Sep 17 00:00:00 2001
From: 0xMRTT <0xMRTT@tuta.io>
Date: Tue, 13 Sep 2022 20:16:31 +0200
Subject: [PATCH 5/6] fix: only update pypi deps on push
Signed-off-by: 0xMRTT <0xMRTT@tuta.io>
---
.github/workflows/pypi_deps.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.github/workflows/pypi_deps.yml b/.github/workflows/pypi_deps.yml
index 687b32d1..637cb41e 100644
--- a/.github/workflows/pypi_deps.yml
+++ b/.github/workflows/pypi_deps.yml
@@ -8,9 +8,6 @@ on:
push:
branches: [ "main" ]
paths: requirements.txt
- pull_request:
- branches: [ "main" ]
- paths: requirements.txt
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
From 9dfa0f0204613df31f1af4f8b0497700ec900b7b Mon Sep 17 00:00:00 2001
From: 0xMRTT <0xMRTT@tuta.io>
Date: Tue, 13 Sep 2022 20:59:29 +0200
Subject: [PATCH 6/6] fix: module not found error
---
gradience/gradience.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gradience/gradience.in b/gradience/gradience.in
index 698f68a1..b0ec6d68 100755
--- a/gradience/gradience.in
+++ b/gradience/gradience.in
@@ -58,5 +58,7 @@ if __name__ == '__main__':
os.path.join(pkgdatadir, 'gradience.gresource'))
Gio.Resource._register(resource)
+ sys.path.insert(1, "/usr/local/lib/python3.10/site-packages")
+
from gradience import main
sys.exit(main.main())