From 1b5d7c3c984cf119afa07245f4c85e8696f04b5a Mon Sep 17 00:00:00 2001 From: Eike S R Date: Wed, 24 Apr 2024 16:13:04 +0200 Subject: [PATCH 1/5] Update generator to work with python 3.12 `imp` has been removed in python 3.12. I switched to the replacement suggested in the release notes. See: https://docs.python.org/3.12/whatsnew/3.12.html#imp While I did not test previous python versions, the replacement function `types.ModuleType` is available since at least python 3.4 Signed-off-by: Eike S R --- flatdata-generator/flatdata/generator/engine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flatdata-generator/flatdata/generator/engine.py b/flatdata-generator/flatdata/generator/engine.py index 0c5ba0ba..d568f03a 100644 --- a/flatdata-generator/flatdata/generator/engine.py +++ b/flatdata-generator/flatdata/generator/engine.py @@ -3,7 +3,7 @@ See the LICENSE file in the root of this project for license details. ''' -import imp +import types from flatdata.generator.tree.builder import build_ast from flatdata.generator.tree.nodes.trivial.namespace import Namespace @@ -70,7 +70,7 @@ def render_python_module(self, module_name=None, archive_name=None): """ root_namespace = self._find_root_namespace(self.tree) module_code = self.render("py") - module = imp.new_module(module_name if module_name is not None else root_namespace.name) + module = types.ModuleType(module_name if module_name is not None else root_namespace.name) #pylint: disable=exec-used exec(module_code, module.__dict__) if archive_name is None: From b4f1cc75a61d952306e3708fe7dbb826133ceaea Mon Sep 17 00:00:00 2001 From: Eike S R Date: Thu, 25 Apr 2024 09:30:36 +0200 Subject: [PATCH 2/5] Fix warning in rust implementation tests Signed-off-by: Eike S R --- flatdata-rs/lib/src/arrayview.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flatdata-rs/lib/src/arrayview.rs b/flatdata-rs/lib/src/arrayview.rs index 67f86caf..ba23f04d 100644 --- a/flatdata-rs/lib/src/arrayview.rs +++ b/flatdata-rs/lib/src/arrayview.rs @@ -102,7 +102,7 @@ mod test { let x = { // test clone and lifetime of returned reference - let view_copy = view.clone(); + let view_copy = view; &view_copy[0] }; assert_eq!(65535, x.x()); @@ -110,7 +110,7 @@ mod test { let x = { // test clone and lifetime of returned reference - let view_copy = view.clone(); + let view_copy = view; view_copy.iter().next().unwrap() }; assert_eq!(65535, x.x()); From 1678f6d3485d776a5dc2842d90edbc2cd78b4eba Mon Sep 17 00:00:00 2001 From: Eike S R Date: Fri, 26 Apr 2024 13:55:05 +0200 Subject: [PATCH 3/5] Hack as `flatdata::generate` is not concurrency-safe `flatdata::generate` (see: `lib/src/generator.rs`) uses `pip` to install the flatdata generator. Concurrent calls to build it from source cause it to fail. Signed-off-by: Eike S R --- .github/workflows/rust.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 922283b0..6f8d776d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,12 +21,12 @@ jobs: # use generator from source export FLATDATA_GENERATOR_PATH=${PWD}/flatdata-generator cd flatdata-rs - cargo build --all-targets - cargo build --all-targets --all-features + cargo build --all-targets -j 1 + cargo build --all-targets --all-features -j 1 - name: Run tests run: | # use generator from source export FLATDATA_GENERATOR_PATH=${PWD}/flatdata-generator cd flatdata-rs - cargo test --all-targets - cargo test --all-targets --all-features \ No newline at end of file + cargo test --all-targets -j 1 + cargo test --all-targets --all-features -j 1 From a85f307862490a6d3b4d6819807e8b561a5e0e51 Mon Sep 17 00:00:00 2001 From: Eike S R Date: Wed, 12 Jun 2024 17:35:29 +0200 Subject: [PATCH 4/5] Changing buil system for parallel pip from source Changing the build system backend for the flatdata-generator to hatchling seems to allow parallel builds from source again. See: https://pip.pypa.io/en/stable/topics/local-project-installs/#build-artifacts on why it doesn't work with setuptools. TODO: Still needs some cleanup before being ready Signed-off-by: Eike S R --- .github/workflows/rust.yml | 8 +++---- flatdata-generator/pyproject.toml | 38 +++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6f8d776d..31c474bd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -21,12 +21,12 @@ jobs: # use generator from source export FLATDATA_GENERATOR_PATH=${PWD}/flatdata-generator cd flatdata-rs - cargo build --all-targets -j 1 - cargo build --all-targets --all-features -j 1 + cargo build --all-targets + cargo build --all-targets --all-features - name: Run tests run: | # use generator from source export FLATDATA_GENERATOR_PATH=${PWD}/flatdata-generator cd flatdata-rs - cargo test --all-targets -j 1 - cargo test --all-targets --all-features -j 1 + cargo test --all-targets + cargo test --all-targets --all-features diff --git a/flatdata-generator/pyproject.toml b/flatdata-generator/pyproject.toml index b5a3c468..532c4723 100644 --- a/flatdata-generator/pyproject.toml +++ b/flatdata-generator/pyproject.toml @@ -1,6 +1,36 @@ [build-system] -requires = [ - "setuptools>=42", - "wheel" +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "flatdata-generator" +version = "0.4.5" +description = "Generate source code for C++, Rust, Go or Python from a Flatdata schema file" +readme = "README.md" +license = "" +authors = [ + { name = "Flatdata Developers" }, ] -build-backend = "setuptools.build_meta" \ No newline at end of file +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", +] +dependencies = [ + "jinja2>=2.2", + "pyparsing>=2.0", +] + +[project.scripts] +flatdata-generator = "flatdata.generator.app:main" + +[project.urls] +Homepage = "https://github.com/heremaps/flatdata" + +[tool.hatch.build.targets.sdist] +include = [ + "/flatdata", +] + +[tool.hatch.build.targets.wheel] +packages = ["flatdata"] From 7d801627ecad38ab09dd713b6491109f9eac7e47 Mon Sep 17 00:00:00 2001 From: Eike S R Date: Fri, 14 Jun 2024 12:07:39 +0200 Subject: [PATCH 5/5] Remove setuptools config and bump version Signed-off-by: Eike S R --- flatdata-generator/pyproject.toml | 2 +- flatdata-generator/setup.py | 33 ------------------------------- 2 files changed, 1 insertion(+), 34 deletions(-) delete mode 100755 flatdata-generator/setup.py diff --git a/flatdata-generator/pyproject.toml b/flatdata-generator/pyproject.toml index 532c4723..dc537248 100644 --- a/flatdata-generator/pyproject.toml +++ b/flatdata-generator/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "flatdata-generator" -version = "0.4.5" +version = "0.4.6" description = "Generate source code for C++, Rust, Go or Python from a Flatdata schema file" readme = "README.md" license = "" diff --git a/flatdata-generator/setup.py b/flatdata-generator/setup.py deleted file mode 100755 index 19cb26d5..00000000 --- a/flatdata-generator/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -import os -from setuptools import find_packages, setup - -SOURCE_FILEPATH = os.path.dirname(os.path.abspath(__file__)) - -setup( - name="flatdata-generator", - version="0.4.5", - author="Flatdata Developers", - description="Generate source code for C++, Rust, Go or Python from a Flatdata schema file", - long_description=open(os.path.join(SOURCE_FILEPATH, "README.md")).read(), - long_description_content_type="text/markdown", - url="https://github.com/heremaps/flatdata", - # we can't use find_namespace_packages as it is only a very recent addition to setuptools - packages=["flatdata." + p for p in find_packages("flatdata")], - package_data={ - "": ["*.jinja2"], - }, - entry_points={ - "console_scripts": ["flatdata-generator=flatdata.generator.app:main"], - }, - setup_requires=["wheel"], - install_requires=[ - "pyparsing>=2.0", - "jinja2>=2.2", - ], - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - ], -)