Skip to content

Commit

Permalink
Merge branch 'main' into update-parts-1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiusens committed May 31, 2023
2 parents f51297b + 40136ea commit d431c76
Show file tree
Hide file tree
Showing 528 changed files with 346 additions and 37,952 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
fail-fast: false
matrix:
spread-jobs:
- google:ubuntu-18.04-64
- google:ubuntu-20.04-64
- google:ubuntu-22.04-64

Expand Down Expand Up @@ -113,7 +112,7 @@ jobs:
SNAPCRAFT_STORE_CREDENTIALS_STAGING: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING }}"
SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID }}"
SNAPCRAFT_STORE_CREDENTIALS_STAGING_LEGACY: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING_LEGACY }}"
run: spread google:ubuntu-18.04-64:tests/spread/general/store
run: spread google:ubuntu-22.04-64:tests/spread/general/store

- name: Discard spread workers
if: always()
Expand Down
1 change: 0 additions & 1 deletion snapcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def get_dispatcher() -> craft_cli.Dispatcher:
"""
# Run the legacy implementation if inside a legacy managed environment.
if os.getenv("SNAPCRAFT_BUILD_ENVIRONMENT") == "managed-host":
snapcraft.BasePlugin = snapcraft_legacy.BasePlugin # type: ignore
snapcraft.ProjectOptions = snapcraft_legacy.ProjectOptions # type: ignore
legacy.legacy_run()

Expand Down
1 change: 0 additions & 1 deletion snapcraft/legacy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def run_legacy(err: Optional[Exception] = None):
logger = logging.getLogger(lib_name)
logger.setLevel(_ORIGINAL_LIB_NAME_LOG_LEVEL[lib_name])

snapcraft.BasePlugin = snapcraft_legacy.BasePlugin # type: ignore
snapcraft.ProjectOptions = snapcraft_legacy.ProjectOptions # type: ignore

# Legacy does not use craft-cli
Expand Down
126 changes: 0 additions & 126 deletions snapcraft/plugins/v1/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion snapcraft_legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ def _get_version():

# For backwards compatibility with external plugins.
import snapcraft_legacy._legacy_loader # noqa isort:skip
from snapcraft_legacy.plugins.v1 import PluginV1 as BasePlugin # noqa isort:skip
from snapcraft_legacy import common # noqa
from snapcraft_legacy import extractors # noqa
from snapcraft_legacy import file_utils # noqa
Expand Down
7 changes: 2 additions & 5 deletions snapcraft_legacy/cli/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ def _try_get_base_from_project() -> str:


def _get_modules_iter(base: str) -> Iterable:
if base == "core18":
modules_path = snapcraft_legacy.plugins.v1.__path__ # type: ignore # mypy issue #1422
else:
modules_path = snapcraft_legacy.plugins.v2.__path__ # type: ignore # mypy issue #1422
modules_path = snapcraft_legacy.plugins.v2.__path__ # type: ignore # mypy issue #1422

# TODO make this part of plugin_finder.
return pkgutil.iter_modules(modules_path)
Expand All @@ -59,7 +56,7 @@ def _get_modules_iter(base: str) -> Iterable:
@click.option(
"--base",
help="Show plugins for specific base",
type=click.Choice(["core18", "core20"]),
type=click.Choice(["core20"]),
)
def list_plugins(base):
"""List the available plugins that handle different types of part.
Expand Down
14 changes: 2 additions & 12 deletions snapcraft_legacy/internal/lifecycle/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
from typing import List, Optional, Sequence, Set

from snapcraft_legacy import config, plugins, storeapi
from snapcraft_legacy import config, storeapi
from snapcraft_legacy.internal import (
common,
errors,
Expand Down Expand Up @@ -293,13 +293,7 @@ def _reprime(self, part, hint=""):
def _handle_part_dependencies(
self, *, step: steps.Step, part: pluginhandler.PluginHandler
) -> None:
# core20 uses Plugins V2 which does not require staging parts for pull
# like V1 Plugins do.
if (
part._build_attributes.core22_step_dependencies()
and self.project._get_build_base() == "core20"
and step == steps.PULL
):
if part._build_attributes.core22_step_dependencies() and step == steps.PULL:
return
elif (
part._build_attributes.core22_step_dependencies()
Expand Down Expand Up @@ -343,10 +337,6 @@ def _prepare_step(self, *, step: steps.Step, part: pluginhandler.PluginHandler):
notify_part_progress(part, "Preparing to {}".format(step.name), debug=True)
preparation_function()

if isinstance(part.plugin, plugins.v1.PluginV1):
common.env = self.parts_config.build_env_for_part(part)
common.env.extend(self.config.project_env())

part = _replace_in_part(part)

def _run_step(self, *, step: steps.Step, part, progress, hint=""):
Expand Down
2 changes: 1 addition & 1 deletion snapcraft_legacy/internal/meta/_snap_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def _assemble_runtime_environment(self) -> str:
self._prime_dir, self._project_config.project.arch_triplet
)
for e in runtime_env:
env.append(re.sub(self._prime_dir, "$SNAP", e))
env.append("export " + re.sub(self._prime_dir, "$SNAP", e))

if all(
[
Expand Down
39 changes: 4 additions & 35 deletions snapcraft_legacy/internal/pluginhandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,17 +521,11 @@ def _do_pull(self):
if self.source_handler:
self.source_handler.pull()

if isinstance(self.plugin, plugins.v1.PluginV1):
self.plugin.pull()

def mark_pull_done(self):
# Send an empty pull_properties for state. This makes it easy
# to keep using what we have or to back out of not doing any
# pulling in the plugins.
if isinstance(self.plugin, plugins.v1.PluginV1):
pull_properties = self.plugin.get_pull_properties()
else:
pull_properties = dict()
pull_properties = dict()

# Add the processed list of build packages and snaps.
part_build_packages = self._grammar_processor.get_build_packages()
Expand Down Expand Up @@ -580,15 +574,11 @@ def clean_pull(self):
if self.stage_packages_path.exists():
shutil.rmtree(self.stage_packages_path)

if isinstance(self.plugin, plugins.v1.PluginV1):
self.plugin.clean_pull()
self.mark_cleaned(steps.PULL)

def prepare_build(self, force=False):
# TODO cleanup entire rebuilding and cleanup logic.
if not isinstance(self.plugin, plugins.v1.PluginV1) and os.path.exists(
self.part_install_dir
):
if os.path.exists(self.part_install_dir):
shutil.rmtree(self.part_install_dir)

self.makedirs()
Expand Down Expand Up @@ -632,9 +622,6 @@ def _generate_part_env(self, step: steps.Step) -> str:
:returns: str with the build step environment.
"""
if isinstance(self.plugin, plugins.v1.PluginV1):
raise RuntimeError("PluginV1 not supported.")

# Snapcraft's say.
snapcraft_build_environment = get_snapcraft_part_environment(self, step=step)

Expand Down Expand Up @@ -668,9 +655,6 @@ def _generate_part_env(self, step: steps.Step) -> str:
return run_environment.getvalue()

def _do_v2_build(self):
if isinstance(self.plugin, plugins.v1.PluginV1):
raise RuntimeError("PluginV1 not supported.")

# Save script executed by snapcraft.
build_script_path = pathlib.Path(self.part_dir) / "run" / "build.sh"
build_script_path.parent.mkdir(mode=0o755, parents=True, exist_ok=True)
Expand Down Expand Up @@ -723,12 +707,8 @@ def _do_build(self, *, update=False):
self.mark_build_done()

def mark_build_done(self):
if isinstance(self.plugin, plugins.v1.PluginV1):
build_properties = self.plugin.get_build_properties()
plugin_manifest = self.plugin.get_manifest()
else:
build_properties = dict()
plugin_manifest = dict()
build_properties = dict()
plugin_manifest = dict()
machine_manifest = self._get_machine_manifest()

# Extract any requested metadata available in the build directory,
Expand Down Expand Up @@ -818,15 +798,9 @@ def clean_build(self):
if os.path.exists(self.part_install_dir):
shutil.rmtree(self.part_install_dir)

if isinstance(self.plugin, plugins.v1.PluginV1):
self.plugin.clean_build()
self.mark_cleaned(steps.BUILD)

def migratable_fileset_for(self, step):
if isinstance(self.plugin, plugins.v1.PluginV1):
plugin_fileset = self.plugin.snap_fileset()
else:
plugin_fileset = list()
fileset = self._get_fileset(step.name).copy()
includes = _get_includes(fileset)
# If we're priming and we don't have an explicit set of files to prime
Expand All @@ -835,8 +809,6 @@ def migratable_fileset_for(self, step):
stage_fileset = self._get_fileset(steps.STAGE.name).copy()
fileset = _combine_filesets(stage_fileset, fileset)

fileset.extend(plugin_fileset)

return _migratable_filesets(fileset, self.part_install_dir)

def _get_fileset(self, option, default=None):
Expand Down Expand Up @@ -1107,9 +1079,6 @@ def get_primed_dependency_paths(self):

return dependency_paths

def env(self, root):
return self.plugin.env(root)

def clean(self, project_staged_state=None, project_primed_state=None, step=None):
if not project_staged_state:
project_staged_state = {}
Expand Down

0 comments on commit d431c76

Please sign in to comment.