def test_get_package(): tests = [ [("unknown", ), None], [("1", ), None], [("id=1", "shasum"), dict(id=1, name="name_1", version="shasum")], [("id=1", "*"), dict(id=1, name="name_1", version="2.1.0")], [("id=1", "^1"), dict(id=1, name="name_1", version="1.2")], [("id=1", "^1"), dict(id=1, name="name_1", version="1.2")], [("name_1", "<2"), dict(id=1, name="name_1", version="1.2")], [("name_1", ">2"), None], [("name_1", "2-0-0"), None], [("name_2", ), dict(name="name_2", version="4.0.0")], [("url_has_higher_priority", None, "git+https://github.com"), dict(name="name_2", version="2.0.0", __src_url="git+https://github.com")], [("name_2", None, "git+https://github.com"), dict(name="name_2", version="2.0.0", __src_url="git+https://github.com")], ] pm = PackageManager(join(get_project_core_dir(), "packages")) for test in tests: manifest = pm.get_package(*test[0]) if test[1] is None: assert manifest is None, test continue for key, value in test[1].items(): assert manifest[key] == value, test
def test_get_package(): tests = [ [("unknown", ), None], [("1", ), None], [("id=1", "shasum"), dict(id=1, name="name_1", version="shasum")], [("id=1", "*"), dict(id=1, name="name_1", version="2.1.0")], [("id=1", "^1"), dict(id=1, name="name_1", version="1.2")], [("id=1", "^1"), dict(id=1, name="name_1", version="1.2")], [("name_1", "<2"), dict(id=1, name="name_1", version="1.2")], [("name_1", ">2"), None], [("name_1", "2-0-0"), None], [("name_2", ), dict(name="name_2", version="4.0.0")], [("url_has_higher_priority", None, "git+https://github.com"), dict(name="name_2", version="2.0.0", __src_url="git+https://github.com")], [("name_2", None, "git+https://github.com"), dict(name="name_2", version="2.0.0", __src_url="git+https://github.com")], ] pm = PackageManager(join(util.get_home_dir(), "packages")) for test in tests: manifest = pm.get_package(*test[0]) if test[1] is None: assert manifest is None, test continue for key, value in test[1].items(): assert manifest[key] == value, test
def install_features_dependencies(): load_config() for feature in FEATURE_DEPENDENCIES: if not env.MarlinFeatureIsEnabled(feature): continue if 'lib_deps' in FEATURE_DEPENDENCIES[feature]: print("Adding lib_deps for %s... " % feature) # deps to add deps_to_add = {} for dep in FEATURE_DEPENDENCIES[feature]['lib_deps']: name, _, _ = PackageManager.parse_pkg_uri(dep) deps_to_add[name] = dep # first check if the env already have the dep deps = env.GetProjectOption("lib_deps") for dep in deps: name, _, _ = PackageManager.parse_pkg_uri(dep) if name in deps_to_add: del deps_to_add[name] # check if we need ignore any lib lib_ignore = env.GetProjectOption("lib_ignore") for dep in deps: name, _, _ = PackageManager.parse_pkg_uri(dep) if name in deps_to_add: del deps_to_add[name] # any left? if len(deps_to_add) <= 0: continue # add only the missing deps proj = env.GetProjectConfig() proj.set("env:" + env["PIOENV"], "lib_deps", deps + list(deps_to_add.values())) if 'extra_scripts' in FEATURE_DEPENDENCIES[feature]: print("Executing extra_scripts for %s... " % feature) env.SConscript(FEATURE_DEPENDENCIES[feature]['extra_scripts'], exports="env") if 'src_filter' in FEATURE_DEPENDENCIES[feature]: print("Adding src_filter for %s... " % feature) proj = env.GetProjectConfig() src_filter = env.GetProjectOption("src_filter") # first we need to remove the references to the same folder my_srcs = re.findall(r'[+-](<.*?>)', FEATURE_DEPENDENCIES[feature]['src_filter']) cur_srcs = re.findall(r'[+-](<.*?>)', src_filter[0]) for d in my_srcs: if d in cur_srcs: src_filter[0] = re.sub(r'[+-]' + d, '', src_filter[0]) src_filter[0] = FEATURE_DEPENDENCIES[feature][ 'src_filter'] + ' ' + src_filter[0] proj.set("env:" + env["PIOENV"], "src_filter", src_filter) env.Replace(SRC_FILTER=src_filter)
def test_install_packages(isolated_pio_home, tmpdir): packages = [ dict(id=1, name="name_1", version="shasum"), dict(id=1, name="name_1", version="2.0.0"), dict(id=1, name="name_1", version="2.1.0"), dict(id=1, name="name_1", version="1.2.0"), dict(id=1, name="name_1", version="1.0.0"), dict(name="name_2", version="1.0.0"), dict(name="name_2", version="2.0.0", __src_url="git+https://github.com"), dict(name="name_2", version="3.0.0", __src_url="git+https://github2.com"), dict(name="name_2", version="4.0.0", __src_url="git+https://github2.com") ] pm = PackageManager(join(util.get_home_dir(), "packages")) for package in packages: tmp_dir = tmpdir.mkdir("tmp-package") tmp_dir.join("package.json").write(json.dumps(package)) pm._install_from_url(package['name'], "file://%s" % str(tmp_dir)) tmp_dir.remove(rec=1) assert len(pm.get_installed()) == len(packages) - 1 pkg_dirnames = [ 'name_1_ID1', '[email protected]', '[email protected]', '[email protected]', 'name_1_ID1@shasum', 'name_2', 'name_2@src-177cbce1f0705580d17790fda1cc2ef5', 'name_2@src-f863b537ab00f4c7b5011fc44b120e1f' ] assert set([p.basename for p in isolated_pio_home.join( "packages").listdir()]) == set(pkg_dirnames)
def cleanup_packages(self, names): self.cache_reset() deppkgs = {} for manifest in PlatformManager().get_installed(): p = PlatformFactory.newPlatform(manifest["__pkg_dir"]) for pkgname, pkgmanifest in p.get_installed_packages().items(): if pkgname not in deppkgs: deppkgs[pkgname] = set() deppkgs[pkgname].add(pkgmanifest["version"]) pm = PackageManager(self.config.get_optional_dir("packages")) for manifest in pm.get_installed(): if manifest["name"] not in names: continue if ( manifest["name"] not in deppkgs or manifest["version"] not in deppkgs[manifest["name"]] ): try: pm.uninstall(manifest["__pkg_dir"], after_update=True) except exception.UnknownPackage: pass self.cache_reset() return True
def apply_features_config(): load_config() for feature in FEATURE_CONFIG: if not env.MarlinFeatureIsEnabled(feature): continue feat = FEATURE_CONFIG[feature] if 'lib_deps' in feat and len(feat['lib_deps']): print("Adding lib_deps for %s... " % feature) # feat to add deps_to_add = {} for dep in feat['lib_deps']: name, _, _ = PackageManager.parse_pkg_uri(dep) deps_to_add[name] = dep # Does the env already have the dependency? deps = env.GetProjectOption('lib_deps') for dep in deps: name, _, _ = PackageManager.parse_pkg_uri(dep) if name in deps_to_add: del deps_to_add[name] # Are there any libraries that should be ignored? lib_ignore = env.GetProjectOption('lib_ignore') for dep in deps: name, _, _ = PackageManager.parse_pkg_uri(dep) if name in deps_to_add: del deps_to_add[name] # Is there anything left? if len(deps_to_add) > 0: # Only add the missing dependencies set_env_field('lib_deps', deps + list(deps_to_add.values())) if 'extra_scripts' in feat: print("Running extra_scripts for %s... " % feature) env.SConscript(feat['extra_scripts'], exports="env") if 'src_filter' in feat: print("Adding src_filter for %s... " % feature) src_filter = ' '.join(env.GetProjectOption('src_filter')) # first we need to remove the references to the same folder my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) for d in my_srcs: if d in cur_srcs: src_filter = re.sub(r'[+-]' + d, '', src_filter) src_filter = feat['src_filter'] + ' ' + src_filter set_env_field('src_filter', [src_filter]) env.Replace(SRC_FILTER=src_filter) if 'lib_ignore' in feat: print("Adding lib_ignore for %s... " % feature) lib_ignore = env.GetProjectOption('lib_ignore') + [ feat['lib_ignore'] ] set_env_field('lib_ignore', lib_ignore)
def test_install_packages(isolated_pio_home, tmpdir): packages = [ dict(id=1, name="name_1", version="shasum"), dict(id=1, name="name_1", version="2.0.0"), dict(id=1, name="name_1", version="2.1.0"), dict(id=1, name="name_1", version="1.2"), dict(id=1, name="name_1", version="1.0.0"), dict(name="name_2", version="1.0.0"), dict(name="name_2", version="2.0.0", __src_url="git+https://github.com"), dict(name="name_2", version="3.0.0", __src_url="git+https://github2.com"), dict(name="name_2", version="4.0.0", __src_url="git+https://github2.com") ] pm = PackageManager(join(util.get_home_dir(), "packages")) for package in packages: tmp_dir = tmpdir.mkdir("tmp-package") tmp_dir.join("package.json").write(json.dumps(package)) pm._install_from_url(package['name'], "file://%s" % str(tmp_dir)) tmp_dir.remove(rec=1) assert len(pm.get_installed()) == len(packages) - 1 pkg_dirnames = [ 'name_1_ID1', '[email protected]', '[email protected]', '[email protected]', 'name_1_ID1@shasum', 'name_2', 'name_2@src-177cbce1f0705580d17790fda1cc2ef5', 'name_2@src-f863b537ab00f4c7b5011fc44b120e1f' ] assert set([p.basename for p in isolated_pio_home.join( "packages").listdir()]) == set(pkg_dirnames)
def __init__(self): PackageManager.__init__( self, join(util.get_home_dir(), "packages"), [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http%s://dl.platformio.org/packages/manifest.json" % ("" if sys.version_info < (2, 7, 9) else "s") ])
def install( # pylint: disable=keyword-arg-before-vararg self, name, requirements=None, *args, **kwargs): PackageManager.install(self, name, requirements, *args, **kwargs) self.cleanup_packages() return self.get_package_dir(name, requirements)
def get_all_env_libs(): env_libs = [] lib_deps = env.GetProjectOption("lib_deps") for dep in lib_deps: name, _, _ = PackageManager.parse_pkg_uri(dep) env_libs.append(name) return env_libs
def __init__(self, manifest_path): self.manifest_path = manifest_path self.silent = False self.verbose = False self._manifest = fs.load_json(manifest_path) self._BOARDS_CACHE = {} self._custom_packages = None self.config = ProjectConfig.get_instance() self.pm = PackageManager(self.config.get_optional_dir("packages"), self.package_repositories) self._src_manifest = None src_manifest_path = self.pm.get_src_manifest_path(self.get_dir()) if src_manifest_path: self._src_manifest = fs.load_json(src_manifest_path)
def get_all_known_libs(): known_libs = [] for feature in FEATURE_DEPENDENCIES: if not 'lib_deps' in FEATURE_DEPENDENCIES[feature]: continue for dep in FEATURE_DEPENDENCIES[feature]['lib_deps']: name, _, _ = PackageManager.parse_pkg_uri(dep) known_libs.append(name) return known_libs
def cleanup_packages(self, names): self.reset_cache() deppkgs = {} for manifest in PlatformManager().get_installed(): p = PlatformFactory.newPlatform(manifest["name"], manifest["version"]) for pkgname, pkgmanifest in p.get_installed_packages().items(): if pkgname not in deppkgs: deppkgs[pkgname] = set() deppkgs[pkgname].add(pkgmanifest["version"]) pm = PackageManager(join(util.get_home_dir(), "packages")) for manifest in pm.get_installed(): if manifest["name"] not in names: continue if manifest["name"] not in deppkgs or manifest["version"] not in deppkgs[manifest["name"]]: pm.uninstall(manifest["name"], manifest["version"], trigger_event=False) self.reset_cache() return True
def __init__(self, manifest_path): self._BOARDS_CACHE = {} self.manifest_path = manifest_path self._manifest = util.load_json(manifest_path) self.pm = PackageManager(join(util.get_home_dir(), "packages"), self._manifest.get("packageRepositories")) self.silent = False self.verbose = False
def get_all_known_libs(): known_libs = [] for feature in FEATURE_CONFIG: feat = FEATURE_CONFIG[feature] if not 'lib_deps' in feat: continue for dep in feat['lib_deps']: name, _, _ = PackageManager.parse_pkg_uri(dep) known_libs.append(name) return known_libs
def __init__(self, manifest_path): self.manifest_path = manifest_path self.silent = False self.verbose = False self._BOARDS_CACHE = {} self._manifest = fs.load_json(manifest_path) self._custom_packages = None self.pm = PackageManager(get_project_packages_dir(), self.package_repositories)
def cleanup_packages(self, names): self.cache_reset() deppkgs = {} for manifest in PlatformManager().get_installed(): p = PlatformFactory.newPlatform(manifest['__pkg_dir']) for pkgname, pkgmanifest in p.get_installed_packages().items(): if pkgname not in deppkgs: deppkgs[pkgname] = set() deppkgs[pkgname].add(pkgmanifest['version']) pm = PackageManager(join(util.get_home_dir(), "packages")) for manifest in pm.get_installed(): if manifest['name'] not in names: continue if (manifest['name'] not in deppkgs or manifest['version'] not in deppkgs[manifest['name']]): pm.uninstall(manifest['__pkg_dir'], trigger_event=False) self.cache_reset() return True
def cleanup_packages(self, names): self.cache_reset() deppkgs = {} for manifest in PlatformManager().get_installed(): p = PlatformFactory.newPlatform(manifest['__pkg_dir']) for pkgname, pkgmanifest in p.get_installed_packages().items(): if pkgname not in deppkgs: deppkgs[pkgname] = set() deppkgs[pkgname].add(pkgmanifest['version']) pm = PackageManager(join(util.get_home_dir(), "packages")) for manifest in pm.get_installed(): if manifest['name'] not in names: continue if (manifest['name'] not in deppkgs or manifest['version'] not in deppkgs[manifest['name']]): try: pm.uninstall(manifest['__pkg_dir'], after_update=True) except exception.UnknownPackage: pass self.cache_reset() return True
def __init__(self, manifest_path): self._BOARDS_CACHE = {} self.manifest_path = manifest_path self._manifest = util.load_json(manifest_path) self.pm = PackageManager(join(util.get_home_dir(), "packages"), self._manifest.get("packageRepositories")) self.silent = False self.verbose = False if self.engines and "platformio" in self.engines: if self.PIO_VERSION not in semantic_version.Spec( self.engines['platformio']): raise exception.IncompatiblePlatform(self.name, str(self.PIO_VERSION))
def parse_pkg_uri(spec): if PackageManager.__name__ == 'PackageSpec': return PackageManager(spec).name else: name, _, _ = PackageManager.parse_pkg_uri(spec) return name
class PlatformBase(PlatformPackagesMixin, PlatformRunMixin): PIO_VERSION = semantic_version.Version(util.pepver_to_semver(__version__)) _BOARDS_CACHE = {} def __init__(self, manifest_path): self.manifest_path = manifest_path self.silent = False self.verbose = False self._manifest = fs.load_json(manifest_path) self._BOARDS_CACHE = {} self._custom_packages = None self.config = ProjectConfig.get_instance() self.pm = PackageManager(self.config.get_optional_dir("packages"), self.package_repositories) self._src_manifest = None src_manifest_path = self.pm.get_src_manifest_path(self.get_dir()) if src_manifest_path: self._src_manifest = fs.load_json(src_manifest_path) # if self.engines and "platformio" in self.engines: # if self.PIO_VERSION not in semantic_version.SimpleSpec( # self.engines['platformio']): # raise exception.IncompatiblePlatform(self.name, # str(self.PIO_VERSION)) @property def name(self): return self._manifest["name"] @property def title(self): return self._manifest["title"] @property def description(self): return self._manifest["description"] @property def version(self): return self._manifest["version"] @property def src_version(self): return self._src_manifest.get( "version") if self._src_manifest else None @property def src_url(self): return self._src_manifest.get("url") if self._src_manifest else None @property def homepage(self): return self._manifest.get("homepage") @property def vendor_url(self): return self._manifest.get("url") @property def docs_url(self): return self._manifest.get("docs") @property def repository_url(self): return self._manifest.get("repository", {}).get("url") @property def license(self): return self._manifest.get("license") @property def frameworks(self): return self._manifest.get("frameworks") @property def engines(self): return self._manifest.get("engines") @property def package_repositories(self): return self._manifest.get("packageRepositories") @property def manifest(self): return self._manifest @property def packages(self): packages = self._manifest.get("packages", {}) for item in self._custom_packages or []: name = item version = "*" if "@" in item: name, version = item.split("@", 2) name = name.strip() if name not in packages: packages[name] = {} packages[name].update({ "version": version.strip(), "optional": False }) return packages @property def python_packages(self): return self._manifest.get("pythonPackages") def get_dir(self): return dirname(self.manifest_path) def get_build_script(self): main_script = join(self.get_dir(), "builder", "main.py") if isfile(main_script): return main_script raise NotImplementedError() def is_embedded(self): for opts in self.packages.values(): if opts.get("type") == "uploader": return True return False def get_boards(self, id_=None): def _append_board(board_id, manifest_path): config = PlatformBoardConfig(manifest_path) if "platform" in config and config.get("platform") != self.name: return if "platforms" in config and self.name not in config.get( "platforms"): return config.manifest["platform"] = self.name self._BOARDS_CACHE[board_id] = config bdirs = [ self.config.get_optional_dir("boards"), join(self.config.get_optional_dir("core"), "boards"), join(self.get_dir(), "boards"), ] if id_ is None: for boards_dir in bdirs: if not isdir(boards_dir): continue for item in sorted(os.listdir(boards_dir)): _id = item[:-5] if not item.endswith(".json") or _id in self._BOARDS_CACHE: continue _append_board(_id, join(boards_dir, item)) else: if id_ not in self._BOARDS_CACHE: for boards_dir in bdirs: if not isdir(boards_dir): continue manifest_path = join(boards_dir, "%s.json" % id_) if isfile(manifest_path): _append_board(id_, manifest_path) break if id_ not in self._BOARDS_CACHE: raise exception.UnknownBoard(id_) return self._BOARDS_CACHE[id_] if id_ else self._BOARDS_CACHE def board_config(self, id_): return self.get_boards(id_) def get_package_type(self, name): return self.packages[name].get("type") def configure_default_packages(self, options, targets): # override user custom packages self._custom_packages = options.get("platform_packages") # enable used frameworks for framework in options.get("framework", []): if not self.frameworks: continue framework = framework.lower().strip() if not framework or framework not in self.frameworks: continue _pkg_name = self.frameworks[framework].get("package") if _pkg_name: self.packages[_pkg_name]["optional"] = False # enable upload tools for upload targets if any(["upload" in t for t in targets] + ["program" in targets]): for name, opts in self.packages.items(): if opts.get("type") == "uploader": self.packages[name]["optional"] = False # skip all packages in "nobuild" mode # allow only upload tools and frameworks elif "nobuild" in targets and opts.get("type") != "framework": self.packages[name]["optional"] = True def get_lib_storages(self): storages = {} for opts in (self.frameworks or {}).values(): if "package" not in opts: continue pkg_dir = self.get_package_dir(opts["package"]) if not pkg_dir or not isdir(join(pkg_dir, "libraries")): continue libs_dir = join(pkg_dir, "libraries") storages[libs_dir] = opts["package"] libcores_dir = join(libs_dir, "__cores__") if not isdir(libcores_dir): continue for item in os.listdir(libcores_dir): libcore_dir = join(libcores_dir, item) if not isdir(libcore_dir): continue storages[libcore_dir] = "%s-core-%s" % (opts["package"], item) return [dict(name=name, path=path) for path, name in storages.items()] def on_installed(self): pass def on_uninstalled(self): pass def install_python_packages(self): if not self.python_packages: return None click.echo( "Installing Python packages: %s" % ", ".join(list(self.python_packages.keys())), ) args = [proc.get_pythonexe_path(), "-m", "pip", "install", "--upgrade"] for name, requirements in self.python_packages.items(): if any(c in requirements for c in ("<", ">", "=")): args.append("%s%s" % (name, requirements)) else: args.append("%s==%s" % (name, requirements)) try: return subprocess.call(args) == 0 except Exception as e: # pylint: disable=broad-except click.secho("Could not install Python packages -> %s" % e, fg="red", err=True) def uninstall_python_packages(self): if not self.python_packages: return click.echo("Uninstalling Python packages") args = [proc.get_pythonexe_path(), "-m", "pip", "uninstall", "--yes"] args.extend(list(self.python_packages.keys())) try: subprocess.call(args) == 0 except Exception as e: # pylint: disable=broad-except click.secho("Could not install Python packages -> %s" % e, fg="red", err=True)
env = DefaultEnvironment() platform = env.PioPlatform() board = env.BoardConfig() variant = board.get("build.variant") platform_packages = env.GetProjectOption('platform_packages') # if there's no framework defined, take it from the class name of platform framewords = { "Ststm32Platform": "framework-arduinoststm32", "AtmelavrPlatform": "framework-arduino-avr" } if len(platform_packages) == 0: platform_name = framewords[platform.__class__.__name__] else: platform_name, _, _ = PackageManager.parse_pkg_uri(platform_packages[0]) FRAMEWORK_DIR = platform.get_package_dir(platform_name) assert os.path.isdir(FRAMEWORK_DIR) assert os.path.isdir("buildroot/share/PlatformIO/variants") variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant) source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) assert os.path.isdir(source_dir) if os.path.isdir(variant_dir): shutil.rmtree(variant_dir) if not os.path.isdir(variant_dir): os.mkdir(variant_dir)
def __init__(self): PackageManager.__init__(self, join(util.get_home_dir(), "packages"), [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "https://dl.platformio.org/packages/manifest.json" ])
def test_pkg_input_parser(): items = [["PkgName", ("PkgName", None, None)], [("PkgName", "!=1.2.3,<2.0"), ("PkgName", "!=1.2.3,<2.0", None)], ["[email protected]", ("PkgName", "1.2.3", None)], [("[email protected]", "1.2.5"), ("[email protected]", "1.2.5", None)], ["id:13", ("id:13", None, None)], ["id:13@~1.2.3", ("id:13", "~1.2.3", None)], [ util.get_home_dir(), (".platformio", None, "file://" + util.get_home_dir()) ], [ "LocalName=" + util.get_home_dir(), ("LocalName", None, "file://" + util.get_home_dir()) ], [ "LocalName=%s@>2.3.0" % util.get_home_dir(), ("LocalName", ">2.3.0", "file://" + util.get_home_dir()) ], [ "https://github.com/user/package.git", ("package", None, "git+https://github.com/user/package.git") ], [ "MyPackage=https://gitlab.com/user/package.git", ("MyPackage", None, "git+https://gitlab.com/user/package.git") ], [ "MyPackage=https://gitlab.com/user/[email protected],!=2", ("MyPackage", "3.2.1,!=2", "git+https://gitlab.com/user/package.git") ], [ "https://somedomain.com/path/LibraryName-1.2.3.zip", ("LibraryName-1.2.3", None, "https://somedomain.com/path/LibraryName-1.2.3.zip") ], [ "https://github.com/user/package/archive/branch.zip", ("branch", None, "https://github.com/user/package/archive/branch.zip") ], [ "https://github.com/user/package/archive/branch.zip@~1.2.3", ("branch", "~1.2.3", "https://github.com/user/package/archive/branch.zip") ], [ "https://github.com/user/package/archive/branch.tar.gz", ("branch.tar", None, "https://github.com/user/package/archive/branch.tar.gz") ], [ "https://github.com/user/package/archive/branch.tar.gz@!=5", ("branch.tar", "!=5", "https://github.com/user/package/archive/branch.tar.gz") ], [ "https://developer.mbed.org/users/user/code/package/", ("package", None, "hg+https://developer.mbed.org/users/user/code/package/") ], [ "https://github.com/user/package#v1.2.3", ("package", None, "git+https://github.com/user/package#v1.2.3") ], [ "https://github.com/user/package.git#branch", ("package", None, "git+https://github.com/user/package.git#branch") ], [ "PkgName=https://github.com/user/package.git#a13d344fg56", ("PkgName", None, "git+https://github.com/user/package.git#a13d344fg56") ], [ "user/package", ("package", None, "git+https://github.com/user/package") ], [ "PkgName=user/package", ("PkgName", None, "git+https://github.com/user/package") ], [ "PkgName=user/package#master", ("PkgName", None, "git+https://github.com/user/package#master") ], [ "git+https://github.com/user/package", ("package", None, "git+https://github.com/user/package") ], [ "hg+https://example.com/user/package", ("package", None, "hg+https://example.com/user/package") ], [ "[email protected]:user/package.git", ("package", None, "[email protected]:user/package.git") ], [ "[email protected]:user/package.git#v1.2.0", ("package", None, "[email protected]:user/package.git#v1.2.0") ], [ "git+ssh://[email protected]/user/package#1.2.0", ("package", None, "git+ssh://[email protected]/user/package#1.2.0") ]] for params, result in items: if isinstance(params, tuple): assert PackageManager.parse_pkg_input(*params) == result else: assert PackageManager.parse_pkg_input(params) == result
def test_pkg_input_parser(): items = [ ["PkgName", ("PkgName", None, None)], [("PkgName", "!=1.2.3,<2.0"), ("PkgName", "!=1.2.3,<2.0", None)], ["[email protected]", ("PkgName", "1.2.3", None)], [("[email protected]", "1.2.5"), ("[email protected]", "1.2.5", None)], ["id=13", ("id=13", None, None)], ["id=13@~1.2.3", ("id=13", "~1.2.3", None)], [ util.get_home_dir(), (".platformio", None, "file://" + util.get_home_dir()) ], [ "LocalName=" + util.get_home_dir(), ("LocalName", None, "file://" + util.get_home_dir()) ], [ "LocalName=%s@>2.3.0" % util.get_home_dir(), ("LocalName", ">2.3.0", "file://" + util.get_home_dir()) ], [ "https://github.com/user/package.git", ("package", None, "git+https://github.com/user/package.git") ], [ "MyPackage=https://gitlab.com/user/package.git", ("MyPackage", None, "git+https://gitlab.com/user/package.git") ], [ "MyPackage=https://gitlab.com/user/[email protected],!=2", ("MyPackage", "3.2.1,!=2", "git+https://gitlab.com/user/package.git") ], [ "https://somedomain.com/path/LibraryName-1.2.3.zip", ("LibraryName-1.2.3", None, "https://somedomain.com/path/LibraryName-1.2.3.zip") ], [ "https://github.com/user/package/archive/branch.zip", ("branch", None, "https://github.com/user/package/archive/branch.zip") ], [ "https://github.com/user/package/archive/branch.zip@~1.2.3", ("branch", "~1.2.3", "https://github.com/user/package/archive/branch.zip") ], [ "https://github.com/user/package/archive/branch.tar.gz", ("branch.tar", None, "https://github.com/user/package/archive/branch.tar.gz") ], [ "https://github.com/user/package/archive/branch.tar.gz@!=5", ("branch.tar", "!=5", "https://github.com/user/package/archive/branch.tar.gz") ], [ "https://developer.mbed.org/users/user/code/package/", ("package", None, "hg+https://developer.mbed.org/users/user/code/package/") ], [ "https://os.mbed.com/users/user/code/package/", ("package", None, "hg+https://os.mbed.com/users/user/code/package/") ], [ "https://github.com/user/package#v1.2.3", ("package", None, "git+https://github.com/user/package#v1.2.3") ], [ "https://github.com/user/package.git#branch", ("package", None, "git+https://github.com/user/package.git#branch") ], [ "PkgName=https://github.com/user/package.git#a13d344fg56", ("PkgName", None, "git+https://github.com/user/package.git#a13d344fg56") ], [ "user/package", ("package", None, "git+https://github.com/user/package") ], [ "PkgName=user/package", ("PkgName", None, "git+https://github.com/user/package") ], [ "PkgName=user/package#master", ("PkgName", None, "git+https://github.com/user/package#master") ], [ "git+https://github.com/user/package", ("package", None, "git+https://github.com/user/package") ], [ "hg+https://example.com/user/package", ("package", None, "hg+https://example.com/user/package") ], [ "[email protected]:user/package.git", ("package", None, "[email protected]:user/package.git") ], [ "[email protected]:user/package.git#v1.2.0", ("package", None, "[email protected]:user/package.git#v1.2.0") ], [ "[email protected]:user/package.git#v1.2.0@~1.2.0", ("LocalName", "~1.2.0", "[email protected]:user/package.git#v1.2.0") ], [ "git+ssh://[email protected]/user/package#1.2.0", ("package", None, "git+ssh://[email protected]/user/package#1.2.0") ], [ "git+ssh://[email protected]:1234/package#1.2.0", ("package", None, "git+ssh://[email protected]:1234/package#1.2.0") ], [ "LocalName=git+ssh://[email protected]:1234" "/package#1.2.0@!=13", ("LocalName", "!=13", "git+ssh://[email protected]:1234/package#1.2.0") ] ] for params, result in items: if isinstance(params, tuple): assert PackageManager.parse_pkg_uri(*params) == result else: assert PackageManager.parse_pkg_uri(params) == result
def install(self, name, requirements=None, *args, **kwargs): PackageManager.install(self, name, requirements, *args, **kwargs) self.cleanup_packages() return self.get_package_dir(name, requirements)
def update(self, *args, **kwargs): # pylint: disable=arguments-differ result = PackageManager.update(self, *args, **kwargs) self.cleanup_packages() return result
def update(self, *args, **kwargs): result = PackageManager.update(self, *args, **kwargs) self.cleanup_packages() return result
def install(self, name, requirements=None, *args, **kwargs): # pylint: disable=arguments-differ PackageManager.install(self, name, requirements, *args, **kwargs) self.cleanup_packages() return self.get_package_dir(name, requirements)