2022.6.10 - Dev dependencies #86

Merged
edraft merged 5 commits from 2022.6.10 into 2022.6 2022-06-27 20:18:25 +02:00
7 changed files with 35 additions and 6 deletions
Showing only changes of commit cbd2964f42 - Show all commits

View File

@ -42,6 +42,7 @@ class InstallService(CommandABC):
self._is_simulation = False self._is_simulation = False
self._is_virtual = False self._is_virtual = False
self._is_dev = False
self._project_file = f'{self._project_settings.name}.json' self._project_file = f'{self._project_settings.name}.json'
@ -107,7 +108,11 @@ class InstallService(CommandABC):
package_version = package.split('==')[1] package_version = package.split('==')[1]
to_remove_list = [] to_remove_list = []
for dependency in self._project_settings.dependencies: deps = self._project_settings.dependencies
if self._is_dev:
deps = self._project_settings.dev_dependencies
for dependency in deps:
dependency_version = '' dependency_version = ''
if '==' in dependency: if '==' in dependency:
@ -121,7 +126,10 @@ class InstallService(CommandABC):
is_already_in_project = True is_already_in_project = True
for to_remove in to_remove_list: for to_remove in to_remove_list:
self._project_settings.dependencies.remove(to_remove) if self._is_dev:
self._project_settings.dev_dependencies.remove(to_remove)
else:
self._project_settings.dependencies.remove(to_remove)
local_package = Pip.get_package(package) local_package = Pip.get_package(package)
if local_package is not None and local_package in self._project_settings.dependencies: if local_package is not None and local_package in self._project_settings.dependencies:
@ -133,9 +141,9 @@ class InstallService(CommandABC):
return return
Console.spinner( Console.spinner(
f'Installing: {package}', f'Installing: {package}' if not self._is_dev else f'Installing dev: {package}',
Pip.install if not self._is_virtual else self._wait, package if not self._is_virtual else 2, Pip.install if not self._is_virtual else self._wait, package if not self._is_virtual else 2,
source=self._cli_settings.pip_path if 'cpl-' in package else None, source=self._cli_settings.pip_path if 'cpl-' in package or 'cpl_' in package else None,
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
text_foreground_color=ForegroundColorEnum.green, text_foreground_color=ForegroundColorEnum.green,
@ -165,7 +173,10 @@ class InstallService(CommandABC):
if '\r' in new_name: if '\r' in new_name:
new_name = new_name.replace('\r', '') new_name = new_name.replace('\r', '')
self._project_settings.dependencies.append(new_name) if self._is_dev:
self._project_settings.dev_dependencies.append(new_name)
else:
self._project_settings.dependencies.append(new_name)
if not self._is_simulation: if not self._is_simulation:
config = { config = {
@ -185,6 +196,10 @@ class InstallService(CommandABC):
:param args: :param args:
:return: :return:
""" """
if 'dev' in args:
self._is_dev = True
args.remove('dev')
if 'virtual' in args: if 'virtual' in args:
self._is_virtual = True self._is_virtual = True
args.remove('virtual') args.remove('virtual')

View File

@ -28,6 +28,7 @@ class ProjectSettings(ConfigurationModelABC):
self._license_name: Optional[str] = None self._license_name: Optional[str] = None
self._license_description: Optional[str] = None self._license_description: Optional[str] = None
self._dependencies: Optional[list[str]] = None self._dependencies: Optional[list[str]] = None
self._dev_dependencies: Optional[list[str]] = None
self._python_version: Optional[str] = None self._python_version: Optional[str] = None
self._python_path: Optional[str] = None self._python_path: Optional[str] = None
self._python_executable: Optional[str] = None self._python_executable: Optional[str] = None
@ -81,6 +82,10 @@ class ProjectSettings(ConfigurationModelABC):
def dependencies(self) -> list[str]: def dependencies(self) -> list[str]:
return self._dependencies return self._dependencies
@property
def dev_dependencies(self) -> list[str]:
return self._dev_dependencies
@property @property
def python_version(self) -> str: def python_version(self) -> str:
return self._python_version return self._python_version
@ -111,6 +116,9 @@ class ProjectSettings(ConfigurationModelABC):
self._license_name = settings[ProjectSettingsNameEnum.license_name.value] self._license_name = settings[ProjectSettingsNameEnum.license_name.value]
self._license_description = settings[ProjectSettingsNameEnum.license_description.value] self._license_description = settings[ProjectSettingsNameEnum.license_description.value]
self._dependencies = settings[ProjectSettingsNameEnum.dependencies.value] self._dependencies = settings[ProjectSettingsNameEnum.dependencies.value]
if ProjectSettingsNameEnum.dev_dependencies.value not in settings:
settings[ProjectSettingsNameEnum.dev_dependencies.value] = []
self._dev_dependencies = settings[ProjectSettingsNameEnum.dev_dependencies.value]
self._python_version = settings[ProjectSettingsNameEnum.python_version.value] self._python_version = settings[ProjectSettingsNameEnum.python_version.value]
self._python_path = settings[ProjectSettingsNameEnum.python_path.value] self._python_path = settings[ProjectSettingsNameEnum.python_path.value]

View File

@ -14,6 +14,7 @@ class ProjectSettingsNameEnum(Enum):
license_name = 'LicenseName' license_name = 'LicenseName'
license_description = 'LicenseDescription' license_description = 'LicenseDescription'
dependencies = 'Dependencies' dependencies = 'Dependencies'
dev_dependencies = 'DevDependencies'
python_version = 'PythonVersion' python_version = 'PythonVersion'
python_path = 'PythonPath' python_path = 'PythonPath'
classifiers = 'Classifiers' classifiers = 'Classifiers'

View File

@ -26,6 +26,7 @@ class SettingsHelper:
ProjectSettingsNameEnum.license_name.value: project.license_name, ProjectSettingsNameEnum.license_name.value: project.license_name,
ProjectSettingsNameEnum.license_description.value: project.license_description, ProjectSettingsNameEnum.license_description.value: project.license_description,
ProjectSettingsNameEnum.dependencies.value: project.dependencies, ProjectSettingsNameEnum.dependencies.value: project.dependencies,
ProjectSettingsNameEnum.dev_dependencies.value: project.dev_dependencies,
ProjectSettingsNameEnum.python_version.value: project.python_version, ProjectSettingsNameEnum.python_version.value: project.python_version,
ProjectSettingsNameEnum.python_path.value: project.python_path, ProjectSettingsNameEnum.python_path.value: project.python_path,
ProjectSettingsNameEnum.classifiers.value: project.classifiers ProjectSettingsNameEnum.classifiers.value: project.classifiers

View File

@ -40,6 +40,7 @@ class StartupArgumentExtension(StartupExtensionABC):
.add_console_argument(ArgumentTypeEnum.Variable, '', 'thread', ['t', 'T'], ' ') \ .add_console_argument(ArgumentTypeEnum.Variable, '', 'thread', ['t', 'T'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'validator', ['v', 'V'], ' ') .add_console_argument(ArgumentTypeEnum.Variable, '', 'validator', ['v', 'V'], ' ')
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'install', ['i', 'I'], InstallService, True, validators=[ProjectValidator]) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'install', ['i', 'I'], InstallService, True, validators=[ProjectValidator]) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'dev', ['d', 'D']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) .add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'new', ['n', 'N'], NewService, True) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'new', ['n', 'N'], NewService, True) \
@ -58,6 +59,7 @@ class StartupArgumentExtension(StartupExtensionABC):
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'run', [], RunService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'run', [], RunService, True, validators=[ProjectValidator])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'start', ['s', 'S'], StartService, True, validators=[ProjectValidator]) config.create_console_argument(ArgumentTypeEnum.Executable, '', 'start', ['s', 'S'], StartService, True, validators=[ProjectValidator])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'uninstall', ['ui', 'UI'], UninstallService, True, validators=[ProjectValidator]) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'uninstall', ['ui', 'UI'], UninstallService, True, validators=[ProjectValidator]) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'dev', ['d', 'D']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \ .add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S']) .add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'update', ['u', 'U'], UpdateService, True, validators=[ProjectValidator]) \ config.create_console_argument(ArgumentTypeEnum.Executable, '', 'update', ['u', 'U'], UpdateService, True, validators=[ProjectValidator]) \

View File

@ -126,7 +126,6 @@ class Pip:
pip_args.append(source) pip_args.append(source)
pip_args.append(package) pip_args.append(package)
print(pip_args)
subprocess.run(pip_args, stdout=stdout, stderr=stderr, env=cls._env) subprocess.run(pip_args, stdout=stdout, stderr=stderr, env=cls._env)
@classmethod @classmethod

View File

@ -18,6 +18,9 @@
"Dependencies": [ "Dependencies": [
"cpl_core==2022.6.1" "cpl_core==2022.6.1"
], ],
"DevDependencies": [
"cpl-cli==2022.6.17.dev10"
],
"PythonVersion": ">=3.10", "PythonVersion": ">=3.10",
"PythonPath": { "PythonPath": {
"linux": "../../venv/bin/python", "linux": "../../venv/bin/python",