diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-12-17 11:50:24 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-12-17 12:23:01 +0100 |
commit | 75a4cbddebfb4e38aaa07b4b232195e455e62480 (patch) | |
tree | 1bef4de1f45c72653e65a76b9ba24addfdc3680a | |
parent | distutils-r1.eclass: Call gpep517 via EPYTHON (diff) | |
download | gentoo-75a4cbddebfb4e38aaa07b4b232195e455e62480.tar.gz gentoo-75a4cbddebfb4e38aaa07b4b232195e455e62480.tar.bz2 gentoo-75a4cbddebfb4e38aaa07b4b232195e455e62480.zip |
dev-python/setuptools-gettext: Add a patch to fix wheel building
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | dev-python/setuptools-gettext/files/setuptools-gettext-0.1.8-wheel.patch | 123 | ||||
-rw-r--r-- | dev-python/setuptools-gettext/setuptools-gettext-0.1.8-r1.ebuild (renamed from dev-python/setuptools-gettext/setuptools-gettext-0.1.8.ebuild) | 5 | ||||
-rw-r--r-- | profiles/package.mask | 6 |
3 files changed, 128 insertions, 6 deletions
diff --git a/dev-python/setuptools-gettext/files/setuptools-gettext-0.1.8-wheel.patch b/dev-python/setuptools-gettext/files/setuptools-gettext-0.1.8-wheel.patch new file mode 100644 index 000000000000..aab0158cd698 --- /dev/null +++ b/dev-python/setuptools-gettext/files/setuptools-gettext-0.1.8-wheel.patch @@ -0,0 +1,123 @@ +From a793c1d9938da1c7c962feff13dc948523fcc774 Mon Sep 17 00:00:00 2001 +From: Eli Schwartz <eschwartz93@gmail.com> +Date: Sat, 16 Dec 2023 21:53:38 -0500 +Subject: [PATCH] fix critical existence failure of install_mo + +In commit d28f5fa57eef7fa9baa28dea119b45e74145ecb5 the self.root was +added, and we ended up with this directory repeated twice and bogus +installed files + +When building a wheel, the value of self.root is internally implemented +by bdist_wheel as (build/bdist.linux-x86_64/wheel); the resulting wheel +placed files in random locations inside of the installed site-packages +directory. + +When running `python setup.py install --root=$DESTDIR`, the value of +self.root is of course `$DESTDIR`, leading to installed files that got +installed to the staging install directory, e.g. the resulting .deb file +would attempt to install files to +``` +/home/$USERNAME/projects/foobar/debian/tmp/usr/share/locale +``` +during an `apt install`. + +This is incorrect use of the setuptools API, as witnessed in +install_data which does the same task correctly: + +``` +if not os.path.isabs(dir): + dir = os.path.join(self.install_dir, dir) +elif self.root: + dir = change_root(self.root, dir) +``` + +Rather than continuing to copy-paste code around, inherit correctly from +the existing class. Update the data_files attribute of the new +install_mo implementation, and use that to drive the installation of +files using the same battle-tested logic used by `setup(data_files=[])`. + +Fixes #30 +--- + setuptools_gettext/__init__.py | 43 +++++++--------------------------- + 1 file changed, 8 insertions(+), 35 deletions(-) + +diff --git a/setuptools_gettext/__init__.py b/setuptools_gettext/__init__.py +index dc4ae73..59769b4 100644 +--- a/setuptools_gettext/__init__.py ++++ b/setuptools_gettext/__init__.py +@@ -26,6 +26,7 @@ + import sys + from typing import List, Optional, Tuple + ++from distutils.command.install_data import install_data + from setuptools import Command + from setuptools.dist import Distribution + +@@ -165,41 +166,19 @@ def run(self): + os.unlink(os.path.join(root, file_)) + + +-class install_mo(Command): ++class install_mo(install_data): + + description: str = "install .mo files" + +- user_options = [ +- ( +- 'install-dir=', +- 'd', +- "base directory for installing data files " +- "(default: installation base dir)", +- ), +- ('root=', None, +- "install everything relative to this alternate root directory"), +- ('force', 'f', "force installation (overwrite existing files)"), +- ] +- +- boolean_options: List[str] = ['force'] + build_dir: Optional[str] +- install_dir: Optional[str] +- root: Optional[str] + + def initialize_options(self) -> None: +- self.install_dir = None +- self.outfiles: List[str] = [] +- self.root = None +- self.force = 0 ++ super().initialize_options() ++ self.data_files: List[str] = [] + self.build_dir = None + + def finalize_options(self) -> None: +- self.set_undefined_options( +- 'install', +- ('install_data', 'install_dir'), +- ('root', 'root'), +- ('force', 'force'), +- ) ++ super().finalize_options() + if self.build_dir is None: + self.build_dir = ( + self.distribution.gettext_build_dir) # type: ignore +@@ -207,18 +186,12 @@ def finalize_options(self) -> None: + def run(self) -> None: + assert self.install_dir is not None + assert self.build_dir is not None +- self.mkpath(self.install_dir) + import glob + for filepath in glob.glob(self.build_dir + "/*/LC_MESSAGES/*.mo"): + langfile = filepath[len(self.build_dir.rstrip('/')+'/'):] +- targetpath = os.path.join( +- self.install_dir, +- os.path.dirname(os.path.join("share/locale", langfile))) +- if self.root is not None: +- targetpath = change_root(self.root, targetpath) +- self.mkpath(targetpath) +- (out, _) = self.copy_file(filepath, targetpath) +- self.outfiles.append(out) ++ install_dir = os.path.dirname(os.path.join("share/locale", langfile)) ++ self.data_files.append((install_dir, [filepath])) ++ super().run() + + def get_inputs(self): + import glob diff --git a/dev-python/setuptools-gettext/setuptools-gettext-0.1.8.ebuild b/dev-python/setuptools-gettext/setuptools-gettext-0.1.8-r1.ebuild index 71b027b2d6e3..e02ba96a24c3 100644 --- a/dev-python/setuptools-gettext/setuptools-gettext-0.1.8.ebuild +++ b/dev-python/setuptools-gettext/setuptools-gettext-0.1.8-r1.ebuild @@ -27,6 +27,11 @@ RDEPEND=" ' 3.10) " +PATCHES=( + # https://github.com/breezy-team/setuptools-gettext/pull/31 + "${FILESDIR}/${P}-wheel.patch" +) + python_test() { cd example || die distutils_pep517_install "${T}/${EPYTHON}" diff --git a/profiles/package.mask b/profiles/package.mask index 598df7cb7277..091caf78009c 100644 --- a/profiles/package.mask +++ b/profiles/package.mask @@ -44,12 +44,6 @@ dev-ruby/elasticsearch:8.8.0 # https://github.com/sdispater/pendulum/issues/769 =dev-python/pendulum-3.0.0 -# Michał Górny <mgorny@gentoo.org> (2023-12-16) -# This package is completely broken upstream: it installs locales -# into an incorrect subdirectory: -# https://github.com/breezy-team/setuptools-gettext/issues/30 -=dev-python/setuptools-gettext-0.1.8 - # Michał Górny <mgorny@gentoo.org> (2023-12-15) # Superseded by dev-python/pypy3_10-exe{,-bin}. # Removal on 2024-01-14. Bug #920036. |