1 |
commit: 708ba6d6ef40b528e9ac344f88cbe10d0a78e3ce |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 23 02:33:56 2021 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 23 11:08:27 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=708ba6d6 |
7 |
|
8 |
setup.py: align venv EPREFIX with sys.prefix |
9 |
|
10 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
11 |
|
12 |
setup.py | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- |
13 |
1 file changed, 72 insertions(+), 8 deletions(-) |
14 |
|
15 |
diff --git a/setup.py b/setup.py |
16 |
index 879e0ca5e..fb4d5c1a5 100755 |
17 |
--- a/setup.py |
18 |
+++ b/setup.py |
19 |
@@ -519,26 +519,29 @@ class x_install_lib(install_lib): |
20 |
|
21 |
val_dict = {} |
22 |
if create_entry_points: |
23 |
- val_dict.update( |
24 |
- { |
25 |
- "GLOBAL_CONFIG_PATH": self.portage_confdir, |
26 |
- } |
27 |
- ) |
28 |
re_sub_file( |
29 |
"portage/const.py", |
30 |
( |
31 |
+ ( |
32 |
+ r"^(GLOBAL_CONFIG_PATH\s*=\s*[\"'])(.*)([\"'])", |
33 |
+ lambda m: "{}{}{}".format( |
34 |
+ m.group(1), |
35 |
+ m.group(2).partition("/usr")[-1], |
36 |
+ m.group(3), |
37 |
+ ), |
38 |
+ ), |
39 |
( |
40 |
r"^(PORTAGE_BASE_PATH\s*=\s*)(.*)", |
41 |
lambda m: "{}{}".format( |
42 |
m.group(1), |
43 |
- 'os.path.realpath(os.path.join(__file__, "../../usr/lib/portage"))', |
44 |
+ 'os.path.join(os.path.realpath(__import__("sys").prefix), "lib/portage")', |
45 |
), |
46 |
), |
47 |
( |
48 |
r"^(EPREFIX\s*=\s*)(.*)", |
49 |
lambda m: "{}{}".format( |
50 |
m.group(1), |
51 |
- 'os.path.realpath(os.path.join(__file__, "../.."))', |
52 |
+ '__import__("sys").prefix', |
53 |
), |
54 |
), |
55 |
), |
56 |
@@ -571,6 +574,10 @@ class x_install_scripts_custom(install_scripts): |
57 |
if self.root is not None: |
58 |
self.install_dir = change_root(self.root, self.install_dir) |
59 |
|
60 |
+ def run(self): |
61 |
+ if not create_entry_points: |
62 |
+ install_scripts.run(self) |
63 |
+ |
64 |
|
65 |
class x_install_scripts_bin(x_install_scripts_custom): |
66 |
dir_name = 'bin' |
67 |
@@ -732,6 +739,48 @@ class build_ext(_build_ext): |
68 |
_build_ext.run(self) |
69 |
|
70 |
|
71 |
+def venv_data_files(locations): |
72 |
+ if not create_entry_points: |
73 |
+ return |
74 |
+ for dest_prefix, source_path, file_args in locations: |
75 |
+ specific_files = [] |
76 |
+ mode_arg = None |
77 |
+ for arg in file_args: |
78 |
+ if arg.startswith("-m"): |
79 |
+ mode_arg = int(arg[2:], 8) |
80 |
+ else: |
81 |
+ specific_files.append(arg) |
82 |
+ |
83 |
+ abs_source_path = os.path.abspath(source_path) |
84 |
+ for root, dirs, files in os.walk(abs_source_path): |
85 |
+ |
86 |
+ root_offset = root[len(abs_source_path) :].lstrip("/") |
87 |
+ dest_path = os.path.join(dest_prefix, root_offset) |
88 |
+ |
89 |
+ if specific_files: |
90 |
+ matched_files = list( |
91 |
+ itertools.chain.from_iterable( |
92 |
+ glob.glob(os.path.join(root, x)) for x in specific_files |
93 |
+ ) |
94 |
+ ) |
95 |
+ else: |
96 |
+ matched_files = [os.path.join(root, x) for x in files] |
97 |
+ |
98 |
+ if mode_arg: |
99 |
+ for filename in matched_files: |
100 |
+ if not os.path.islink(filename): |
101 |
+ os.chmod(filename, mode_arg) |
102 |
+ |
103 |
+ yield (dest_path, matched_files) |
104 |
+ |
105 |
+ |
106 |
+def get_data_files(regular_files, venv_files): |
107 |
+ if create_entry_points: |
108 |
+ return list(venv_data_files(venv_files)) |
109 |
+ |
110 |
+ return regular_files |
111 |
+ |
112 |
+ |
113 |
setup( |
114 |
name = 'portage', |
115 |
version = '3.0.20', |
116 |
@@ -752,7 +801,7 @@ setup( |
117 |
# something to cheat build & install commands |
118 |
scripts = list(find_scripts()), |
119 |
|
120 |
- data_files = list(get_manpages()) + [ |
121 |
+ data_files = get_data_files(list(get_manpages()) + [ |
122 |
['$sysconfdir', ['cnf/etc-update.conf', 'cnf/dispatch-conf.conf']], |
123 |
['$logrotatedir', ['cnf/logrotate.d/elog-save-summary']], |
124 |
['$portage_confdir', [ |
125 |
@@ -762,6 +811,21 @@ setup( |
126 |
['$portage_base/bin', ['bin/deprecated-path']], |
127 |
['$sysconfdir/portage/repo.postsync.d', ['cnf/repo.postsync.d/example']], |
128 |
], |
129 |
+ [ |
130 |
+ ("etc", "cnf", ("etc-update.conf", "dispatch-conf.conf")), |
131 |
+ ("etc/logrotate.d", "cnf/logrotate.d", ("elog-save-summary",)), |
132 |
+ ("etc/portage/repo.postsync.d", "cnf/repo.postsync.d", ("example",)), |
133 |
+ ( |
134 |
+ "share/portage/config", |
135 |
+ "cnf", |
136 |
+ ("make.conf.example", "make.globals", "repos.conf"), |
137 |
+ ), |
138 |
+ ("share/portage/config/sets", "cnf/sets", ("*.conf",)), |
139 |
+ ("share/man/man1", "man", ("*.1",)), |
140 |
+ ("share/man/man5", "man", ("*.5",)), |
141 |
+ ("share/portage/doc", "", ("NEWS", "RELEASE-NOTES")), |
142 |
+ ("lib/portage/bin", "bin", ("-m0755",)), |
143 |
+ ]), |
144 |
entry_points={ |
145 |
"console_scripts": [ |
146 |
"{}=portage.util.bin_entry_point:bin_entry_point".format(os.path.basename(path)) |