diff --git a/.gitignore b/.gitignore index 68bc17f..04f1bf2 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,4 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +.pdm-python diff --git a/.pdm-python b/.pdm-python deleted file mode 100644 index 1ceb92d..0000000 --- a/.pdm-python +++ /dev/null @@ -1 +0,0 @@ -D:/Projects/Mina/.venv/Scripts/python.exe \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 61cb58b..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "cSpell.words": [ - "mina", - "tomli", - "deps" - ], - "python.formatting.provider": "black" -} \ No newline at end of file diff --git a/README.en.md b/README.en.md index 6bfb38c..10ce964 100644 --- a/README.en.md +++ b/README.en.md @@ -17,7 +17,7 @@ It also provides a simple CLI implementation as the `PDM Plugin`; `mina-build` only works when the package to be packaged is defined, Otherwise the behavior is the same as `pdm-backend`. The CLI does provide a `pdm mina build ` command, -but you can also specify the package to be packaged via the environment variable `MINA_BUILD_TARGET` or by setting `--mina-target` in `config-setting`. +but you can also specify the package to be packaged via the environment variable `MINA_BUILD_TARGET` or by setting `mina-target` in `config-setting`. ## Quick Start @@ -26,11 +26,26 @@ but you can also specify the package to be packaged via the environment variable At the moment, Mina only supports `pdm` as the main user function entry, but perhaps `poetry` will be supported later? ```bash -elaina@localhost $ pip install pdm-mina +elaina@localhost $ pipx inject pdm pdm-mina # or pdm -elaina@localhost $ pdm add pdm-mina -d +elaina@localhost $ pdm self add pdm-mina ``` +Or specify in `pyproject.toml`: + +```toml +[tool.pdm] +plugins = ["pdm-mina"] +``` + +Then run: + +```bash +elaina@localhost $ pdm install --plugins +``` + +This will enable `pdm-mina` plugin in the current project. + ### Introduce mina-build Configure the following in the project `pyproject.toml`: @@ -38,7 +53,7 @@ Configure the following in the project `pyproject.toml`: ```toml [build-system] requires = ["mina-build>=0.2.5"] -build-backend = "mina.backend" +build-backend = "pdm.backend" ``` ### Edit pyproject.toml @@ -79,13 +94,9 @@ includes = [ ] # Equivalent to tool.pdm.includes, I don't know what happens if you leave it out, it's probably just the normal case - packing the module that name refers to. -# raw-dependencies = [...] -# This configuration item will be queued directly into the dependency declaration after project.dependencies has been processed. -# You can use this feature to declare dependencies between subpackages. - # override = false -[tool.mina.packages. "core".project] +[tool.mina.packages."core".project] name = "avilla-core" # the name of the subpackage on `pypi`, required description = "..." authors = ["..."] diff --git a/README.md b/README.md index 94daf2d..9cf6568 100644 --- a/README.md +++ b/README.md @@ -14,24 +14,39 @@ `Mina` 提供了名为 [`mina-build`](https://pypi.org/project/mina-build/) 的 `PEP-517` 实现, 同时还提供作为 `PDM Plugin` 的简易 CLI 实现; -`mina-build` 仅在配置了需要构建的分包名称时才会注入 `pdm-pep517` 的构建流程, +`mina-build` 仅在配置了需要构建的分包名称时才会注入 `pdm-backend` 的构建流程, 其他情况下的行为与 `pdm-backend` 无异. CLI 中虽提供了一个 `pdm mina build ` 指令, -但你也可以通过环境变量 `MINA_BUILD_TARGET` 或是 `config-setting` 中设置 `--mina-target` 指定需要打包的分包. +但你也可以通过环境变量 `MINA_BUILD_TARGET` 或是 `config-setting` 中设置 `mina-target` 指定需要打包的分包. ## Quick Start -### 安装 CLI +### 安装插件 目前, Mina 仅支持将 `pdm` 作为主要的用户功能入口, 但或许 `poetry` 会在之后得到支持? ```bash -elaina@localhost $ pip install pdm-mina +elaina@localhost $ pipx inject pdm pdm-mina # or pdm -elaina@localhost $ pdm add pdm-mina -d +elaina@localhost $ pdm self add pdm-mina ``` +或者在 `pyproject.toml` 指定: + +```toml +[tool.pdm] +plugins = ["pdm-mina"] +``` + +然后运行: + +```bash +elaina@localhost $ pdm install --plugins +``` + +运行成功后将在当前项目中启用 `pdm-mina` 插件。 + ### 引入 mina-build 在项目的 `pyproject.toml` 中配置以下项: @@ -39,7 +54,7 @@ elaina@localhost $ pdm add pdm-mina -d ```toml [build-system] requires = ["mina-build>=0.2.5"] -build-backend = "mina.backend" +build-backend = "pdm.backend" ``` ### 编辑 pyproject.toml @@ -80,10 +95,6 @@ includes = [ ] # 相当于 tool.pdm.includes, 如果不填我不知道会发生什么, 可能就是普通的情况 -- 打包 name 所指向的模块. -# raw-dependencies = [...] -# 这一配置项会在处理完 project.dependencies 后直接排入依赖声明. -# 你可以用这个特性来声明分包之间的依赖. - # override = false [tool.mina.packages."core".project] @@ -127,4 +138,4 @@ override = true # 仅在 core 分包启用该特性 # 开源协议 -本项目使用 MIT 协议开源. \ No newline at end of file +本项目使用 MIT 协议开源. diff --git a/mina/backend/__init__.py b/mina/backend/__init__.py deleted file mode 100644 index 90c769b..0000000 --- a/mina/backend/__init__.py +++ /dev/null @@ -1,325 +0,0 @@ -from __future__ import annotations - -import functools -import os -from pathlib import Path -from typing import Any, Dict, Mapping, Optional, cast - -try: - import tomllib as tomli # type: ignore -except ImportError: - try: - from pdm.backend._vendor import tomli - except ImportError: - import tomli # type: ignore - -from pdm.backend._vendor.packaging.requirements import Requirement -from pdm.backend import \ - get_requires_for_build_sdist as get_requires_for_build_sdist -from pdm.backend import \ - get_requires_for_build_wheel as get_requires_for_build_wheel -from pdm.backend.base import Builder -from pdm.backend.config import Metadata, BuildConfig - - -@functools.lru_cache(None) -def _get_config_root(): - cwd = Path.cwd() - return tomli.loads((cwd / "pyproject.toml").read_text(encoding="utf-8")) - - -@functools.lru_cache(None) -def _get_root_project(): - return _get_config_root().get("project", {}) - - -@functools.lru_cache(None) -def _get_tool_mina() -> dict[str, Any]: - return _get_config_root().get("tool", {}).get("mina", {}) - - -@functools.lru_cache(None) -def _get_package(package: str) -> Dict[str, Any]: - return _get_tool_mina().get("packages", {}).get(package, {}) - - -def _has_package(package: str) -> bool: - return _get_package(package) is not None - - -def _get_build_target( - config_settings: Optional[Mapping[str, Any]] = None -) -> str | None: - return ( - (config_settings or {}).get("--mina-target") - or os.environ.get("MINA_BUILD_TARGET") - or _get_tool_mina().get("mina-build-target") - ) - - -def _using_override_global() -> bool: - return _get_tool_mina().get("override-global", False) - - -def _using_override(package: str | None) -> bool: - if package and _has_package(package): - pkg = _get_package(package) - if "override" in pkg: - return pkg["override"] - return _using_override_global() - - -def _patch_dep(pkg_project: dict[str, Any]): - if "dependencies" in pkg_project: - dependencies: list[str] = [] - - deps = cast(list[str], pkg_project["dependencies"]) - workspace_deps_origin: list[str] = _get_root_project().get("dependencies", []) - workspace_deps_convert = [Requirement(i) for i in workspace_deps_origin] - workspace_deps_map = { - i.name: i for i in workspace_deps_convert if i.name is not None - } - - for dep in deps: - req = Requirement(dep) - if req.name is None: - raise ValueError(f"'{dep}' is not a valid requirement") - if req.name not in workspace_deps_map: - raise ValueError(f"{req.name} is not defined in project requirements") - dependencies.append(str(workspace_deps_map[req.name])) - - pkg_project["dependencies"] = dependencies - - if "optional-dependencies" in pkg_project: - optional_dependencies: dict[str, list[str]] = {} - - optional_dep_groups: dict[str, list[str]] = pkg_project["optional-dependencies"] - - # workspace don't use optional dep: it must contains ALL deps mina required. - workspace_deps_origin: list[str] = _get_root_project().get("dependencies", []) - workspace_deps_convert = [Requirement(i) for i in workspace_deps_origin] - workspace_deps_map = { - i.name: i for i in workspace_deps_convert if i.name is not None - } - - for group, optional_deps in optional_dep_groups.items(): - group_deps = [] - for dep in optional_deps: - req = Requirement(dep) - if req.name is None: - raise ValueError(f"'{dep}' is not a valid requirement") - if req.name not in workspace_deps_map: - raise ValueError( - f"{req.name} is not defined in project requirements" - ) - group_deps.append(str(workspace_deps_map[req.name])) - optional_dependencies[group] = group_deps - - pkg_project["optional-dependencies"] = optional_dependencies - - -def _get_standalone_config(pkg: str): - config_file = Path.cwd() / ".mina" / f"{pkg}.toml" - if not config_file.exists(): - return - - return tomli.loads(config_file.read_text()) - - -def _patch_pdm_config(package: str): - cwd = Path.cwd() - config = Builder(cwd).config - - package_conf = _get_standalone_config(package) - if package_conf is not None: - package_conf.setdefault("includes", []).append(f".mina/{package}.toml") - else: - package_conf = ( - config.data.get("tool", {}) - .get("mina", {}) - .get("packages", {}) - .get(package, None) - ) - if package_conf is None: - raise ValueError(f"No package named '{package}'") - - package_project = package_conf.get("project", {}) - - _patch_dep(package_project) - - pdm_settings = config.data.get("tool", {}).get("pdm", {}).get("build", {}) - - # dev-dependencies is unnecessary for a pkg(for workspace), so it will be ignored by mina. - - if "custom-hook" in package_conf: - pdm_settings["custom-hook"] = package_conf["custom-hook"] - - if "includes" in package_conf: - pdm_settings["includes"] = package_conf["includes"] - - if "excludes" in package_conf: - pdm_settings["excludes"] = package_conf["excludes"] - - if "source-includes" in package_conf: - pdm_settings["source-includes"] = package_conf["source-includes"] - - if "is-purelib" in package_conf: - pdm_settings["is-purelib"] = package_conf["is-purelib"] - - if "run-setuptools" in package_conf: - pdm_settings["run-setuptools"] = package_conf["run-setuptools"] - - if "package-dir" in package_conf: - pdm_settings["package-dir"] = package_conf["package-dir"] - - if "editable-backend" in package_conf: - pdm_settings["editable-backend"] = package_conf["editable-backend"] - - if "wheel-data" in package_conf: - pdm_settings["wheel-data"] = package_conf["wheel-data"] - - if "entry-points" in package_conf: - if "entry-points" not in package_project: - package_project["entry-points"] = {} - for group, entry_points in package_conf["entry-points"].items(): - if group not in package_project["entry-points"]: - package_project["entry-points"][group] = {} - package_project["entry-points"][group].update(entry_points) - - if "scripts" in package_conf: - package_project.setdefault("entry-points", {})[ - "console_scripts" - ] = package_conf["scripts"] - if "gui-scripts" in package_conf: - package_project.setdefault("entry-points", {})["gui_scripts"] = package_conf[ - "gui-scripts" - ] - - if ( - "raw-dependencies" in package_conf - and config.metadata.get("dependencies") is not None - ): - package_project["dependencies"].extend(package_conf["raw-dependencies"]) - if _using_override(package): - project_conf = config.data["project"] - - def merge(source: dict, target: dict): - for key, value in target.items(): - if key in source and isinstance(value, list): - source[key].extend(value) - elif key in source and isinstance(value, dict): - merge(source[key], value) - else: - source[key] = value - return source - - config.data["project"] = merge(project_conf, package_project) - else: - config.data["project"] = package_project - - config.data["tool"].setdefault("pdm", {})["build"] = pdm_settings - config.validate(config.data, config.root) - config.metadata = Metadata(config.data["project"]) - config.build_config = BuildConfig(config.root, pdm_settings) - return config - - -def prepare_metadata_for_build_wheel( - metadata_directory: str, config_settings: Optional[Mapping[str, Any]] = None -) -> str: - """Prepare the metadata, places it in metadata_directory""" - from pdm.backend.wheel import WheelBuilder - - _patched_config = None - mina_target = _get_build_target(config_settings) - if mina_target is not None: - if not _has_package(mina_target): - raise ValueError(f"{mina_target} is not defined as a mina package") - _patched_config = _patch_pdm_config(mina_target) # os.chdir may break behavior - with WheelBuilder(Path.cwd(), config_settings) as builder: - if _patched_config is not None: - builder.config = _patched_config - return builder.prepare_metadata(metadata_directory).name - - -def build_wheel( - wheel_directory: str, - config_settings: Optional[Mapping[str, Any]] = None, - metadata_directory: Optional[str] = None, -) -> str: - """Builds a wheel, places it in wheel_directory""" - from pdm.backend.wheel import WheelBuilder - - _patched_config = None - mina_target = _get_build_target(config_settings) - if mina_target is not None: - if not _has_package(mina_target): - raise ValueError(f"{mina_target} is not defined as a mina package") - _patched_config = _patch_pdm_config(mina_target) # os.chdir may break behavior - - with WheelBuilder(Path.cwd(), config_settings) as builder: - if _patched_config is not None: - builder.config = _patched_config - return builder.build( - wheel_directory, metadata_directory=metadata_directory - ).name - - -def build_sdist( - sdist_directory: str, config_settings: Optional[Mapping[str, Any]] = None -) -> str: - """Builds an sdist, places it in sdist_directory""" - from pdm.backend.sdist import SdistBuilder - - _patched_config = None - mina_target = _get_build_target(config_settings) - if mina_target is not None: - if not _has_package(mina_target): - raise ValueError(f"{mina_target} is not defined as a mina package") - _patched_config = _patch_pdm_config(mina_target) # os.chdir may break behavior - with SdistBuilder(Path.cwd(), config_settings) as builder: - if _patched_config is not None: - builder.config = _patched_config - return builder.build(sdist_directory).name - - -get_requires_for_build_editable = get_requires_for_build_wheel - - -def prepare_metadata_for_build_editable( - metadata_directory: str, config_settings: Optional[Mapping[str, Any]] = None -) -> str: - """Prepare the metadata, places it in metadata_directory""" - from pdm.backend.editable import EditableBuilder - - _patched_config = None - mina_target = _get_build_target(config_settings) - if mina_target is not None: - if not _has_package(mina_target): - raise ValueError(f"{mina_target} is not defined as a mina package") - _patched_config = _patch_pdm_config(mina_target) # os.chdir may break behavior - with EditableBuilder(Path.cwd(), config_settings) as builder: - if _patched_config is not None: - builder.config = _patched_config - return builder.prepare_metadata(metadata_directory).name - - -def build_editable( - wheel_directory: str, - config_settings: Optional[Mapping[str, Any]] = None, - metadata_directory: Optional[str] = None, -) -> str: - from pdm.backend.editable import EditableBuilder - - _patched_config = None - mina_target = _get_build_target(config_settings) - if mina_target is not None: - if not _has_package(mina_target): - raise ValueError(f"{mina_target} is not defined as a mina package") - _patched_config = _patch_pdm_config(mina_target) # os.chdir may break behavior - with EditableBuilder(Path.cwd(), config_settings) as builder: - if _patched_config is not None: - builder.config = _patched_config - return builder.build( - wheel_directory, metadata_directory=metadata_directory - ).name diff --git a/mina/commands/build.py b/mina/commands/build.py deleted file mode 100644 index fb7f2b3..0000000 --- a/mina/commands/build.py +++ /dev/null @@ -1,180 +0,0 @@ -from __future__ import annotations - -import argparse -import shutil -import sys -from pathlib import Path - -try: - import tomllib as tomli # type: ignore -except ImportError: - try: - from pdm.backend._vendor import tomli - except ImportError: - import tomli -from pdm.builders.sdist import SdistBuilder -from pdm.builders.wheel import WheelBuilder -from pdm.cli.commands.base import BaseCommand -from pdm.cli.options import ( - no_isolation_option, - project_option, - skip_option, - verbose_option, -) -from pdm.exceptions import ProjectError -from pdm.project.core import Project - - -def do_build_mina( - project: Project, - packages: list[str], - option_sdist: bool = True, - option_wheel: bool = True, - option_dest: str = "dist", - option_clean: bool = True, - config_settings: dict[str, str] | None = None, -): - if project.is_global: - project.core.ui.echo("You can't build packages in global project.", err=True) - raise ProjectError("Global project not supported") - if not option_wheel and not option_sdist: - project.core.ui.echo("You must build at least one of sdist or wheel.", err=True) - raise ProjectError("No build type specified") - dest = Path(option_dest).absolute() - if option_clean: - shutil.rmtree(dest, ignore_errors=True) - artifacts: list[str] = [] - for package in packages: - settings = (config_settings or {}).copy() - settings.setdefault("--mina-target", package) - project.core.ui.echo(f"Building package {package}...") - with project.core.ui.logging("Building packages"): - if option_sdist: - project.core.ui.echo(" - Building sdist") - loc = SdistBuilder(project.root, project.environment).build( - option_dest, settings - ) - project.core.ui.echo(f" - completed: {loc}") - artifacts.append(loc) - if option_wheel: - project.core.ui.echo(" - Building wheel") - loc = WheelBuilder(project.root, project.environment).build( - option_dest, settings - ) - project.core.ui.echo(f" - completed: {loc}") - artifacts.append(loc) - project.core.ui.echo(f"{package} build completed.") - project.core.ui.echo( - f"Successfully built {len(packages)} packages: {len(artifacts)} artifacts" - ) - return artifacts - - -class MinaCommandNamespace: - packages: list[str] - all: bool - sdist: bool - wheel: bool - dest: str - clean: bool - config_setting: list[str] - - -class MinaBuildCommand(BaseCommand): - arguments = (verbose_option, project_option, no_isolation_option, skip_option) - - def add_arguments(self, parser: argparse.ArgumentParser) -> None: - parser.add_argument( - "packages", - nargs="*", - help="Packages to build, which must be defined in pyproject.toml.", - ) - parser.add_argument( - "-a", - "--all", - default=False, - action="store_true", - help="Build all packages.", - ) - parser.add_argument( - "--no-sdist", - dest="sdist", - default=True, - action="store_false", - help="Don't build source tarballs", - ) - parser.add_argument( - "--no-wheel", - dest="wheel", - default=True, - action="store_false", - help="Don't build wheels", - ) - parser.add_argument( - "-d", "--dest", default="dist", help="Target directory to put artifacts" - ) - parser.add_argument( - "--no-clean", - dest="clean", - default=True, - action="store_false", - help="Do not clean the target directory", - ) - parser.add_argument( - "--config-setting", - "-C", - action="append", - default=[], - help="Pass options to the backend. options with a value must be " - 'specified after "=": "--config-setting=--opt(=value)" ' - 'or "-C--opt(=value)"', - ) - - def handle(self, project: Project, options: MinaCommandNamespace): - if not (project.root / "pyproject.toml").exists(): - project.core.ui.echo("No pyproject.toml found.", err=True) - sys.exit(1) - pyproj = tomli.loads( - (project.root / "pyproject.toml").read_text(encoding="utf-8") - ) - mina_packages = pyproj.get("tool", {}).get("mina", {}).get("packages", []) - for i in project.root.glob(".mina/*.toml"): - name = i.name[:-5] - if name not in mina_packages: - mina_packages.append(name) - - packages = options.packages - - if options.all: - if packages: - raise ProjectError("Cannot specify packages and --all") - packages = mina_packages - - if not packages: - raise ProjectError("No package specified") - - errors: list[str] = [ - package for package in packages if package not in mina_packages - ] - if errors: - raise ProjectError(f"Package(s) not found: {', '.join(errors)}") - - config_settings = {} - for item in options.config_setting: - name, _, value = item.partition("=") - if name not in config_settings: - config_settings[name] = value - else: - if not isinstance(config_settings[name], list): - config_settings[name] = [config_settings[name]] - config_settings[name].append(value) - artifacts = do_build_mina( - project, - packages, - options.sdist, - options.wheel, - options.dest, - options.clean, - config_settings, - ) - # artifacts 后面还可以拿来做其他的事情, 比如 publish. diff --git a/pdm.lock b/pdm.lock index 5665137..80d130a 100644 --- a/pdm.lock +++ b/pdm.lock @@ -3,15 +3,15 @@ [metadata] groups = ["default", "dev"] -cross_platform = true -static_urls = false -lock_version = "4.3" -content_hash = "sha256:503e8b32ce8d83106d3f13f8a07403b14598345ac6833097cd8e778585d99bc7" +strategy = ["cross_platform", "inherit_metadata"] +lock_version = "4.4.1" +content_hash = "sha256:87118014545392ee3e8be66780dafcd0e7799efff79115d522c7d6c539545957" [[package]] name = "asttokens" version = "2.0.5" summary = "Annotate AST trees with source code positions" +groups = ["dev"] dependencies = [ "six", ] @@ -25,6 +25,7 @@ name = "black" version = "23.7.0" requires_python = ">=3.8" summary = "The uncompromising code formatter." +groups = ["dev"] dependencies = [ "click>=8.0.0", "mypy-extensions>=0.4.3", @@ -54,24 +55,11 @@ files = [ {file = "black-23.7.0.tar.gz", hash = "sha256:022a582720b0d9480ed82576c920a8c1dde97cc38ff11d8d8859b3bd6ca9eedb"}, ] -[[package]] -name = "bleach" -version = "5.0.1" -requires_python = ">=3.7" -summary = "An easy safelist-based HTML-sanitizing tool." -dependencies = [ - "six>=1.9.0", - "webencodings", -] -files = [ - {file = "bleach-5.0.1-py3-none-any.whl", hash = "sha256:085f7f33c15bd408dd9b17a4ad77c577db66d76203e5984b1bd59baeee948b2a"}, - {file = "bleach-5.0.1.tar.gz", hash = "sha256:0d03255c47eb9bd2f26aa9bb7f2107732e7e8fe195ca2f64709fcf3b0a4a085c"}, -] - [[package]] name = "blinker" version = "1.4" summary = "Fast, simple object-to-object and broadcast signaling" +groups = ["dev"] files = [ {file = "blinker-1.4.tar.gz", hash = "sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6"}, ] @@ -81,6 +69,7 @@ name = "cachecontrol" version = "0.13.1" requires_python = ">=3.7" summary = "httplib2 caching for requests" +groups = ["dev"] dependencies = [ "msgpack>=0.5.2", "requests>=2.16.0", @@ -96,6 +85,7 @@ version = "0.13.1" extras = ["filecache"] requires_python = ">=3.7" summary = "httplib2 caching for requests" +groups = ["dev"] dependencies = [ "cachecontrol==0.13.1", "filelock>=3.8.0", @@ -110,59 +100,18 @@ name = "certifi" version = "2022.6.15" requires_python = ">=3.6" summary = "Python package for providing Mozilla's CA Bundle." +groups = ["dev"] files = [ {file = "certifi-2022.6.15-py3-none-any.whl", hash = "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"}, {file = "certifi-2022.6.15.tar.gz", hash = "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"}, ] -[[package]] -name = "cffi" -version = "1.15.1" -summary = "Foreign Function Interface for Python calling C code." -dependencies = [ - "pycparser", -] -files = [ - {file = "cffi-1.15.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21"}, - {file = "cffi-1.15.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e"}, - {file = "cffi-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4"}, - {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01"}, - {file = "cffi-1.15.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e"}, - {file = "cffi-1.15.1-cp310-cp310-win32.whl", hash = "sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2"}, - {file = "cffi-1.15.1-cp310-cp310-win_amd64.whl", hash = "sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d"}, - {file = "cffi-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac"}, - {file = "cffi-1.15.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325"}, - {file = "cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c"}, - {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef"}, - {file = "cffi-1.15.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8"}, - {file = "cffi-1.15.1-cp311-cp311-win32.whl", hash = "sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d"}, - {file = "cffi-1.15.1-cp311-cp311-win_amd64.whl", hash = "sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104"}, - {file = "cffi-1.15.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585"}, - {file = "cffi-1.15.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35"}, - {file = "cffi-1.15.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27"}, - {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76"}, - {file = "cffi-1.15.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3"}, - {file = "cffi-1.15.1-cp39-cp39-win32.whl", hash = "sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee"}, - {file = "cffi-1.15.1-cp39-cp39-win_amd64.whl", hash = "sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c"}, - {file = "cffi-1.15.1.tar.gz", hash = "sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9"}, -] - [[package]] name = "charset-normalizer" version = "2.1.0" requires_python = ">=3.6.0" summary = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +groups = ["dev"] files = [ {file = "charset-normalizer-2.1.0.tar.gz", hash = "sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413"}, {file = "charset_normalizer-2.1.0-py3-none-any.whl", hash = "sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5"}, @@ -173,6 +122,7 @@ name = "click" version = "8.1.3" requires_python = ">=3.7" summary = "Composable command line interface toolkit" +groups = ["dev"] dependencies = [ "colorama; platform_system == \"Windows\"", ] @@ -186,6 +136,8 @@ name = "colorama" version = "0.4.5" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" summary = "Cross-platform colored terminal text." +groups = ["dev"] +marker = "platform_system == \"Windows\"" files = [ {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, @@ -195,42 +147,24 @@ files = [ name = "commonmark" version = "0.9.1" summary = "Python parser for the CommonMark Markdown spec" +groups = ["dev"] files = [ {file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"}, {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, ] [[package]] -name = "cryptography" -version = "37.0.4" -requires_python = ">=3.6" -summary = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." +name = "dep-logic" +version = "0.0.4" +requires_python = ">=3.8" +summary = "Python dependency specifications supporting logical operations" +groups = ["dev"] dependencies = [ - "cffi>=1.12", -] -files = [ - {file = "cryptography-37.0.4-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:549153378611c0cca1042f20fd9c5030d37a72f634c9326e225c9f666d472884"}, - {file = "cryptography-37.0.4-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:a958c52505c8adf0d3822703078580d2c0456dd1d27fabfb6f76fe63d2971cd6"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f721d1885ecae9078c3f6bbe8a88bc0786b6e749bf32ccec1ef2b18929a05046"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:3d41b965b3380f10e4611dbae366f6dc3cefc7c9ac4e8842a806b9672ae9add5"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:80f49023dd13ba35f7c34072fa17f604d2f19bf0989f292cedf7ab5770b87a0b"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2dcb0b3b63afb6df7fd94ec6fbddac81b5492513f7b0436210d390c14d46ee8"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:b7f8dd0d4c1f21759695c05a5ec8536c12f31611541f8904083f3dc582604280"}, - {file = "cryptography-37.0.4-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:30788e070800fec9bbcf9faa71ea6d8068f5136f60029759fd8c3efec3c9dcb3"}, - {file = "cryptography-37.0.4-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:190f82f3e87033821828f60787cfa42bff98404483577b591429ed99bed39d59"}, - {file = "cryptography-37.0.4-cp36-abi3-win32.whl", hash = "sha256:b62439d7cd1222f3da897e9a9fe53bbf5c104fff4d60893ad1355d4c14a24157"}, - {file = "cryptography-37.0.4-cp36-abi3-win_amd64.whl", hash = "sha256:f7a6de3e98771e183645181b3627e2563dcde3ce94a9e42a3f427d2255190327"}, - {file = "cryptography-37.0.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bc95ed67b6741b2607298f9ea4932ff157e570ef456ef7ff0ef4884a134cc4b"}, - {file = "cryptography-37.0.4-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:f8c0a6e9e1dd3eb0414ba320f85da6b0dcbd543126e30fcc546e7372a7fbf3b9"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:e007f052ed10cc316df59bc90fbb7ff7950d7e2919c9757fd42a2b8ecf8a5f67"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7bc997818309f56c0038a33b8da5c0bfbb3f1f067f315f9abd6fc07ad359398d"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:d204833f3c8a33bbe11eda63a54b1aad7aa7456ed769a982f21ec599ba5fa282"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:75976c217f10d48a8b5a8de3d70c454c249e4b91851f6838a4e48b8f41eb71aa"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:7099a8d55cd49b737ffc99c17de504f2257e3787e02abe6d1a6d136574873441"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2be53f9f5505673eeda5f2736bea736c40f051a739bfae2f92d18aed1eb54596"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:91ce48d35f4e3d3f1d83e29ef4a9267246e6a3be51864a5b7d2247d5086fa99a"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:4c590ec31550a724ef893c50f9a97a0c14e9c851c85621c5650d699a7b88f7ab"}, - {file = "cryptography-37.0.4.tar.gz", hash = "sha256:63f9c17c0e2474ccbebc9302ce2f07b55b3b3fcb211ded18a42d5764f5c10a82"}, + "packaging>=22", +] +files = [ + {file = "dep_logic-0.0.4-py3-none-any.whl", hash = "sha256:65ab4122d5aaf4ec188dafc4cfdce55064929cf9e83d1aedcd57d6f586833b34"}, + {file = "dep_logic-0.0.4.tar.gz", hash = "sha256:1830e784e0d58fc93511e77da164887629641b65b38876b274db974ec5f3889f"}, ] [[package]] @@ -238,6 +172,7 @@ name = "devtools" version = "0.11.0" requires_python = ">=3.7" summary = "Python's missing debug print command, and more." +groups = ["dev"] dependencies = [ "asttokens<3.0.0,>=2.0.0", "executing>=1.1.1", @@ -251,35 +186,17 @@ files = [ name = "distlib" version = "0.3.4" summary = "Distribution utilities" +groups = ["dev"] files = [ {file = "distlib-0.3.4-py2.py3-none-any.whl", hash = "sha256:6564fe0a8f51e734df6333d08b8b94d4ea8ee6b99b5ed50613f731fd4089f34b"}, {file = "distlib-0.3.4.zip", hash = "sha256:e4b58818180336dc9c529bfb9a0b58728ffc09ad92027a3f30b7cd91e3458579"}, ] -[[package]] -name = "docutils" -version = "0.19" -requires_python = ">=3.7" -summary = "Docutils -- Python Documentation Utilities" -files = [ - {file = "docutils-0.19-py3-none-any.whl", hash = "sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc"}, - {file = "docutils-0.19.tar.gz", hash = "sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6"}, -] - -[[package]] -name = "editables" -version = "0.5" -requires_python = ">=3.7" -summary = "Editable installations" -files = [ - {file = "editables-0.5-py3-none-any.whl", hash = "sha256:61e5ffa82629e0d8bfe09bc44a07db3c1ab8ed1ce78a6980732870f19b5e7d4c"}, - {file = "editables-0.5.tar.gz", hash = "sha256:309627d9b5c4adc0e668d8c6fa7bac1ba7c8c5d415c2d27f60f081f8e80d1de2"}, -] - [[package]] name = "executing" version = "1.2.0" summary = "Get the currently executing AST node of a frame, and other information" +groups = ["dev"] files = [ {file = "executing-1.2.0-py2.py3-none-any.whl", hash = "sha256:0314a69e37426e3608aada02473b4161d4caf5a4b244d1d0c48072b8fee7bacc"}, {file = "executing-1.2.0.tar.gz", hash = "sha256:19da64c18d2d851112f09c287f8d3dbbdf725ab0e569077efb6cdcbd3497c107"}, @@ -290,6 +207,7 @@ name = "filelock" version = "3.12.0" requires_python = ">=3.7" summary = "A platform independent file lock." +groups = ["dev"] files = [ {file = "filelock-3.12.0-py3-none-any.whl", hash = "sha256:ad98852315c2ab702aeb628412cbf7e95b7ce8c3bf9565670b4eaecf1db370a9"}, {file = "filelock-3.12.0.tar.gz", hash = "sha256:fc03ae43288c013d2ea83c8597001b1129db351aad9c57fe2409327916b8e718"}, @@ -297,15 +215,16 @@ files = [ [[package]] name = "findpython" -version = "0.3.1" +version = "0.4.1" requires_python = ">=3.7" summary = "A utility to find python versions on your system" +groups = ["dev"] dependencies = [ "packaging>=20", ] files = [ - {file = "findpython-0.3.1-py3-none-any.whl", hash = "sha256:b57a67fc95cc687bfcfa4944c730a5e368b8cbe20f84ad4cdbc9d6bfe128f50b"}, - {file = "findpython-0.3.1.tar.gz", hash = "sha256:7621f8a9c199a70d219831cddaeb84ca7e83e20b8358172bff47871a18a5eda4"}, + {file = "findpython-0.4.1-py3-none-any.whl", hash = "sha256:ca3a5272704b0b8a2f5e8d03d816701ec99f13eafee9bb2a316cbf099c937ede"}, + {file = "findpython-0.4.1.tar.gz", hash = "sha256:d7d014558681b3761d57a5b2342a713a8bf302f6c1fc9d99f81b9d8bd1681b04"}, ] [[package]] @@ -313,6 +232,7 @@ name = "idna" version = "3.3" requires_python = ">=3.5" summary = "Internationalized Domain Names in Applications (IDNA)" +groups = ["dev"] files = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, @@ -323,6 +243,8 @@ name = "importlib-metadata" version = "4.12.0" requires_python = ">=3.7" summary = "Read metadata from Python packages" +groups = ["dev"] +marker = "python_version < \"3.10\"" dependencies = [ "zipp>=0.5", ] @@ -336,6 +258,7 @@ name = "installer" version = "0.7.0" requires_python = ">=3.7" summary = "A library for installing Python wheels." +groups = ["dev"] files = [ {file = "installer-0.7.0-py3-none-any.whl", hash = "sha256:05d1933f0a5ba7d8d6296bb6d5018e7c94fa473ceb10cf198a92ccea19c27b53"}, {file = "installer-0.7.0.tar.gz", hash = "sha256:a26d3e3116289bb08216e0d0f7d925fcef0b0194eedfa0c944bcaaa106c4b631"}, @@ -346,55 +269,17 @@ name = "isort" version = "5.12.0" requires_python = ">=3.8.0" summary = "A Python utility / library to sort Python imports." +groups = ["dev"] files = [ {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, ] -[[package]] -name = "jeepney" -version = "0.8.0" -requires_python = ">=3.7" -summary = "Low-level, pure Python DBus protocol wrapper." -files = [ - {file = "jeepney-0.8.0-py3-none-any.whl", hash = "sha256:c0a454ad016ca575060802ee4d590dd912e35c122fa04e70306de3d076cce755"}, - {file = "jeepney-0.8.0.tar.gz", hash = "sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806"}, -] - -[[package]] -name = "keyring" -version = "23.6.0" -requires_python = ">=3.7" -summary = "Store and access your passwords safely." -dependencies = [ - "SecretStorage>=3.2; sys_platform == \"linux\"", - "importlib-metadata>=3.6; python_version < \"3.10\"", - "jeepney>=0.4.2; sys_platform == \"linux\"", - "pywin32-ctypes!=0.1.0,!=0.1.1; sys_platform == \"win32\"", -] -files = [ - {file = "keyring-23.6.0-py3-none-any.whl", hash = "sha256:372ff2fc43ab779e3f87911c26e6c7acc8bb440cbd82683e383ca37594cb0617"}, - {file = "keyring-23.6.0.tar.gz", hash = "sha256:3ac00c26e4c93739e19103091a9986a9f79665a78cf15a4df1dba7ea9ac8da2f"}, -] - -[[package]] -name = "mina-build" -version = "0.4.0" -requires_python = ">=3.9" -summary = "build backend for Mina Package Structure" -dependencies = [ - "pdm-backend>=2.1.0", - "tomli>=1.1.0; python_version < \"3.11\"", -] -files = [ - {file = "mina-build-0.4.0.tar.gz", hash = "sha256:8a4e308c17ee4da2a3e6b60721afc43f757f1526bae9536e2ab889fb690c8488"}, - {file = "mina_build-0.4.0-py3-none-any.whl", hash = "sha256:de2277ce643df82fe729af2bee3a2a4a090248cbfaa427bbc66defc87f4dbe61"}, -] - [[package]] name = "msgpack" version = "1.0.4" summary = "MessagePack serializer" +groups = ["dev"] files = [ {file = "msgpack-1.0.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4ab251d229d10498e9a2f3b1e68ef64cb393394ec477e3370c457f9430ce9250"}, {file = "msgpack-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:112b0f93202d7c0fef0b7810d465fde23c746a2d482e1e2de2aafd2ce1492c88"}, @@ -425,6 +310,7 @@ files = [ name = "mypy-extensions" version = "0.4.3" summary = "Experimental type system extensions for programs checked with the mypy typechecker." +groups = ["dev"] files = [ {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, @@ -435,6 +321,7 @@ name = "packaging" version = "23.1" requires_python = ">=3.7" summary = "Core utilities for Python packages" +groups = ["dev"] files = [ {file = "packaging-23.1-py3-none-any.whl", hash = "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61"}, {file = "packaging-23.1.tar.gz", hash = "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f"}, @@ -445,6 +332,7 @@ name = "pathspec" version = "0.9.0" requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" summary = "Utility library for gitignore style pattern matching of file paths." +groups = ["dev"] files = [ {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, @@ -452,14 +340,16 @@ files = [ [[package]] name = "pdm" -version = "2.8.2" -requires_python = ">=3.7" +version = "2.12.3" +requires_python = ">=3.8" summary = "A modern Python package and dependency manager supporting the latest PEP standards" +groups = ["dev"] dependencies = [ "blinker", "cachecontrol[filecache]>=0.13.0", "certifi", - "findpython<1.0.0a0,>=0.3.0", + "dep-logic<1.0,>=0.0.2", + "findpython<1.0.0a0,>=0.4.0", "importlib-metadata>=3.6; python_version < \"3.10\"", "installer<0.8,>=0.7", "packaging!=22.0,>=20.9", @@ -472,35 +362,27 @@ dependencies = [ "shellingham>=1.3.2", "tomli>=1.1.0; python_version < \"3.11\"", "tomlkit<1,>=0.11.1", - "unearth>=0.10.0", + "truststore; python_version >= \"3.10\"", + "unearth>=0.12.1", "virtualenv>=20", ] files = [ - {file = "pdm-2.8.2-py3-none-any.whl", hash = "sha256:b1de3411d26cc7525741c7f0a84a00e6834f63105c19da13df9a61c229ba45d9"}, - {file = "pdm-2.8.2.tar.gz", hash = "sha256:b948d00bf620682b0ac4c80d228cb305a2b0150e497ee6931da30e3cc305bfdc"}, + {file = "pdm-2.12.3-py3-none-any.whl", hash = "sha256:27eddf71434906e39db3f448d35ea5ee1f4d0f557de39fc932205f7dfc82f902"}, + {file = "pdm-2.12.3.tar.gz", hash = "sha256:53cdab727c1469fdc196efd8d7ff8404a3ca91ee43c0a5714736f2020d0a5ddf"}, ] [[package]] name = "pdm-backend" -version = "2.1.4" +version = "2.1.8" requires_python = ">=3.7" summary = "The build backend used by PDM that supports latest packaging standards" +groups = ["dev"] dependencies = [ "importlib-metadata>=3.6; python_version < \"3.10\"", ] files = [ - {file = "pdm_backend-2.1.4-py3-none-any.whl", hash = "sha256:72e8d560cb7f5b2f6b0a09a01705edd2cb823b762a3e188e1ac334d4415bac1b"}, - {file = "pdm_backend-2.1.4.tar.gz", hash = "sha256:f39637cafd739213459a41d27421bad8601eed5262ac828c2519b023a0ffbf14"}, -] - -[[package]] -name = "pkginfo" -version = "1.8.3" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" -summary = "Query metadatdata from sdists / bdists / installed packages." -files = [ - {file = "pkginfo-1.8.3-py2.py3-none-any.whl", hash = "sha256:848865108ec99d4901b2f7e84058b6e7660aae8ae10164e015a6dcf5b242a594"}, - {file = "pkginfo-1.8.3.tar.gz", hash = "sha256:a84da4318dd86f870a9447a8c98340aa06216bfc6f2b7bdc4b8766984ae1867c"}, + {file = "pdm_backend-2.1.8-py3-none-any.whl", hash = "sha256:fc69799e40817daf9bb9ce8f93ff650d59e093bf86fa3a5264b26a9ef579563d"}, + {file = "pdm_backend-2.1.8.tar.gz", hash = "sha256:2487dfbd13f69d80fb4e6a08006a3ee68272833970813047dc5fcfacdfdc0151"}, ] [[package]] @@ -508,26 +390,18 @@ name = "platformdirs" version = "2.5.2" requires_python = ">=3.7" summary = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +groups = ["dev"] files = [ {file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"}, {file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"}, ] -[[package]] -name = "pycparser" -version = "2.21" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -summary = "C parser in Python" -files = [ - {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, - {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, -] - [[package]] name = "pygments" version = "2.12.0" requires_python = ">=3.6" summary = "Pygments is a syntax highlighting package written in Python." +groups = ["dev"] files = [ {file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"}, {file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"}, @@ -538,6 +412,7 @@ name = "pyproject-hooks" version = "1.0.0" requires_python = ">=3.7" summary = "Wrappers to call pyproject.toml-based build backend hooks." +groups = ["dev"] dependencies = [ "tomli>=1.1.0; python_version < \"3.11\"", ] @@ -551,40 +426,18 @@ name = "python-dotenv" version = "0.20.0" requires_python = ">=3.5" summary = "Read key-value pairs from a .env file and set them as environment variables" +groups = ["dev"] files = [ {file = "python-dotenv-0.20.0.tar.gz", hash = "sha256:b7e3b04a59693c42c36f9ab1cc2acc46fa5df8c78e178fc33a8d4cd05c8d498f"}, {file = "python_dotenv-0.20.0-py3-none-any.whl", hash = "sha256:d92a187be61fe482e4fd675b6d52200e7be63a12b724abbf931a40ce4fa92938"}, ] -[[package]] -name = "pywin32-ctypes" -version = "0.2.0" -summary = "UNKNOWN" -files = [ - {file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"}, - {file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"}, -] - -[[package]] -name = "readme-renderer" -version = "35.0" -requires_python = ">=3.7" -summary = "readme_renderer is a library for rendering \"readme\" descriptions for Warehouse" -dependencies = [ - "Pygments>=2.5.1", - "bleach>=2.1.0", - "docutils>=0.13.1", -] -files = [ - {file = "readme_renderer-35.0-py3-none-any.whl", hash = "sha256:73b84905d091c31f36e50b4ae05ae2acead661f6a09a9abb4df7d2ddcdb6a698"}, - {file = "readme_renderer-35.0.tar.gz", hash = "sha256:a727999acfc222fc21d82a12ed48c957c4989785e5865807c65a487d21677497"}, -] - [[package]] name = "requests" version = "2.28.1" requires_python = ">=3.7, <4" summary = "Python HTTP for Humans." +groups = ["dev"] dependencies = [ "certifi>=2017.4.17", "charset-normalizer<3,>=2", @@ -600,6 +453,7 @@ files = [ name = "requests-toolbelt" version = "0.9.1" summary = "A utility belt for advanced users of python-requests" +groups = ["dev"] dependencies = [ "requests<3.0.0,>=2.0.1", ] @@ -612,26 +466,18 @@ files = [ name = "resolvelib" version = "1.0.1" summary = "Resolve abstract dependencies into concrete ones" +groups = ["dev"] files = [ {file = "resolvelib-1.0.1-py2.py3-none-any.whl", hash = "sha256:d2da45d1a8dfee81bdd591647783e340ef3bcb104b54c383f70d422ef5cc7dbf"}, {file = "resolvelib-1.0.1.tar.gz", hash = "sha256:04ce76cbd63fded2078ce224785da6ecd42b9564b1390793f64ddecbe997b309"}, ] -[[package]] -name = "rfc3986" -version = "2.0.0" -requires_python = ">=3.7" -summary = "Validating URI References per RFC 3986" -files = [ - {file = "rfc3986-2.0.0-py2.py3-none-any.whl", hash = "sha256:50b1502b60e289cb37883f3dfd34532b8873c7de9f49bb546641ce9cbd256ebd"}, - {file = "rfc3986-2.0.0.tar.gz", hash = "sha256:97aacf9dbd4bfd829baad6e6309fa6573aaf1be3f6fa735c8ab05e46cecb261c"}, -] - [[package]] name = "rich" version = "12.4.4" requires_python = ">=3.6.3,<4.0.0" summary = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" +groups = ["dev"] dependencies = [ "commonmark<0.10.0,>=0.9.0", "pygments<3.0.0,>=2.6.0", @@ -641,25 +487,12 @@ files = [ {file = "rich-12.4.4.tar.gz", hash = "sha256:4c586de507202505346f3e32d1363eb9ed6932f0c2f63184dea88983ff4971e2"}, ] -[[package]] -name = "secretstorage" -version = "3.3.2" -requires_python = ">=3.6" -summary = "Python bindings to FreeDesktop.org Secret Service API" -dependencies = [ - "cryptography>=2.0", - "jeepney>=0.6", -] -files = [ - {file = "SecretStorage-3.3.2-py3-none-any.whl", hash = "sha256:755dc845b6ad76dcbcbc07ea3da75ae54bb1ea529eb72d15f83d26499a5df319"}, - {file = "SecretStorage-3.3.2.tar.gz", hash = "sha256:0a8eb9645b320881c222e827c26f4cfcf55363e8b374a021981ef886657a912f"}, -] - [[package]] name = "shellingham" version = "1.4.0" requires_python = "!=3.0,!=3.1,!=3.2,!=3.3,>=2.6" summary = "Tool to Detect Surrounding Shell" +groups = ["dev"] files = [ {file = "shellingham-1.4.0-py2.py3-none-any.whl", hash = "sha256:536b67a0697f2e4af32ab176c00a50ac2899c5a05e0d8e2dadac8e58888283f9"}, {file = "shellingham-1.4.0.tar.gz", hash = "sha256:4855c2458d6904829bd34c299f11fdeed7cfefbf8a2c522e4caea6cd76b3171e"}, @@ -670,6 +503,7 @@ name = "six" version = "1.16.0" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" summary = "Python 2 and 3 compatibility utilities" +groups = ["dev"] files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -680,6 +514,8 @@ name = "tomli" version = "2.0.1" requires_python = ">=3.7" summary = "A lil' TOML parser" +groups = ["dev"] +marker = "python_version < \"3.11\"" files = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, @@ -690,30 +526,22 @@ name = "tomlkit" version = "0.11.1" requires_python = ">=3.6,<4.0" summary = "Style preserving TOML library" +groups = ["dev"] files = [ {file = "tomlkit-0.11.1-py3-none-any.whl", hash = "sha256:1c5bebdf19d5051e2e1de6cf70adfc5948d47221f097fcff7a3ffc91e953eaf5"}, {file = "tomlkit-0.11.1.tar.gz", hash = "sha256:61901f81ff4017951119cd0d1ed9b7af31c821d6845c8c477587bbdcd5e5854e"}, ] [[package]] -name = "twine" -version = "4.0.2" -requires_python = ">=3.7" -summary = "Collection of utilities for publishing packages on PyPI" -dependencies = [ - "importlib-metadata>=3.6", - "keyring>=15.1", - "pkginfo>=1.8.1", - "readme-renderer>=35.0", - "requests-toolbelt!=0.9.0,>=0.8.0", - "requests>=2.20", - "rfc3986>=1.4.0", - "rich>=12.0.0", - "urllib3>=1.26.0", -] +name = "truststore" +version = "0.8.0" +requires_python = ">= 3.10" +summary = "Verify certificates using native system trust stores" +groups = ["dev"] +marker = "python_version >= \"3.10\"" files = [ - {file = "twine-4.0.2-py3-none-any.whl", hash = "sha256:929bc3c280033347a00f847236564d1c52a3e61b1ac2516c97c48f3ceab756d8"}, - {file = "twine-4.0.2.tar.gz", hash = "sha256:9e102ef5fdd5a20661eb88fad46338806c3bd32cf1db729603fe3697b1bc83c8"}, + {file = "truststore-0.8.0-py3-none-any.whl", hash = "sha256:e37a5642ae9fc48caa8f120b6283d77225d600d224965a672c9e8ef49ce4bb4c"}, + {file = "truststore-0.8.0.tar.gz", hash = "sha256:dc70da89634944a579bfeec70a7a4523c53ffdb3cf52d1bb4a431fda278ddb96"}, ] [[package]] @@ -721,6 +549,8 @@ name = "typing-extensions" version = "4.3.0" requires_python = ">=3.7" summary = "Backported and Experimental Type Hints for Python 3.7+" +groups = ["dev"] +marker = "python_version < \"3.10\"" files = [ {file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"}, {file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"}, @@ -728,16 +558,17 @@ files = [ [[package]] name = "unearth" -version = "0.10.0" -requires_python = ">=3.7" +version = "0.14.0" +requires_python = ">=3.8" summary = "A utility to fetch and download python packages" +groups = ["dev"] dependencies = [ "packaging>=20", "requests>=2.25", ] files = [ - {file = "unearth-0.10.0-py3-none-any.whl", hash = "sha256:e8b36f6efd6b677a3ff86354675368a79e98ee8ba01aaa601858e2cc043bc51a"}, - {file = "unearth-0.10.0.tar.gz", hash = "sha256:d5b152a5ab2aa3e5149a11cf7b3ba5c5d493176dca38f66ca8969dadd5a8f645"}, + {file = "unearth-0.14.0-py3-none-any.whl", hash = "sha256:a2b937ca22198043f5360192bce38708f11ddc5d4cdea973ee38583219b97d5d"}, + {file = "unearth-0.14.0.tar.gz", hash = "sha256:f3cddfb94ac0f865fbcf964231556ef7183010379c00b01205517a50c78a186d"}, ] [[package]] @@ -745,6 +576,7 @@ name = "urllib3" version = "1.26.10" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4" summary = "HTTP library with thread-safe connection pooling, file post, and more." +groups = ["dev"] files = [ {file = "urllib3-1.26.10-py2.py3-none-any.whl", hash = "sha256:8298d6d56d39be0e3bc13c1c97d133f9b45d797169a0e11cdd0e0489d786f7ec"}, {file = "urllib3-1.26.10.tar.gz", hash = "sha256:879ba4d1e89654d9769ce13121e0f94310ea32e8d2f8cf587b77c08bbcdb30d6"}, @@ -755,6 +587,7 @@ name = "virtualenv" version = "20.15.1" requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" summary = "Virtual Python Environment builder" +groups = ["dev"] dependencies = [ "distlib<1,>=0.3.1", "filelock<4,>=3.2", @@ -766,20 +599,13 @@ files = [ {file = "virtualenv-20.15.1.tar.gz", hash = "sha256:288171134a2ff3bfb1a2f54f119e77cd1b81c29fc1265a2356f3e8d14c7d58c4"}, ] -[[package]] -name = "webencodings" -version = "0.5.1" -summary = "Character encoding aliases for legacy web content" -files = [ - {file = "webencodings-0.5.1-py2.py3-none-any.whl", hash = "sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78"}, - {file = "webencodings-0.5.1.tar.gz", hash = "sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"}, -] - [[package]] name = "zipp" version = "3.8.0" requires_python = ">=3.7" summary = "Backport of pathlib-compatible object wrapper for zip files" +groups = ["dev"] +marker = "python_version < \"3.10\"" files = [ {file = "zipp-3.8.0-py3-none-any.whl", hash = "sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099"}, {file = "zipp-3.8.0.tar.gz", hash = "sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad"}, diff --git a/pyproject.toml b/pyproject.toml index e1da0df..1cebe3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,34 +1,31 @@ [project] -name = "pdm-mina-workspace" # won't publish to pypi -version = "0.0.1" -description = "multi-publish for a series of packages which from a python package" +name = "pdm-mina" +version = "0.3.1" +requires-python = ">=3.9" +readme = "README.md" authors = [ {name = "GreyElaina", email = "GreyElaina@outlook.com"}, ] -dependencies = [ - "pdm>=2.5.0", - "mina-build>=0.2.1", - "twine>=4.0.0", - "tomli>=1.1.0; python_version < \"3.11\"", - "pdm-backend>=2.1.0", - "editables>=0.5", -] -requires-python = ">=3.9" -readme = "README.md" license = {text = "MIT"} -[tool.pdm] [tool.pdm.dev-dependencies] dev = [ "black>=22.3.0", "isort>=5.10.1", "devtools>=0.8.0", + "pdm>=2.10.0", + "pdm-backend>=2.1.0", ] +[tool.pdm.build] +includes = [ + "src/mina" +] +custom-hook = "src/mina_backend/hooks.py" [build-system] -requires = ["mina-build>=0.2.6", "editables"] -build-backend = "mina.backend" +requires = ["pdm-backend"] +build-backend = "pdm.backend" [project.entry-points.pdm] mina = "mina.plugin:ensure_pdm" @@ -37,50 +34,22 @@ mina = "mina.plugin:ensure_pdm" enabled = true override-global = false # default value +[tool.mina.packages."cli-pdm"] -[tool.mina.packages."backend"] -override = false +[tool.mina.packages.backend] includes = [ - "mina/backend" + "src/mina_backend" ] -raw-dependencies = [] -# dev-dependencies is owned by workspace. - -[tool.mina.packages."backend".project] +[tool.mina.packages.backend.project] name = "mina-build" version = "0.5.2" description = "build backend for Mina Package Structure" -authors = [ - {name = "GreyElaina", email = "GreyElaina@outlook.com"}, -] dependencies = [ - "pdm-backend", - "tomli", - "editables" + "pdm-backend" ] -requires-python = ">=3.9" readme = "README.build.md" -license = {text = "MIT"} - -[tool.mina.packages."cli-pdm"] -includes = [ - "mina" -] -excludes = [ - "mina/backend" -] +[tool.mina.packages.backend.project.entry-points."pdm.build.hook"] +mina = "mina_backend.hooks" -[tool.mina.packages."cli-pdm".project] -name = "pdm-mina" -version = "0.3.1" -dependencies = [ - "pdm", - "mina-build", - "tomli" -] -requires-python = ">=3.9" -readme = "README.md" -license = {text = "MIT"} -entry-points = {pdm = {mina = "mina.plugin:ensure_pdm"}} diff --git a/mina/__init__.py b/src/mina/__init__.py similarity index 100% rename from mina/__init__.py rename to src/mina/__init__.py diff --git a/mina/commands/__init__.py b/src/mina/commands/__init__.py similarity index 100% rename from mina/commands/__init__.py rename to src/mina/commands/__init__.py diff --git a/src/mina/commands/build.py b/src/mina/commands/build.py new file mode 100644 index 0000000..554dffe --- /dev/null +++ b/src/mina/commands/build.py @@ -0,0 +1,98 @@ +from __future__ import annotations + +import argparse +import os +import shutil +from typing import TYPE_CHECKING + +from pdm.cli.commands.build import Command as BuildCommand +from pdm.cli.hooks import HookManager +from pdm.exceptions import PdmUsageError +from pdm.project import Project + + +class MinaCommandNamespace: + packages: list[str] + all: bool + sdist: bool + wheel: bool + dest: str + clean: bool + config_setting: list[str] + skip: list[str] | None + + +class MinaBuildCommand(BuildCommand): + """Build specific sub package or all packages.""" + + def add_arguments(self, parser: argparse.ArgumentParser) -> None: + super().add_arguments(parser) + parser.add_argument( + "packages", + nargs="*", + help="Packages to build, which must be defined in pyproject.toml.", + ) + parser.add_argument( + "-a", + "--all", + default=False, + action="store_true", + help="Build all packages.", + ) + + def handle(self, project: Project, options: argparse.Namespace): + if TYPE_CHECKING: + assert isinstance(options, MinaCommandNamespace) + + config_settings = {} + if options.config_setting: + for item in options.config_setting: + name, _, value = item.partition("=") + if name not in config_settings: + config_settings[name] = value + else: + if not isinstance(config_settings[name], list): + config_settings[name] = [config_settings[name]] + config_settings[name].append(value) + + mina_packages = ( + project.pyproject._data.get("tool", {}).get("mina", {}).get("packages", []) + ) + for i in project.root.glob(".mina/*.toml"): + name = i.stem + if name not in mina_packages: + mina_packages.append(name) + + packages = options.packages + + if options.all: + if packages: + raise PdmUsageError("Cannot specify packages and --all at the same time") + packages = mina_packages + + if not packages: + raise PdmUsageError("No package specified") + + errors: list[str] = [ + package for package in packages if package not in mina_packages + ] + if errors: + raise PdmUsageError(f"Package(s) not found: {', '.join(errors)}") + + hooks = HookManager(project, options.skip) + if options.clean: + dest = options.dest + if not os.path.isabs(dest): + dest = project.root.joinpath(dest).as_posix() + shutil.rmtree(dest, ignore_errors=True) + for package in packages: + settings = {**config_settings, "mina-target": package} + self.do_build( + project, + sdist=options.sdist, + wheel=options.wheel, + dest=options.dest, + clean=False, + config_settings=settings, + hooks=hooks, + ) diff --git a/mina/commands/list.py b/src/mina/commands/list.py similarity index 58% rename from mina/commands/list.py rename to src/mina/commands/list.py index d2fcc64..a9c7f38 100644 --- a/mina/commands/list.py +++ b/src/mina/commands/list.py @@ -1,35 +1,27 @@ import sys -from pathlib import Path from argparse import Namespace -try: - import tomllib as tomli # type: ignore -except ImportError: - try: - from pdm.backend._vendor import tomli - except ImportError: - import tomli from pdm.cli.commands.base import BaseCommand from pdm.project.core import Project class MinaPackagesListCommand(BaseCommand): + """List all sub packages in the project.""" + def handle(self, project: Project, options: Namespace): - if not (project.root / "pyproject.toml").exists(): - project.core.ui.echo("No pyproject.toml found.", err=True) - sys.exit(1) - pyproj = tomli.loads( - (project.root / "pyproject.toml").read_text(encoding="utf-8") + mina_packages = ( + project.pyproject._data.get("tool", {}).get("mina", {}).get("packages", []) ) - mina_packages = pyproj.get("tool", {}).get("mina", {}).get("packages", []) for i in project.root.glob(".mina/*.toml"): name = i.name[:-5] if name not in mina_packages: mina_packages.append(name) - + if not mina_packages: project.core.ui.echo( - "No mina packages found, you could add some in pyproject.toml." + "No mina packages found, you could add some in pyproject.toml.", + err=True, + style="error", ) sys.exit(0) project.core.ui.echo( diff --git a/mina/plugin.py b/src/mina/plugin.py similarity index 86% rename from mina/plugin.py rename to src/mina/plugin.py index 78e6d9a..3f64416 100644 --- a/mina/plugin.py +++ b/src/mina/plugin.py @@ -1,14 +1,16 @@ +from __future__ import annotations + from argparse import ArgumentParser, Namespace from typing import TYPE_CHECKING from pdm.cli.commands.base import BaseCommand -from pdm.project.core import Project from mina.commands.build import MinaBuildCommand from mina.commands.list import MinaPackagesListCommand if TYPE_CHECKING: from pdm.core import Core + from pdm.project.core import Project class MinaCommand(BaseCommand): @@ -24,5 +26,5 @@ def handle(self, project: Project, options: Namespace) -> None: self.parser.print_help() -def ensure_pdm(core: "Core"): +def ensure_pdm(core: Core) -> None: core.register_command(MinaCommand, "mina") diff --git a/src/mina_backend/__init__.py b/src/mina_backend/__init__.py new file mode 100644 index 0000000..2961fd2 --- /dev/null +++ b/src/mina_backend/__init__.py @@ -0,0 +1,10 @@ +from pdm.backend import ( + get_requires_for_build_editable as get_requires_for_build_editable, + get_requires_for_build_sdist as get_requires_for_build_sdist, + get_requires_for_build_wheel as get_requires_for_build_wheel, + prepare_metadata_for_build_editable as prepare_metadata_for_build_editable, + prepare_metadata_for_build_wheel as prepare_metadata_for_build_wheel, + build_editable as build_editable, + build_sdist as build_sdist, + build_wheel as build_wheel, +) diff --git a/src/mina_backend/hooks.py b/src/mina_backend/hooks.py new file mode 100644 index 0000000..821bda4 --- /dev/null +++ b/src/mina_backend/hooks.py @@ -0,0 +1,101 @@ +from __future__ import annotations + +import os +import sys +from pathlib import Path +from typing import Any, Mapping, MutableMapping + +from pdm.backend.config import Config +from pdm.backend.hooks import Context + +if sys.version_info >= (3, 11): + import tomllib as tomli +else: + from pdm.backend._vendor import tomli + + +def _get_build_target(context: Context) -> str | None: + tool_mina = context.config.data.get("tool", {}).get("mina", {}) + return ( + context.config_settings.get("mina-target") + or os.environ.get("MINA_BUILD_TARGET") + or tool_mina.get("default-build-target") + ) + + +def _using_override(config: Config, package_conf: dict[str, Any]) -> bool: + if "override" in package_conf: + return package_conf["override"] + return config.data.get("tool", {}).get("mina", {}).get("override-global", False) + + +def _get_mina_packages(context: Context): + mina_packages = ( + context.config.data.get("tool", {}).get("mina", {}).get("packages", []) + ) + for i in context.root.glob(".mina/*.toml"): + name = i.name[:-5] + if name not in mina_packages: + mina_packages.append(name) + return mina_packages + + +def _get_standalone_config(root: Path, pkg: str): + config_file = root / ".mina" / f"{pkg}.toml" + if not config_file.exists(): + return + + return tomli.loads(config_file.read_text()) + + +def _update_config(config: Config, package: str) -> None: + package_conf = _get_standalone_config(config.root, package) + if package_conf is not None: + package_conf.setdefault("includes", []).append(f".mina/{package}.toml") + else: + package_conf = ( + config.data.get("tool", {}) + .get("mina", {}) + .get("packages", {}) + .get(package, None) + ) + if package_conf is None: + raise ValueError(f"No package named '{package}'") + + package_metadata = package_conf.pop("project", {}) + using_override = _using_override(config, package_conf) + + build_config = config.build_config + + # Override build config + build_config.update(package_conf) + + if using_override: + config.data["project"] = package_metadata + else: + deep_merge(config.metadata, package_metadata) + # dependencies are already merged, restore them + config.metadata["dependencies"] = package_metadata.get("dependencies", []) + config.metadata["optional-dependencies"] = package_metadata.get( + "optional-dependencies", {} + ) + + config.validate(config.data, config.root) + + +def deep_merge(source: MutableMapping, target: Mapping) -> Mapping: + for key, value in target.items(): + if key in source and isinstance(value, list): + source[key].extend(value) + elif key in source and isinstance(value, dict): + deep_merge(source[key], value) + else: + source[key] = value + return source + + +def pdm_build_initialize(context: Context) -> None: + mina_target = _get_build_target(context) + if mina_target is None: + return + _update_config(context.config, mina_target)