2021.4.6 #25
17
docs/pip.txt
17
docs/pip.txt
@ -1,11 +1,20 @@
|
|||||||
upload:
|
upload:
|
||||||
prod:
|
prod:
|
||||||
twine upload --repository-url https://pip.sh-edraft.de dist/publish/setup/*
|
cpl:
|
||||||
twine upload -r pip.sh-edraft.de dist/publish/setup/*
|
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:
|
dev:
|
||||||
twine upload --repository-url https://pip-dev.sh-edraft.de dist/publish/setup/*
|
cpl:
|
||||||
twine upload -r pip-dev.sh-edraft.de dist/publish/setup/*
|
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:
|
install:
|
||||||
pip install --extra-index-url https://pip.sh-edraft.de/ sh_cpl
|
pip install --extra-index-url https://pip.sh-edraft.de/ sh_cpl
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
"SourcePath": "",
|
"SourcePath": "",
|
||||||
"OutputPath": "../../dist",
|
"OutputPath": "../../dist",
|
||||||
"Main": "",
|
"Main": "",
|
||||||
"EntryPoint": "cpl",
|
"EntryPoint": "",
|
||||||
"IncludePackageData": true,
|
"IncludePackageData": true,
|
||||||
"Included": [
|
"Included": [
|
||||||
"*/templates"
|
"*/templates"
|
||||||
@ -48,10 +48,6 @@
|
|||||||
"*/logs",
|
"*/logs",
|
||||||
"*/tests"
|
"*/tests"
|
||||||
],
|
],
|
||||||
"PackageData": {
|
"PackageData": {}
|
||||||
"cpl_cli": [
|
|
||||||
"*.json"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -72,6 +72,8 @@ class CommandHandler(ABC):
|
|||||||
if index < len(sys.argv):
|
if index < len(sys.argv):
|
||||||
args = sys.argv[index:]
|
args = sys.argv[index:]
|
||||||
|
|
||||||
|
self._config.add_configuration('ProjectName', project_name)
|
||||||
|
|
||||||
if project_name not in workspace.projects:
|
if project_name not in workspace.projects:
|
||||||
Error.error(
|
Error.error(
|
||||||
f'Project {project_name} not found.'
|
f'Project {project_name} not found.'
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"LicenseName": "MIT",
|
"LicenseName": "MIT",
|
||||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||||
"Dependencies": [
|
"Dependencies": [
|
||||||
"sh_cpl==2021.4.0"
|
"sh_cpl==2021.4.dev1"
|
||||||
],
|
],
|
||||||
"PythonVersion": ">=3.8",
|
"PythonVersion": ">=3.8",
|
||||||
"PythonPath": {},
|
"PythonPath": {},
|
||||||
@ -26,7 +26,7 @@
|
|||||||
"ProjectType": "console",
|
"ProjectType": "console",
|
||||||
"SourcePath": "",
|
"SourcePath": "",
|
||||||
"OutputPath": "../../dist",
|
"OutputPath": "../../dist",
|
||||||
"Main": "main",
|
"Main": "cpl_cli.main",
|
||||||
"EntryPoint": "cpl",
|
"EntryPoint": "cpl",
|
||||||
"IncludePackageData": true,
|
"IncludePackageData": true,
|
||||||
"Included": [
|
"Included": [
|
||||||
|
@ -7,6 +7,7 @@ import setuptools
|
|||||||
from packaging import version
|
from packaging import version
|
||||||
from setuptools import sandbox
|
from setuptools import sandbox
|
||||||
|
|
||||||
|
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||||
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
from cpl.console.foreground_color_enum import ForegroundColorEnum
|
||||||
from cpl.console.console import Console
|
from cpl.console.console import Console
|
||||||
from cpl.environment.application_environment_abc import ApplicationEnvironmentABC
|
from cpl.environment.application_environment_abc import ApplicationEnvironmentABC
|
||||||
@ -19,15 +20,18 @@ from cpl_cli.templates.publish.setup_template import SetupTemplate
|
|||||||
|
|
||||||
class PublisherService(PublisherABC):
|
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
|
Service to build or publish files for distribution
|
||||||
|
:param config:
|
||||||
:param env:
|
:param env:
|
||||||
:param project:
|
:param project:
|
||||||
:param build:
|
:param build:
|
||||||
"""
|
"""
|
||||||
PublisherABC.__init__(self)
|
PublisherABC.__init__(self)
|
||||||
|
|
||||||
|
self._config = config
|
||||||
self._env = env
|
self._env = env
|
||||||
self._project_settings = project
|
self._project_settings = project
|
||||||
self._build_settings = build
|
self._build_settings = build
|
||||||
@ -130,6 +134,21 @@ class PublisherService(PublisherABC):
|
|||||||
|
|
||||||
return False
|
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):
|
def _read_sources(self):
|
||||||
"""
|
"""
|
||||||
Reads all source files and save included files
|
Reads all source files and save included files
|
||||||
@ -152,8 +171,8 @@ class PublisherService(PublisherABC):
|
|||||||
for file in f:
|
for file in f:
|
||||||
relative_path = os.path.relpath(r)
|
relative_path = os.path.relpath(r)
|
||||||
file_path = os.path.join(relative_path, os.path.relpath(file))
|
file_path = os.path.join(relative_path, os.path.relpath(file))
|
||||||
if self._is_path_excluded(relative_path):
|
if self._is_file_excluded(file_path):
|
||||||
break
|
continue
|
||||||
|
|
||||||
if len(d) > 0:
|
if len(d) > 0:
|
||||||
for directory in d:
|
for directory in d:
|
||||||
@ -289,6 +308,8 @@ class PublisherService(PublisherABC):
|
|||||||
if os.path.isfile(setup_file):
|
if os.path.isfile(setup_file):
|
||||||
os.remove(setup_file)
|
os.remove(setup_file)
|
||||||
|
|
||||||
|
entry_points = {}
|
||||||
|
if self._build_settings.main != "":
|
||||||
main = None
|
main = None
|
||||||
try:
|
try:
|
||||||
main_name = self._build_settings.main
|
main_name = self._build_settings.main
|
||||||
@ -315,6 +336,12 @@ class PublisherService(PublisherABC):
|
|||||||
mod_name = main.__name__
|
mod_name = main.__name__
|
||||||
func_name = main.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:
|
with open(setup_file, 'w+') as setup_py:
|
||||||
setup_string = stringTemplate(SetupTemplate.get_setup_py()).substitute(
|
setup_string = stringTemplate(SetupTemplate.get_setup_py()).substitute(
|
||||||
Name=self._project_settings.name,
|
Name=self._project_settings.name,
|
||||||
@ -328,11 +355,7 @@ class PublisherService(PublisherABC):
|
|||||||
Description=self._project_settings.description,
|
Description=self._project_settings.description,
|
||||||
PyRequires=self._project_settings.python_version,
|
PyRequires=self._project_settings.python_version,
|
||||||
Dependencies=self._project_settings.dependencies,
|
Dependencies=self._project_settings.dependencies,
|
||||||
EntryPoints={
|
EntryPoints=entry_points,
|
||||||
'console_scripts': [
|
|
||||||
f'{self._build_settings.entry_point} = {mod_name}:{func_name}'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
PackageData=self._build_settings.package_data
|
PackageData=self._build_settings.package_data
|
||||||
)
|
)
|
||||||
setup_py.write(setup_string)
|
setup_py.write(setup_string)
|
||||||
@ -385,6 +408,7 @@ class PublisherService(PublisherABC):
|
|||||||
3. Copies all included source files to dist_path/build
|
3. Copies all included source files to dist_path/build
|
||||||
:return:
|
: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'))
|
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,
|
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
|
4. Remove all included source from dist_path/publish
|
||||||
:return:
|
: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'))
|
self._output_path = os.path.abspath(os.path.join(self._output_path, self._project_settings.name, 'publish'))
|
||||||
|
|
||||||
Console.write_line('Build:')
|
Console.write_line('Build:')
|
||||||
|
@ -59,7 +59,9 @@ class Startup(StartupABC):
|
|||||||
ConsoleArgument('', 'console', ['c', 'C'], ' '),
|
ConsoleArgument('', 'console', ['c', 'C'], ' '),
|
||||||
ConsoleArgument('', 'library', ['l', 'L'], ' ')
|
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(
|
self._configuration.add_console_argument(
|
||||||
ConsoleArgument('', 'start', ['s', 'S'], ' ', is_value_token_optional=True)
|
ConsoleArgument('', 'start', ['s', 'S'], ' ', is_value_token_optional=True)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user