From 87c6899949b5bb45a4b627c09955d79410babf12 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 9 Mar 2021 22:26:54 +0100 Subject: [PATCH] Improved publishing --- cpl.json | 14 ++++++++++++-- src/cpl_cli/publish/publisher.py | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/cpl.json b/cpl.json index 4deb47b4..989f10af 100644 --- a/cpl.json +++ b/cpl.json @@ -32,13 +32,23 @@ "EntryPoint": "cpl", "IncludePackageData": "False", "Included": [ - "src/cpl_cli/templates/new/console/src/tests" + "src/cpl_cli/templates/new/console/src/tests/" ], "Excluded": [ "*/__pycache__", "*/logs", "*/tests" ], - "PackageData": {} + "PackageData": { + "cpl_cli": [ + "templates/*", + "templates/build/*", + "templates/new/*", + "templates/new/console/*", + "templates/new/console/src/*", + "templates/new/console/src/tests/*", + "templates/publish/*" + ] + } } } \ No newline at end of file diff --git a/src/cpl_cli/publish/publisher.py b/src/cpl_cli/publish/publisher.py index b0f4e713..7382ba7c 100644 --- a/src/cpl_cli/publish/publisher.py +++ b/src/cpl_cli/publish/publisher.py @@ -40,7 +40,7 @@ class Publisher(PublisherABC): @staticmethod def _get_module_name_from_dirs(file: str) -> str: if 'src/' in file: - file = file.replace('src/', '') + file = file.replace('src/', '', 1) dirs = os.path.dirname(file).split('/') for d in dirs: @@ -89,8 +89,7 @@ class Publisher(PublisherABC): relative_path = os.path.relpath(r) file_path = os.path.join(relative_path, os.path.relpath(sub_file)) - if not self._is_path_excluded(relative_path): - self._included_files.append(os.path.relpath(file_path)) + self._included_files.append(os.path.relpath(file_path)) elif os.path.isfile(rel_path): self._included_files.append(rel_path) @@ -114,7 +113,7 @@ class Publisher(PublisherABC): def _create_packages(self): for file in self._included_files: - if file.endswith('__init__.py'): + if file.endswith('console_src_tests.__init__.py'): template_content = '' module_file_lines: list[str] = [] @@ -175,7 +174,7 @@ class Publisher(PublisherABC): for file in self._included_files: dist_file = file if 'src/' in dist_file: - dist_file = dist_file.replace('src/', '') + dist_file = dist_file.replace('src/', '', 1) output_path = os.path.join(build_path, os.path.dirname(dist_file)) output_file = os.path.join(build_path, dist_file) @@ -215,6 +214,14 @@ class Publisher(PublisherABC): if os.path.isdir(path): shutil.rmtree(path) + @staticmethod + def _package_files(directory): + paths = [] + for (path, directories, filenames) in os.walk(directory): + for filename in filenames: + paths.append(os.path.join('..', path, filename)) + return paths + def _create_setup(self): setup_file = os.path.join(self._output_path, 'setup.py') if os.path.isfile(setup_file):