2021.4.6 #25

Merged
edraft merged 57 commits from 2021.4.6 into 2021.4.post1 2021-04-11 15:54:38 +02:00
6 changed files with 76 additions and 42 deletions
Showing only changes of commit 2552f1d43c - Show all commits

View File

@ -1,11 +1,20 @@
upload:
prod:
twine upload --repository-url https://pip.sh-edraft.de dist/publish/setup/*
twine upload -r pip.sh-edraft.de dist/publish/setup/*
cpl:
twine upload --repository-url https://pip.sh-edraft.de dist/sh_cpl/publish/setup/*
twine upload -r pip.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
cli:
twine upload --repository-url https://pip.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
twine upload -r pip.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
dev:
twine upload --repository-url https://pip-dev.sh-edraft.de dist/publish/setup/*
twine upload -r pip-dev.sh-edraft.de dist/publish/setup/*
cpl:
twine upload --repository-url https://pip-dev.sh-edraft.de dist/sh_cpl/publish/setup/*
twine upload -r pip-dev.sh-edraft.de dist/sh_cpl/publish/setup/*
cli:
twine upload --repository-url https://pip-dev.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
twine upload -r pip-dev.sh-edraft.de dist/sh_cpl-cli/publish/setup/*
install:
pip install --extra-index-url https://pip.sh-edraft.de/ sh_cpl

View File

@ -38,7 +38,7 @@
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "",
"EntryPoint": "cpl",
"EntryPoint": "",
"IncludePackageData": true,
"Included": [
"*/templates"
@ -48,10 +48,6 @@
"*/logs",
"*/tests"
],
"PackageData": {
"cpl_cli": [
"*.json"
]
}
"PackageData": {}
}
}

View File

@ -72,6 +72,8 @@ class CommandHandler(ABC):
if index < len(sys.argv):
args = sys.argv[index:]
self._config.add_configuration('ProjectName', project_name)
if project_name not in workspace.projects:
Error.error(
f'Project {project_name} not found.'

View File

@ -16,7 +16,7 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl==2021.4.0"
"sh_cpl==2021.4.dev1"
],
"PythonVersion": ">=3.8",
"PythonPath": {},
@ -26,7 +26,7 @@
"ProjectType": "console",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "main",
"Main": "cpl_cli.main",
"EntryPoint": "cpl",
"IncludePackageData": true,
"Included": [

View File

@ -7,6 +7,7 @@ import setuptools
from packaging import version
from setuptools import sandbox
from cpl.configuration.configuration_abc import ConfigurationABC
from cpl.console.foreground_color_enum import ForegroundColorEnum
from cpl.console.console import Console
from cpl.environment.application_environment_abc import ApplicationEnvironmentABC
@ -19,15 +20,18 @@ from cpl_cli.templates.publish.setup_template import SetupTemplate
class PublisherService(PublisherABC):
def __init__(self, env: ApplicationEnvironmentABC, project: ProjectSettings, build: BuildSettings):
def __init__(self, config: ConfigurationABC,
env: ApplicationEnvironmentABC, project: ProjectSettings, build: BuildSettings):
"""
Service to build or publish files for distribution
:param config:
:param env:
:param project:
:param build:
"""
PublisherABC.__init__(self)
self._config = config
self._env = env
self._project_settings = project
self._build_settings = build
@ -130,6 +134,21 @@ class PublisherService(PublisherABC):
return False
def _is_file_excluded(self, file: str) -> bool:
"""
Checks if the file is excluded
:param file:
:return:
"""
for excluded in self._build_settings.excluded:
if excluded.startswith('*'):
excluded = excluded.replace('*', '')
if excluded in file and not self._is_path_included(file):
return True
return False
def _read_sources(self):
"""
Reads all source files and save included files
@ -152,8 +171,8 @@ class PublisherService(PublisherABC):
for file in f:
relative_path = os.path.relpath(r)
file_path = os.path.join(relative_path, os.path.relpath(file))
if self._is_path_excluded(relative_path):
break
if self._is_file_excluded(file_path):
continue
if len(d) > 0:
for directory in d:
@ -289,6 +308,8 @@ class PublisherService(PublisherABC):
if os.path.isfile(setup_file):
os.remove(setup_file)
entry_points = {}
if self._build_settings.main != "":
main = None
try:
main_name = self._build_settings.main
@ -315,6 +336,12 @@ class PublisherService(PublisherABC):
mod_name = main.__name__
func_name = main.main.__name__
entry_points = {
'console_scripts': [
f'{self._build_settings.entry_point} = {mod_name}:{func_name}'
]
}
with open(setup_file, 'w+') as setup_py:
setup_string = stringTemplate(SetupTemplate.get_setup_py()).substitute(
Name=self._project_settings.name,
@ -328,11 +355,7 @@ class PublisherService(PublisherABC):
Description=self._project_settings.description,
PyRequires=self._project_settings.python_version,
Dependencies=self._project_settings.dependencies,
EntryPoints={
'console_scripts': [
f'{self._build_settings.entry_point} = {mod_name}:{func_name}'
]
},
EntryPoints=entry_points,
PackageData=self._build_settings.package_data
)
setup_py.write(setup_string)
@ -385,6 +408,7 @@ class PublisherService(PublisherABC):
3. Copies all included source files to dist_path/build
:return:
"""
self.exclude(f'*/{self._config.get_configuration("ProjectName")}.json')
self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'build'))
Console.spinner('Reading source files:', self._read_sources, text_foreground_color=ForegroundColorEnum.green,
@ -405,6 +429,7 @@ class PublisherService(PublisherABC):
4. Remove all included source from dist_path/publish
:return:
"""
self.exclude(f'*/{self._config.get_configuration("ProjectName")}.json')
self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'publish'))
Console.write_line('Build:')

View File

@ -59,7 +59,9 @@ class Startup(StartupABC):
ConsoleArgument('', 'console', ['c', 'C'], ' '),
ConsoleArgument('', 'library', ['l', 'L'], ' ')
]))
self._configuration.add_console_argument(ConsoleArgument('', 'publish', ['p', 'P'], ''))
self._configuration.add_console_argument(
ConsoleArgument('', 'publish', ['p', 'P'], ' ', is_value_token_optional=True)
)
self._configuration.add_console_argument(
ConsoleArgument('', 'start', ['s', 'S'], ' ', is_value_token_optional=True)
)