예제 #1
0
파일: dirs.py 프로젝트: ksbg/snapcraft
def setup_dirs() -> None:
    """
    Ensure that snapcraft.common plugindir is setup correctly
    and support running out of a development snapshot
    """
    from snapcraft.internal import common

    topdir = os.path.abspath(os.path.join(__file__, "..", "..", ".."))
    # Only change the default if we are running from a checkout or from the
    # snap.
    if os.path.exists(os.path.join(topdir, "setup.py")):
        common.set_plugindir(os.path.join(topdir, "snapcraft", "plugins"))
        common.set_schemadir(os.path.join(topdir, "schema"))
        common.set_extensionsdir(os.path.join(topdir, "extensions"))

    # The default paths are relative to sys.prefix, which works well for
    # Snapcraft as a deb or in a venv. However, the Python plugin installs
    # packages into $SNAP/ as a prefix, while Python itself is contained in
    # $SNAP/usr/. As a result, using sys.prefix (which is '/usr') to find these
    # files won't work in the snap.
    elif common.is_snap():
        parent_dir = os.path.join(os.environ.get("SNAP"), "share", "snapcraft")
        common.set_plugindir(os.path.join(parent_dir, "plugins"))
        common.set_schemadir(os.path.join(parent_dir, "schema"))
        common.set_extensionsdir(os.path.join(parent_dir, "extensions"))
        common.set_legacy_snapcraft_dir(
            os.path.join(os.environ.get("SNAP"), "legacy_snapcraft"))
예제 #2
0
파일: dirs.py 프로젝트: tuksik/snapcraft
def setup_dirs():
    """
    Ensure that snapcraft.common plugindir is setup correctly
    and support running out of a development snapshot
    """
    from snapcraft.internal import common
    topdir = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
    # only change the default if we are running from a checkout
    if os.path.exists(os.path.join(topdir, 'setup.py')):
        common.set_plugindir(os.path.join(topdir, 'snapcraft', 'plugins'))
        common.set_schemadir(os.path.join(topdir, 'schema'))
        common.set_librariesdir(os.path.join(topdir, 'libraries'))
예제 #3
0
def setup_dirs() -> None:
    """
    Ensure that snapcraft.common plugindir is setup correctly
    and support running out of a development snapshot
    """
    from snapcraft.internal import common

    topdir = os.path.abspath(os.path.join(__file__, "..", "..", ".."))

    # Only change the default if we are running from a checkout or from the
    # snap, or in Windows.
    if os.path.exists(os.path.join(topdir, "setup.py")):
        common.set_plugindir(os.path.join(topdir, "snapcraft", "plugins"))
        common.set_schemadir(os.path.join(topdir, "schema"))
        common.set_extensionsdir(os.path.join(topdir, "extensions"))
        common.set_keyringsdir(os.path.join(topdir, "keyrings"))

    # The default paths are relative to sys.prefix, which works well for
    # Snapcraft as a deb or in a venv. However, the Python plugin installs
    # packages into $SNAP/ as a prefix, while Python itself is contained in
    # $SNAP/usr/. As a result, using sys.prefix (which is '/usr') to find these
    # files won't work in the snap.
    elif common.is_snap():
        snap_path = os.environ.get("SNAP")
        if snap_path is None:
            # Shouldn't happen, but it is certainly an error if it does.
            raise RuntimeError("SNAP not defined, but SNAP_NAME is?")

        parent_dir = os.path.join(snap_path, "share", "snapcraft")
        common.set_plugindir(os.path.join(parent_dir, "plugins"))
        common.set_schemadir(os.path.join(parent_dir, "schema"))
        common.set_extensionsdir(os.path.join(parent_dir, "extensions"))
        common.set_keyringsdir(os.path.join(parent_dir, "keyrings"))
        common.set_legacy_snapcraft_dir(
            os.path.join(snap_path, "legacy_snapcraft"))

    elif sys.platform == "win32":
        common.set_plugindir(os.path.join(topdir, "snapcraft", "plugins"))

        data_dir = _find_windows_data_dir(topdir)
        common.set_schemadir(os.path.join(data_dir, "schema"))
        common.set_extensionsdir(os.path.join(data_dir, "extensions"))
        common.set_keyringsdir(os.path.join(data_dir, "keyrings"))

    else:
        # Make sure required data directories exist in the default locations.
        # Plugins and legacy snapcraft directory are not required.
        for d in [
                common.get_schemadir(),
                common.get_extensionsdir(),
                common.get_keyringsdir(),
        ]:
            if not os.path.exists(d):
                raise snapcraft.internal.errors.SnapcraftDataDirectoryMissingError(
                )
예제 #4
0
 def test_set_plugindir(self):
     plugindir = os.path.join(self.path, 'testplugin')
     common.set_plugindir(plugindir)
     self.assertEqual(plugindir, common.get_plugindir())
예제 #5
0
 def test_set_plugindir(self):
     plugindir = os.path.join(self.path, 'testplugin')
     common.set_plugindir(plugindir)
     self.assertEqual(plugindir, common.get_plugindir())
예제 #6
0
 def test_set_plugindir(self):
     plugindir = os.path.join(self.path, "testplugin")
     common.set_plugindir(plugindir)
     self.assertThat(plugindir, Equals(common.get_plugindir()))
예제 #7
0
 def test_set_plugindir(self):
     plugindir = os.path.join(self.path, "testplugin")
     common.set_plugindir(plugindir)
     self.assertThat(plugindir, Equals(common.get_plugindir()))