From f8a657d409b72f78bdc62d110eb62bb5ced46f6a Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Thu, 14 Mar 2024 09:12:42 +0000 Subject: [PATCH 1/7] glib: 2.80.0 --- recipes/glib/all/conandata.yml | 3 +++ recipes/glib/all/conanfile.py | 7 +++++-- recipes/glib/all/test_package/conanfile.py | 3 ++- recipes/glib/all/test_v1_package/conanfile.py | 3 +++ recipes/glib/config.yml | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/recipes/glib/all/conandata.yml b/recipes/glib/all/conandata.yml index 826e4f114106f..13218c1d222f5 100644 --- a/recipes/glib/all/conandata.yml +++ b/recipes/glib/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "2.80.0": + url: "https://download.gnome.org/sources/glib/2.80/glib-2.80.0.tar.xz" + sha256: "8228a92f92a412160b139ae68b6345bd28f24434a7b5af150ebe21ff587a561d" "2.78.3": url: "https://download.gnome.org/sources/glib/2.78/glib-2.78.3.tar.xz" sha256: "609801dd373796e515972bf95fc0b2daa44545481ee2f465c4f204d224b2bc21" diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 6ccdcc81fb42a..52e10dbcbb319 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -6,6 +6,7 @@ from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os import shutil @@ -81,9 +82,11 @@ def requirements(self): self.requires("libiconv/1.17") def build_requirements(self): - self.tool_requires("meson/1.2.2") + self.tool_requires("meson/1.4.0") if not self.conf.get("tools.gnu:pkg_config", check_type=str): - self.tool_requires("pkgconf/2.0.3") + self.tool_requires("pkgconf/2.1.0") + if Version(self.version) >= "2.79.0": + self.tool_requires("python_packaging/24.0") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) diff --git a/recipes/glib/all/test_package/conanfile.py b/recipes/glib/all/test_package/conanfile.py index 168cdc2e86991..398628b9660a0 100644 --- a/recipes/glib/all/test_package/conanfile.py +++ b/recipes/glib/all/test_package/conanfile.py @@ -15,10 +15,11 @@ def layout(self): def requirements(self): self.requires(self.tested_reference_str) + self.requires("python_packaging/24.0") def build_requirements(self): if self.settings.os != "Windows" and not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): - self.tool_requires("pkgconf/2.0.3") + self.tool_requires("pkgconf/2.1.0") def generate(self): tc = CMakeToolchain(self) diff --git a/recipes/glib/all/test_v1_package/conanfile.py b/recipes/glib/all/test_v1_package/conanfile.py index 3247118701674..b600396f48e48 100644 --- a/recipes/glib/all/test_v1_package/conanfile.py +++ b/recipes/glib/all/test_v1_package/conanfile.py @@ -6,6 +6,9 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi", "pkg_config" + def requirements(self): + self.requires("python_packaging/24.0") + def build_requirements(self): if self.settings.os != "Windows": self.tool_requires("pkgconf/2.0.3") diff --git a/recipes/glib/config.yml b/recipes/glib/config.yml index f0bd1289c0ca6..b556263a4491f 100644 --- a/recipes/glib/config.yml +++ b/recipes/glib/config.yml @@ -1,4 +1,6 @@ versions: + "2.80.0": + folder: all "2.78.3": folder: all "2.78.1": From 692b395f57cbf0532304f0165188de1773236505 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 15 Apr 2024 15:01:20 +0300 Subject: [PATCH 2/7] glib: install 'packaging' Python package locally for Meson --- recipes/glib/all/conanfile.py | 19 +++++++++++++++++-- recipes/glib/all/test_package/conanfile.py | 1 - recipes/glib/all/test_v1_package/conanfile.py | 3 --- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 52e10dbcbb319..fb1af0d39928b 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name, is_apple_os -from conan.tools.env import VirtualBuildEnv +from conan.tools.env import VirtualBuildEnv, Environment from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout @@ -86,11 +86,15 @@ def build_requirements(self): if not self.conf.get("tools.gnu:pkg_config", check_type=str): self.tool_requires("pkgconf/2.1.0") if Version(self.version) >= "2.79.0": - self.tool_requires("python_packaging/24.0") + self.tool_requires("cpython/3.12.2") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + @property + def _site_packages_dir(self): + return os.path.join(self.build_folder, "site-packages") + def generate(self): virtual_build_env = VirtualBuildEnv(self) virtual_build_env.generate() @@ -106,6 +110,11 @@ def generate(self): tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled" tc.generate() + env = Environment() + env.append_path("PYTHONPATH", self._site_packages_dir) + env.append_path("PATH", os.path.join(self._site_packages_dir, "bin")) + env.vars(self).save_script("pythonpath") + def _patch_sources(self): apply_conandata_patches(self) replace_in_file(self, @@ -133,8 +142,14 @@ def _patch_sources(self): "'res'", ) + def _pip_install(self, packages): + self.run(f"python -m pip install {' '.join(packages)} --no-cache-dir --target={self._site_packages_dir}") + def build(self): self._patch_sources() + # Install 'packaging' Python package for Meson. + # Note that artifacts corresponding to a version are immutable on PyPI, which is exactly what we want. + self._pip_install(["packaging==24.0"]) meson = Meson(self) meson.configure() meson.build() diff --git a/recipes/glib/all/test_package/conanfile.py b/recipes/glib/all/test_package/conanfile.py index 398628b9660a0..a8b85e9a5dfe0 100644 --- a/recipes/glib/all/test_package/conanfile.py +++ b/recipes/glib/all/test_package/conanfile.py @@ -15,7 +15,6 @@ def layout(self): def requirements(self): self.requires(self.tested_reference_str) - self.requires("python_packaging/24.0") def build_requirements(self): if self.settings.os != "Windows" and not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): diff --git a/recipes/glib/all/test_v1_package/conanfile.py b/recipes/glib/all/test_v1_package/conanfile.py index b600396f48e48..3247118701674 100644 --- a/recipes/glib/all/test_v1_package/conanfile.py +++ b/recipes/glib/all/test_v1_package/conanfile.py @@ -6,9 +6,6 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi", "pkg_config" - def requirements(self): - self.requires("python_packaging/24.0") - def build_requirements(self): if self.settings.os != "Windows": self.tool_requires("pkgconf/2.0.3") From 6a0b9179ca97fb3d5b27c7a948c0e50b263f9fbc Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 15 Apr 2024 16:38:02 +0300 Subject: [PATCH 3/7] glib: vendor packaging.version instead --- recipes/glib/all/conanfile.py | 56 ++++++++++++++-------- recipes/glib/all/test_package/conanfile.py | 2 +- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index fb1af0d39928b..3ed9e0eb17907 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name, is_apple_os from conan.tools.env import VirtualBuildEnv, Environment -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir, download, load, save from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain @@ -24,7 +24,8 @@ class GLibConan(ConanFile): topics = "gio", "gmodule", "gnome", "gobject", "gtk" url = "https://github.com/conan-io/conan-center-index" homepage = "https://gitlab.gnome.org/GNOME/glib" - license = "LGPL-2.1-or-later" + # The latter half of the AND in the license is for the vendored pypa/packaging components + license = "LGPL-2.1-or-later AND (Apache-2.0 OR BSD-2-Clause)" package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { @@ -60,6 +61,8 @@ def configure(self): self.options.rm_safe("fPIC") self.settings.rm_safe("compiler.cppstd") self.settings.rm_safe("compiler.libcxx") + if Version(self.version) < "2.79": + self.license = "LGPL-2.1-or-later" def layout(self): basic_layout(self, src_folder="src") @@ -85,15 +88,24 @@ def build_requirements(self): self.tool_requires("meson/1.4.0") if not self.conf.get("tools.gnu:pkg_config", check_type=str): self.tool_requires("pkgconf/2.1.0") - if Version(self.version) >= "2.79.0": - self.tool_requires("cpython/3.12.2") + + @property + def _codegen_dir(self): + return os.path.join(self.source_folder, "gio", "gdbus-2.0", "codegen") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) - - @property - def _site_packages_dir(self): - return os.path.join(self.build_folder, "site-packages") + if Version(self.version) >= "2.79": + # Vendor https://github.com/pypa/packaging/blob/24.0/src/packaging/version.py + download(self, url="https://raw.githubusercontent.com/pypa/packaging/24.0/src/packaging/version.py", + sha256="5e34412cd2b5ed430380b78ff141e7ab0898dd37528b4df1150511b5e736d750", + filename=os.path.join(self._codegen_dir, "version.py")) + download(self, url="https://raw.githubusercontent.com/pypa/packaging/24.0/src/packaging/_structures.py", + sha256="ab77953666d62461bf4b40e2b7f4b7028f2a42acffe4f6135c500a0597b9cabe", + filename=os.path.join(self._codegen_dir, "_structures.py")) + for license in ["LICENSE", "LICENSE.APACHE", "LICENSE.BSD"]: + filename = "LICENSE.pypa-packaging" if license == "LICENSE" else license + download(self, url=f"https://raw.githubusercontent.com/pypa/packaging/24.0/{license}", filename=filename) def generate(self): virtual_build_env = VirtualBuildEnv(self) @@ -110,11 +122,6 @@ def generate(self): tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled" tc.generate() - env = Environment() - env.append_path("PYTHONPATH", self._site_packages_dir) - env.append_path("PATH", os.path.join(self._site_packages_dir, "bin")) - env.vars(self).save_script("pythonpath") - def _patch_sources(self): apply_conandata_patches(self) replace_in_file(self, @@ -142,20 +149,31 @@ def _patch_sources(self): "'res'", ) - def _pip_install(self, packages): - self.run(f"python -m pip install {' '.join(packages)} --no-cache-dir --target={self._site_packages_dir}") + if Version(self.version) >= "2.79": + # Use the vendored packaging.version.Version + replace_in_file(self, os.path.join(self._codegen_dir, "utils.py"), + "import packaging.version", + "from .version import Version") + replace_in_file(self, os.path.join(self._codegen_dir, "utils.py"), + "packaging.version.Version", + "Version") + replace_in_file(self, os.path.join(self._codegen_dir, "meson.build"), + "'utils.py',", + "'utils.py', 'version.py', '_structures.py',") + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), + ".find_installation(modules: ['packaging'])", + ".find_installation()") def build(self): self._patch_sources() - # Install 'packaging' Python package for Meson. - # Note that artifacts corresponding to a version are immutable on PyPI, which is exactly what we want. - self._pip_install(["packaging==24.0"]) meson = Meson(self) meson.configure() meson.build() def package(self): - copy(self, pattern="LGPL-2.1-or-later.txt", dst=os.path.join(self.package_folder, "licenses"), src=os.path.join(self.source_folder, "LICENSES")) + copy(self, "LGPL-2.1-or-later.txt", os.path.join(self.source_folder, "LICENSES"), os.path.join(self.package_folder, "licenses")) + # pypa/packaging license files + copy(self, "LICENSE.*", os.path.join(self.source_folder, "LICENSES"), os.path.join(self.package_folder, "licenses")) meson = Meson(self) meson.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) diff --git a/recipes/glib/all/test_package/conanfile.py b/recipes/glib/all/test_package/conanfile.py index a8b85e9a5dfe0..89fef354a476b 100644 --- a/recipes/glib/all/test_package/conanfile.py +++ b/recipes/glib/all/test_package/conanfile.py @@ -56,4 +56,4 @@ def test(self): if self.settings.os != "Windows": pkg_config = PkgConfig(self, "gio-2.0", pkg_config_path=self.generators_folder) gdbus_codegen = pkg_config.variables["gdbus_codegen"] - self.run(f"{gdbus_codegen} -h", env="conanrun") + self.run(f"{gdbus_codegen} -h") From 92c6606d80d0569dd85b35141dd6d8441fcb71d8 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 15 Apr 2024 17:17:01 +0300 Subject: [PATCH 4/7] glib: move packaging URL details to conandata.yml --- recipes/glib/all/conandata.yml | 8 +++++-- recipes/glib/all/conanfile.py | 38 ++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/recipes/glib/all/conandata.yml b/recipes/glib/all/conandata.yml index 13218c1d222f5..4b76f42ac3c7b 100644 --- a/recipes/glib/all/conandata.yml +++ b/recipes/glib/all/conandata.yml @@ -1,7 +1,11 @@ sources: "2.80.0": - url: "https://download.gnome.org/sources/glib/2.80/glib-2.80.0.tar.xz" - sha256: "8228a92f92a412160b139ae68b6345bd28f24434a7b5af150ebe21ff587a561d" + source: + url: "https://download.gnome.org/sources/glib/2.80/glib-2.80.0.tar.xz" + sha256: "8228a92f92a412160b139ae68b6345bd28f24434a7b5af150ebe21ff587a561d" + pypa-packaging: + url: "https://github.com/pypa/packaging/archive/refs/tags/24.0.tar.gz" + sha256: "1bf35cf2c2be982f2ae6c905760ae19cb744fadbf56269f2e54f7bdcef64d291" "2.78.3": url: "https://download.gnome.org/sources/glib/2.78/glib-2.78.3.tar.xz" sha256: "609801dd373796e515972bf95fc0b2daa44545481ee2f465c4f204d224b2bc21" diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 3ed9e0eb17907..77007545b9a80 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name, is_apple_os from conan.tools.env import VirtualBuildEnv, Environment -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir, download, load, save +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir, load, save from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain @@ -89,23 +89,26 @@ def build_requirements(self): if not self.conf.get("tools.gnu:pkg_config", check_type=str): self.tool_requires("pkgconf/2.1.0") + @property + def _vendor_pypa_packaging(self): + return Version(self.version) >= "2.79" + + @property + def _pypa_packaging_dir(self): + return os.path.join(self.source_folder, "pypa-packaging") + @property def _codegen_dir(self): return os.path.join(self.source_folder, "gio", "gdbus-2.0", "codegen") def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True) - if Version(self.version) >= "2.79": + if self._vendor_pypa_packaging: + get(self, **self.conan_data["sources"][self.version]["source"], strip_root=True) # Vendor https://github.com/pypa/packaging/blob/24.0/src/packaging/version.py - download(self, url="https://raw.githubusercontent.com/pypa/packaging/24.0/src/packaging/version.py", - sha256="5e34412cd2b5ed430380b78ff141e7ab0898dd37528b4df1150511b5e736d750", - filename=os.path.join(self._codegen_dir, "version.py")) - download(self, url="https://raw.githubusercontent.com/pypa/packaging/24.0/src/packaging/_structures.py", - sha256="ab77953666d62461bf4b40e2b7f4b7028f2a42acffe4f6135c500a0597b9cabe", - filename=os.path.join(self._codegen_dir, "_structures.py")) - for license in ["LICENSE", "LICENSE.APACHE", "LICENSE.BSD"]: - filename = "LICENSE.pypa-packaging" if license == "LICENSE" else license - download(self, url=f"https://raw.githubusercontent.com/pypa/packaging/24.0/{license}", filename=filename) + get(self, **self.conan_data["sources"][self.version]["pypa-packaging"], strip_root=True, + destination=self._pypa_packaging_dir) + else: + get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): virtual_build_env = VirtualBuildEnv(self) @@ -149,8 +152,10 @@ def _patch_sources(self): "'res'", ) - if Version(self.version) >= "2.79": + if self._vendor_pypa_packaging: # Use the vendored packaging.version.Version + copy(self, "version.py", os.path.join(self._pypa_packaging_dir, "src", "packaging"), self._codegen_dir) + copy(self, "_structures.py", os.path.join(self._pypa_packaging_dir, "src", "packaging"), self._codegen_dir) replace_in_file(self, os.path.join(self._codegen_dir, "utils.py"), "import packaging.version", "from .version import Version") @@ -172,8 +177,11 @@ def build(self): def package(self): copy(self, "LGPL-2.1-or-later.txt", os.path.join(self.source_folder, "LICENSES"), os.path.join(self.package_folder, "licenses")) - # pypa/packaging license files - copy(self, "LICENSE.*", os.path.join(self.source_folder, "LICENSES"), os.path.join(self.package_folder, "licenses")) + if self._vendor_pypa_packaging: + # pypa/packaging license files + copy(self, "LICENSE*", os.path.join(self.source_folder, "pypa-packaging"), os.path.join(self.package_folder, "licenses")) + os.rename(os.path.join(self.package_folder, "licenses", "LICENSE"), + os.path.join(self.package_folder, "licenses", "LICENSE.pypa-packaging")) meson = Meson(self) meson.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) From 85847de70962d8f05863aeb0b94285adde680335 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Mon, 15 Apr 2024 18:55:59 +0200 Subject: [PATCH 5/7] disable introspection it introduces a cyclic dependency with gobject-introspection --- recipes/glib/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index 77007545b9a80..cadc88564cae5 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -123,6 +123,9 @@ def generate(self): tc.project_options["xattr"] = "false" tc.project_options["tests"] = "false" tc.project_options["libelf"] = "enabled" if self.options.get_safe("with_elf") else "disabled" + if Version(self.version) >= "2.79.0": + # https://gitlab.gnome.org/GNOME/glib/-/commit/fe32c3f5c5155eab5cd4838867b0c95beefa2239 + tc.project_options["introspection"] = "disabled" tc.generate() def _patch_sources(self): From e9947fee2fe621088d84b74c68acaca8eaa5e128 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Mon, 15 Apr 2024 18:58:27 +0200 Subject: [PATCH 6/7] remove unused imports --- recipes/glib/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/glib/all/conanfile.py b/recipes/glib/all/conanfile.py index cadc88564cae5..62cdcf2aee361 100644 --- a/recipes/glib/all/conanfile.py +++ b/recipes/glib/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name, is_apple_os -from conan.tools.env import VirtualBuildEnv, Environment -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir, load, save +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain From d94cbd4fccf490f9b2225e4dfb6d8b432a00f620 Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Wed, 17 Apr 2024 07:55:14 +0200 Subject: [PATCH 7/7] Don't use PkgConfig helper because pkg-config is not installed on macos runners --- recipes/glib/all/test_package/conanfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/glib/all/test_package/conanfile.py b/recipes/glib/all/test_package/conanfile.py index 89fef354a476b..606ef373a6e44 100644 --- a/recipes/glib/all/test_package/conanfile.py +++ b/recipes/glib/all/test_package/conanfile.py @@ -2,7 +2,8 @@ from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain from conan.tools.env import Environment, VirtualBuildEnv, VirtualRunEnv -from conan.tools.gnu import PkgConfig, PkgConfigDeps +from conan.tools.gnu import PkgConfigDeps +import io import os @@ -54,6 +55,6 @@ def test(self): self.run(bin_path, env="conanrun") if self.settings.os != "Windows": - pkg_config = PkgConfig(self, "gio-2.0", pkg_config_path=self.generators_folder) - gdbus_codegen = pkg_config.variables["gdbus_codegen"] - self.run(f"{gdbus_codegen} -h") + mybuf = io.StringIO() + self.run(f"PKG_CONFIG_PATH={self.generators_folder} pkgconf --variable=gdbus_codegen gio-2.0", mybuf, env="conanbuild") + self.run(f"{mybuf.getvalue().strip()} -h")