diff --git a/CHANGELOG.md b/CHANGELOG.md index d21e9a4..8ede06c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.1.1] - 2024-06-28 + +### Fixed + +- An issue where the `__everything__.py` file was missing the first character of + the package name if the build root ended with a slash (or backslash) + + ## [5.1.0] - 2024-04-30 ### Added diff --git a/neobuilder/__init__.py b/neobuilder/__init__.py index a5e4513..40f5033 100644 --- a/neobuilder/__init__.py +++ b/neobuilder/__init__.py @@ -1 +1 @@ -__version__ = '5.1.0' +__version__ = '5.1.1' diff --git a/neobuilder/neobuilder/__init__.py b/neobuilder/neobuilder/__init__.py index c17380e..7447f7a 100644 --- a/neobuilder/neobuilder/__init__.py +++ b/neobuilder/neobuilder/__init__.py @@ -12,6 +12,7 @@ from grpc_tools import protoc from . import render +import pathlib from ccptools.tpu import strimp @@ -387,11 +388,14 @@ def add_everything(self): line_buffer = [] + broot = pathlib.Path(self.build_root).absolute() + for (dirpath, dirnames, filenames) in os.walk(self.build_path): for f in filenames: if f.endswith('.py') and not f.endswith('__.py'): - fpath = os.path.join(dirpath, f).replace('\\', '/') - package_name = fpath[len(self.build_root)+1:-3].replace('/', '.') + fpath = pathlib.Path(dirpath) / f + rel_path = fpath.relative_to(broot) + package_name = str(rel_path)[:-3].replace('\\', '/').replace('/', '.') line_buffer.append(f'import {package_name}') counter += 1 line_buffer.sort() diff --git a/tests/test_services.py b/tests/test_services.py index 6104c82..f9e5394 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -17,7 +17,7 @@ HERE = os.path.dirname(__file__) PROTO_ROOT = os.path.join(HERE, 'res', 'proto') -BUILD_ROOT = os.path.join(HERE, 'res', 'build') +BUILD_ROOT = os.path.join(HERE, 'res', 'build/') class ServiceTest(unittest.TestCase):