0.3 #146

Merged
edraft merged 359 commits from 0.3 into master 2023-01-12 07:04:40 +01:00
3 changed files with 62 additions and 5 deletions
Showing only changes of commit 7d4f3e9541 - Show all commits

View File

@ -21,6 +21,6 @@ class Application(ApplicationABC):
def main(self):
Console.write_line('KDB Post-Build:')
Console.spinner(f'Removing unnecessary configs', self._remove_config.remove)
# Console.spinner(f'Creating requirements file for pip', self._deps.create)
Console.spinner(f'Creating requirements file for pip', self._deps.create)

View File

@ -1,7 +1,64 @@
import os
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings, BuildSettings
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.environment import ApplicationEnvironmentABC
from post_build.post_build_settings import PostBuildSettings
class Dependencies:
def __init__(self):
pass
def __init__(
self,
config: ConfigurationABC,
env: ApplicationEnvironmentABC,
ws: WorkspaceSettings,
project: ProjectSettings,
build: BuildSettings,
post_build: PostBuildSettings
):
self._config = config
self._env = env
self._workspace = ws
self._project = project
self._build = build
self._post_build = post_build
self._dependencies = {}
def _add_dependencies(self, deps: list[str]):
for d in deps:
d_name = d
if '>=' in d:
d_name = d.split('>=')[0]
if '<=' in d:
d_name = d.split('<=')[0]
if '==' in d:
d_name = d.split('==')[0]
if d_name in self._dependencies:
continue
self._dependencies[d_name] = d
def create(self):
pass
dist_path = os.path.abspath(os.path.join(
self._env.working_directory,
os.path.dirname(self._workspace.projects[self._project.name]),
self._build.output_path,
self._project.name,
'build'
))
for project in self._workspace.projects:
project_file = os.path.join(self._env.working_directory, self._workspace.projects[project])
self._config.add_json_file(project_file, output=False, optional=False)
project: ProjectSettings = self._config.get_configuration(ProjectSettings)
self._add_dependencies(project.dependencies)
with open(f'{dist_path}/requirements.txt', 'w+', encoding='utf-8') as f:
for dependency in self._dependencies:
f.write(f'{self._dependencies[dependency]}\n')
f.close()

View File

@ -9,7 +9,7 @@ from post_build.post_build_settings import PostBuildSettings
class RemoveConfig:
def __init__(self, env: ApplicationEnvironmentABC, ws: WorkspaceSettings, project: ProjectSettings, build: BuildSettings, post_build: PostBuildSettings,):
def __init__(self, env: ApplicationEnvironmentABC, ws: WorkspaceSettings, project: ProjectSettings, build: BuildSettings, post_build: PostBuildSettings):
self._env = env
self._workspace = ws