Improved publishing

This commit is contained in:
Sven Heidemann 2021-03-09 22:26:54 +01:00
parent e8afff0e48
commit 87c6899949
2 changed files with 24 additions and 7 deletions

View File

@ -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/*"
]
}
}
}

View File

@ -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,7 +89,6 @@ 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))
elif os.path.isfile(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):