Compare commits

...

2 Commits

Author SHA1 Message Date
f8f5030976 change imports 2023-10-07 12:22:40 +08:00
b686540512 rename app module, nest cli in app 2023-10-07 12:22:30 +08:00
15 changed files with 47 additions and 46 deletions

View File

@ -15,8 +15,8 @@
import os import os
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from app.deploy import get_stack_status
from decouple import config from decouple import config
from .deploy import get_stack_status
def get_stack(config, stack): def get_stack(config, stack):

View File

@ -27,8 +27,8 @@ import subprocess
import click import click
import importlib.resources import importlib.resources
from pathlib import Path from pathlib import Path
from app.util import include_exclude_check, get_parsed_stack_config from .util import include_exclude_check, get_parsed_stack_config
from app.base import get_npm_registry_url from .base import get_npm_registry_url
# TODO: find a place for this # TODO: find a place for this
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)" # epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
@ -67,7 +67,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
print('Dev root directory doesn\'t exist, creating') print('Dev root directory doesn\'t exist, creating')
# See: https://stackoverflow.com/a/20885799/1701505 # See: https://stackoverflow.com/a/20885799/1701505
from app import data from . import data
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file: with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
all_containers = container_list_file.read().splitlines() all_containers = container_list_file.read().splitlines()

View File

@ -25,8 +25,8 @@ from decouple import config
import click import click
import importlib.resources import importlib.resources
from python_on_whales import docker, DockerException from python_on_whales import docker, DockerException
from app.base import get_stack from .base import get_stack
from app.util import include_exclude_check, get_parsed_stack_config from .util import include_exclude_check, get_parsed_stack_config
builder_js_image_name = "cerc/builder-js:local" builder_js_image_name = "cerc/builder-js:local"
@ -83,7 +83,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
os.makedirs(build_root_path) os.makedirs(build_root_path)
# See: https://stackoverflow.com/a/20885799/1701505 # See: https://stackoverflow.com/a/20885799/1701505
from app import data from . import data
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file: with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
all_packages = package_list_file.read().splitlines() all_packages = package_list_file.read().splitlines()

View File

@ -15,14 +15,14 @@
import click import click
from app.command_types import CommandOptions from .command_types import CommandOptions
from app import setup_repositories from . import setup_repositories
from app import build_containers from . import build_containers
from app import build_npms from . import build_npms
from app import deploy from . import deploy
from app import version from . import version
from app import deployment from . import deployment
from app import update from . import update
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])

View File

@ -13,11 +13,11 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>. # along with this program. If not, see <http:#www.gnu.org/licenses/>.
from app.util import get_yaml from laconic_stack_orchestrator.util import get_yaml
from app.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext from laconic_stack_orchestrator.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext
from app.stack_state import State from laconic_stack_orchestrator.stack_state import State
from app.deploy_util import VolumeMapping, run_container_command from laconic_stack_orchestrator.deploy_util import VolumeMapping, run_container_command
from app.command_types import CommandOptions from laconic_stack_orchestrator.command_types import CommandOptions
from enum import Enum from enum import Enum
from pathlib import Path from pathlib import Path
from shutil import copyfile, copytree from shutil import copyfile, copytree

View File

@ -13,10 +13,10 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>. # along with this program. If not, see <http:#www.gnu.org/licenses/>.
from app.util import get_yaml from laconic_stack_orchestrator.util import get_yaml
from app.deploy_types import DeployCommandContext from laconic_stack_orchestrator.deploy_types import DeployCommandContext
from app.stack_state import State from laconic_stack_orchestrator.stack_state import State
from app.deploy_util import VolumeMapping, run_container_command from laconic_stack_orchestrator.deploy_util import VolumeMapping, run_container_command
from pathlib import Path from pathlib import Path
default_spec_file_content = """config: default_spec_file_content = """config:

View File

@ -26,11 +26,11 @@ import subprocess
from python_on_whales import DockerClient, DockerException from python_on_whales import DockerClient, DockerException
import click import click
from pathlib import Path from pathlib import Path
from app.util import include_exclude_check, get_parsed_stack_config, global_options2 from .util import include_exclude_check, get_parsed_stack_config, global_options2
from app.deploy_types import ClusterContext, DeployCommandContext from .deploy_types import ClusterContext, DeployCommandContext
from app.deployment_create import create as deployment_create from .deployment_create import create as deployment_create
from app.deployment_create import init as deployment_init from .deployment_create import init as deployment_init
from app.deployment_create import setup as deployment_setup from .deployment_create import setup as deployment_setup
@click.group() @click.group()
@ -263,7 +263,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
print(f"Using cluster name: {cluster}") print(f"Using cluster name: {cluster}")
# See: https://stackoverflow.com/a/20885799/1701505 # See: https://stackoverflow.com/a/20885799/1701505
from app import data from . import data
with resources.open_text(data, "pod-list.txt") as pod_list_file: with resources.open_text(data, "pod-list.txt") as pod_list_file:
all_pods = pod_list_file.read().splitlines() all_pods = pod_list_file.read().splitlines()

View File

@ -17,7 +17,7 @@ from typing import List
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from python_on_whales import DockerClient from python_on_whales import DockerClient
from app.command_types import CommandOptions from .command_types import CommandOptions
@dataclass @dataclass

View File

@ -15,8 +15,8 @@
import os import os
from typing import List from typing import List
from app.deploy_types import DeployCommandContext, VolumeMapping from .deploy_types import DeployCommandContext, VolumeMapping
from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir from .util import get_parsed_stack_config, get_yaml, get_compose_file_dir
def _container_image_from_service(stack: str, service: str): def _container_image_from_service(stack: str, service: str):

View File

@ -17,8 +17,8 @@ import click
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
import sys import sys
from app.deploy import up_operation, down_operation, ps_operation, port_operation from .deploy import up_operation, down_operation, ps_operation, port_operation
from app.deploy import exec_operation, logs_operation, create_deploy_context from .deploy import exec_operation, logs_operation, create_deploy_context
@dataclass @dataclass

View File

@ -20,9 +20,9 @@ from pathlib import Path
import random import random
from shutil import copyfile, copytree from shutil import copyfile, copytree
import sys import sys
from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml from .util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml
from app.util import get_compose_file_dir from .util import get_compose_file_dir
from app.deploy_types import DeploymentContext, LaconicStackSetupCommand from .deploy_types import DeploymentContext, LaconicStackSetupCommand
def _make_default_deployment_dir(): def _make_default_deployment_dir():

View File

@ -25,7 +25,7 @@ import click
import importlib.resources import importlib.resources
from pathlib import Path from pathlib import Path
import yaml import yaml
from app.util import include_exclude_check from .util import include_exclude_check
class GitProgress(git.RemoteProgress): class GitProgress(git.RemoteProgress):
@ -232,7 +232,7 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
os.makedirs(dev_root_path) os.makedirs(dev_root_path)
# See: https://stackoverflow.com/a/20885799/1701505 # See: https://stackoverflow.com/a/20885799/1701505
from app import data from . import data
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file: with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
all_repos = repository_list_file.read().splitlines() all_repos = repository_list_file.read().splitlines()

View File

@ -23,7 +23,7 @@ import sys
import stat import stat
import shutil import shutil
import validators import validators
from app.util import get_yaml from .util import get_yaml
def _download_url(url: str, file_path: Path): def _download_url(url: str, file_path: Path):

View File

@ -23,7 +23,7 @@ def command(ctx):
'''print tool version''' '''print tool version'''
# See: https://stackoverflow.com/a/20885799/1701505 # See: https://stackoverflow.com/a/20885799/1701505
from app import data from . import data
with importlib.resources.open_text(data, "build_tag.txt") as version_file: with importlib.resources.open_text(data, "build_tag.txt") as version_file:
# TODO: code better version that skips comment lines # TODO: code better version that skips comment lines
version_string = version_file.read().splitlines()[1] version_string = version_file.read().splitlines()[1]

View File

@ -1,5 +1,5 @@
# See https://medium.com/nerd-for-tech/how-to-build-and-distribute-a-cli-tool-with-python-537ae41d9d78 # See https://medium.com/nerd-for-tech/how-to-build-and-distribute-a-cli-tool-with-python-537ae41d9d78
from setuptools import setup, find_packages from setuptools import setup
with open("README.md", "r", encoding="utf-8") as fh: with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read() long_description = fh.read()
with open("requirements.txt", "r", encoding="utf-8") as fh: with open("requirements.txt", "r", encoding="utf-8") as fh:
@ -14,8 +14,9 @@ setup(
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url='https://github.com/cerc-io/stack-orchestrator', url='https://github.com/cerc-io/stack-orchestrator',
py_modules=['cli', 'app'], packages=['laconic_stack_orchestrator'],
packages=find_packages(), package_dir={'laconic_stack_orchestrator': 'app'},
py_modules=['laconic_stack_orchestrator', 'laconic_stack_orchestrator.cli'],
install_requires=[requirements], install_requires=[requirements],
python_requires='>=3.7', python_requires='>=3.7',
include_package_data=True, include_package_data=True,
@ -25,6 +26,6 @@ setup(
"Operating System :: OS Independent", "Operating System :: OS Independent",
], ],
entry_points={ entry_points={
'console_scripts': ['laconic-so=cli:cli'], 'console_scripts': ['laconic-so=laconic_stack_orchestrator.cli:cli'],
} }
) )