aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2021-06-22 19:33:56 -0700
committerZac Medico <zmedico@gentoo.org>2021-06-23 04:08:27 -0700
commit708ba6d6ef40b528e9ac344f88cbe10d0a78e3ce (patch)
treef6091fc1c3d29c964974f081f297fa3b5189ea27
parentUse PORTAGE_PROPERTIES and PORTAGE_RESTRICT internally (diff)
downloadportage-708ba6d6ef40b528e9ac344f88cbe10d0a78e3ce.tar.gz
portage-708ba6d6ef40b528e9ac344f88cbe10d0a78e3ce.tar.bz2
portage-708ba6d6ef40b528e9ac344f88cbe10d0a78e3ce.zip
setup.py: align venv EPREFIX with sys.prefix
Signed-off-by: Zac Medico <zmedico@gentoo.org>
-rwxr-xr-xsetup.py80
1 files changed, 72 insertions, 8 deletions
diff --git a/setup.py b/setup.py
index 879e0ca5e..fb4d5c1a5 100755
--- a/setup.py
+++ b/setup.py
@@ -519,26 +519,29 @@ class x_install_lib(install_lib):
val_dict = {}
if create_entry_points:
- val_dict.update(
- {
- "GLOBAL_CONFIG_PATH": self.portage_confdir,
- }
- )
re_sub_file(
"portage/const.py",
(
(
+ r"^(GLOBAL_CONFIG_PATH\s*=\s*[\"'])(.*)([\"'])",
+ lambda m: "{}{}{}".format(
+ m.group(1),
+ m.group(2).partition("/usr")[-1],
+ m.group(3),
+ ),
+ ),
+ (
r"^(PORTAGE_BASE_PATH\s*=\s*)(.*)",
lambda m: "{}{}".format(
m.group(1),
- 'os.path.realpath(os.path.join(__file__, "../../usr/lib/portage"))',
+ 'os.path.join(os.path.realpath(__import__("sys").prefix), "lib/portage")',
),
),
(
r"^(EPREFIX\s*=\s*)(.*)",
lambda m: "{}{}".format(
m.group(1),
- 'os.path.realpath(os.path.join(__file__, "../.."))',
+ '__import__("sys").prefix',
),
),
),
@@ -571,6 +574,10 @@ class x_install_scripts_custom(install_scripts):
if self.root is not None:
self.install_dir = change_root(self.root, self.install_dir)
+ def run(self):
+ if not create_entry_points:
+ install_scripts.run(self)
+
class x_install_scripts_bin(x_install_scripts_custom):
dir_name = 'bin'
@@ -732,6 +739,48 @@ class build_ext(_build_ext):
_build_ext.run(self)
+def venv_data_files(locations):
+ if not create_entry_points:
+ return
+ for dest_prefix, source_path, file_args in locations:
+ specific_files = []
+ mode_arg = None
+ for arg in file_args:
+ if arg.startswith("-m"):
+ mode_arg = int(arg[2:], 8)
+ else:
+ specific_files.append(arg)
+
+ abs_source_path = os.path.abspath(source_path)
+ for root, dirs, files in os.walk(abs_source_path):
+
+ root_offset = root[len(abs_source_path) :].lstrip("/")
+ dest_path = os.path.join(dest_prefix, root_offset)
+
+ if specific_files:
+ matched_files = list(
+ itertools.chain.from_iterable(
+ glob.glob(os.path.join(root, x)) for x in specific_files
+ )
+ )
+ else:
+ matched_files = [os.path.join(root, x) for x in files]
+
+ if mode_arg:
+ for filename in matched_files:
+ if not os.path.islink(filename):
+ os.chmod(filename, mode_arg)
+
+ yield (dest_path, matched_files)
+
+
+def get_data_files(regular_files, venv_files):
+ if create_entry_points:
+ return list(venv_data_files(venv_files))
+
+ return regular_files
+
+
setup(
name = 'portage',
version = '3.0.20',
@@ -752,7 +801,7 @@ setup(
# something to cheat build & install commands
scripts = list(find_scripts()),
- data_files = list(get_manpages()) + [
+ data_files = get_data_files(list(get_manpages()) + [
['$sysconfdir', ['cnf/etc-update.conf', 'cnf/dispatch-conf.conf']],
['$logrotatedir', ['cnf/logrotate.d/elog-save-summary']],
['$portage_confdir', [
@@ -762,6 +811,21 @@ setup(
['$portage_base/bin', ['bin/deprecated-path']],
['$sysconfdir/portage/repo.postsync.d', ['cnf/repo.postsync.d/example']],
],
+ [
+ ("etc", "cnf", ("etc-update.conf", "dispatch-conf.conf")),
+ ("etc/logrotate.d", "cnf/logrotate.d", ("elog-save-summary",)),
+ ("etc/portage/repo.postsync.d", "cnf/repo.postsync.d", ("example",)),
+ (
+ "share/portage/config",
+ "cnf",
+ ("make.conf.example", "make.globals", "repos.conf"),
+ ),
+ ("share/portage/config/sets", "cnf/sets", ("*.conf",)),
+ ("share/man/man1", "man", ("*.1",)),
+ ("share/man/man5", "man", ("*.5",)),
+ ("share/portage/doc", "", ("NEWS", "RELEASE-NOTES")),
+ ("lib/portage/bin", "bin", ("-m0755",)),
+ ]),
entry_points={
"console_scripts": [
"{}=portage.util.bin_entry_point:bin_entry_point".format(os.path.basename(path))