89 lines
3.6 KiB
Diff
89 lines
3.6 KiB
Diff
From 6b68afbb047060277b00f570345e7e1969266712 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Perl <m@thp.io>
|
|
Date: Wed, 12 Apr 2023 15:22:02 +0200
|
|
Subject: [PATCH] Rework handling of running from a source checkout (fixes
|
|
#755)
|
|
|
|
diff --git a/CHANGELOG.md b/CHANGELOG.md
|
|
index 657e0494..fccf1f1d 100644
|
|
--- a/CHANGELOG.md
|
|
+++ b/CHANGELOG.md
|
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
|
|
The format mostly follows [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
|
|
|
+## UNRELEASED
|
|
+
|
|
+### Fixed
|
|
+
|
|
+- Rework handling of running from a source checkout, fixes issues with example files
|
|
+ when `urlwatch` was run as `/usr/sbin/urlwatch`, e.g. on Void Linux (fixes #755)
|
|
+
|
|
## [2.26] -- 2023-04-11
|
|
|
|
### Added
|
|
diff --git a/lib/urlwatch/cli.py b/lib/urlwatch/cli.py
|
|
index 75332f09..f6a5802a 100755
|
|
--- a/lib/urlwatch/cli.py
|
|
+++ b/lib/urlwatch/cli.py
|
|
@@ -47,9 +47,6 @@
|
|
# Check if we are installed in the system already
|
|
(prefix, bindir) = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0])))
|
|
|
|
-if bindir != 'bin':
|
|
- sys.path.insert(0, os.path.join(prefix, bindir, 'lib'))
|
|
-
|
|
from urlwatch.command import UrlwatchCommand
|
|
from urlwatch.config import CommandConfig
|
|
from urlwatch.main import Urlwatch
|
|
@@ -90,7 +87,7 @@ def main():
|
|
if os.path.exists(old_cache_file) and not os.path.exists(new_cache_file):
|
|
cache_file = old_cache_file
|
|
|
|
- command_config = CommandConfig(sys.argv[1:], pkgname, urlwatch_dir, bindir, prefix,
|
|
+ command_config = CommandConfig(sys.argv[1:], pkgname, urlwatch_dir, prefix,
|
|
config_file, urls_file, hooks_file, cache_file, False)
|
|
setup_logger(command_config.verbose)
|
|
|
|
diff --git a/lib/urlwatch/config.py b/lib/urlwatch/config.py
|
|
index c1075460..40d206ec 100644
|
|
--- a/lib/urlwatch/config.py
|
|
+++ b/lib/urlwatch/config.py
|
|
@@ -52,20 +52,12 @@ def __init__(self, pkgname, urlwatch_dir, config, urls, cache, hooks, verbose):
|
|
|
|
class CommandConfig(BaseConfig):
|
|
|
|
- def __init__(self, args, pkgname, urlwatch_dir, bindir, prefix, config, urls, hooks, cache, verbose):
|
|
+ def __init__(self, args, pkgname, urlwatch_dir, prefix, config, urls, hooks, cache, verbose):
|
|
super().__init__(pkgname, urlwatch_dir, config, urls, cache, hooks, verbose)
|
|
- self.bindir = bindir
|
|
- self.prefix = prefix
|
|
self.migrate_cache = migrate_cache
|
|
self.migrate_urls = migrate_urls
|
|
|
|
- if self.bindir == 'bin':
|
|
- # Installed system-wide
|
|
- self.examples_dir = os.path.join(prefix, 'share', self.pkgname, 'examples')
|
|
- else:
|
|
- # Assume we are not yet installed
|
|
- self.examples_dir = os.path.join(prefix, bindir, 'share', self.pkgname, 'examples')
|
|
-
|
|
+ self.examples_dir = os.path.join(prefix, 'share', self.pkgname, 'examples')
|
|
self.urls_yaml_example = os.path.join(self.examples_dir, 'urls.yaml.example')
|
|
self.hooks_py_example = os.path.join(self.examples_dir, 'hooks.py.example')
|
|
|
|
diff --git a/lib/urlwatch/tests/test_handler.py b/lib/urlwatch/tests/test_handler.py
|
|
index 1d5d22e6..7886acc9 100644
|
|
--- a/lib/urlwatch/tests/test_handler.py
|
|
+++ b/lib/urlwatch/tests/test_handler.py
|
|
@@ -89,8 +89,7 @@ def test_pep8_conformance():
|
|
|
|
class ConfigForTest(CommandConfig):
|
|
def __init__(self, config, urls, cache, hooks, verbose):
|
|
- (prefix, bindir) = os.path.split(os.path.dirname(os.path.abspath(sys.argv[0])))
|
|
- super().__init__([], 'urlwatch', os.path.dirname(__file__), bindir, prefix, config, urls, hooks, cache, verbose)
|
|
+ super().__init__([], 'urlwatch', os.path.dirname(__file__), root, config, urls, hooks, cache, verbose)
|
|
|
|
|
|
@contextlib.contextmanager
|