1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
From 7eda0d89745de97d0d0299e0d68e4fd839bd4145 Mon Sep 17 00:00:00 2001
From: Jon duSaint <jon@rockgeeks.net>
Date: Mon, 1 Aug 2022 17:15:28 -0700
Subject: [PATCH] setup.py: Add --config-name option
This is used to tell wee_config where to put the output weewx.conf file.
---
setup.py | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/setup.py b/setup.py
index fecd57a..96fc309 100755
--- a/setup.py
+++ b/setup.py
@@ -48,15 +48,17 @@ this_dir = os.path.abspath(os.path.dirname(this_file))
# ==============================================================================
class weewx_install(install):
- """Specialized version of install, which adds a '--no-prompt' option, and which runs a
- wee_config post-install script"""
+ """Specialized version of install, which adds '--no-prompt' and '--config-name' options,
+ and which runs a wee_config post-install script"""
- # Add an option for --no-prompt. This will be passed on to wee_config
- user_options = install.user_options + [('no-prompt', None, 'Do not prompt for station info')]
+ # Add options for --no-prompt and --config-name to be passed on to wee_config
+ user_options = install.user_options + [('no-prompt', None, 'Do not prompt for station info'),
+ ('config-name=', None, 'Output config file')]
def initialize_options(self, *args, **kwargs):
install.initialize_options(self, *args, **kwargs)
self.no_prompt = None
+ self.config_name = 'weewx.conf'
def finalize_options(self):
# Call my superclass's version
@@ -76,7 +78,7 @@ class weewx_install(install):
# Now the post-install
update_and_install_config(self.install_data, self.install_scripts, self.install_lib,
- self.no_prompt)
+ self.no_prompt, self.config_name)
return rv
@@ -250,7 +252,12 @@ def update_and_install_config(install_dir, install_scripts, install_lib, no_prom
"""
# This is where the weewx.conf file will go
- config_path = os.path.join(install_dir, config_name)
+ dist_config_path = os.path.join(install_dir, os.path.basename(config_name))
+
+ if os.path.isabs(config_name):
+ config_path = config_name
+ else:
+ config_path = dist_config_path
# Is there an existing file?
if os.path.isfile(config_path):
@@ -259,7 +266,7 @@ def update_and_install_config(install_dir, install_scripts, install_lib, no_prom
os.path.join(install_scripts, 'wee_config'),
'--upgrade',
'--config=%s' % config_path,
- '--dist-config=%s' % config_path + '.' + VERSION,
+ '--dist-config=%s' % dist_config_path + '.' + VERSION,
'--output=%s' % config_path,
]
else:
@@ -267,7 +274,7 @@ def update_and_install_config(install_dir, install_scripts, install_lib, no_prom
args = [sys.executable,
os.path.join(install_scripts, 'wee_config'),
'--install',
- '--dist-config=%s' % config_path + '.' + VERSION,
+ '--dist-config=%s' % dist_config_path + '.' + VERSION,
'--output=%s' % config_path,
]
# Add the --no-prompt flag if the user requested it.
--
2.35.1
|