Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyElaina committed Dec 25, 2022
1 parent 11fab87 commit a4b87b0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
28 changes: 19 additions & 9 deletions mina/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
from pathlib import Path
from typing import Any, Dict, Mapping, Optional

from pdm.pep517._vendor import tomli
try:
import tomllib as tomli # type: ignore
except ImportError:
try:
from pdm.pep517._vendor import tomli
except ImportError:
import tomli

from pdm.pep517._vendor.packaging.requirements import Requirement
from pdm.pep517.api import _prepare_metadata
from pdm.pep517.api import get_requires_for_build_sdist as get_requires_for_build_sdist
from pdm.pep517.api import get_requires_for_build_wheel as get_requires_for_build_wheel
from pdm.pep517.api import (
prepare_metadata_for_build_wheel as prepare_metadata_for_build_wheel,
)
from pdm.pep517.api import \
get_requires_for_build_sdist as get_requires_for_build_sdist
from pdm.pep517.api import \
get_requires_for_build_wheel as get_requires_for_build_wheel
from pdm.pep517.api import \
prepare_metadata_for_build_wheel as prepare_metadata_for_build_wheel
from pdm.pep517.base import Builder
from pdm.pep517.editable import EditableBuilder
from pdm.pep517.metadata import Config, Metadata
Expand All @@ -23,7 +31,7 @@
@functools.lru_cache(None)
def _get_config_root():
cwd = Path.cwd()
return tomli.loads((cwd / "pyproject.toml").read_text(encoding='utf-8'))
return tomli.loads((cwd / "pyproject.toml").read_text(encoding="utf-8"))


@functools.lru_cache(None)
Expand Down Expand Up @@ -103,7 +111,9 @@ def _patch_dep(_meta: Metadata, pkg_project: dict[str, Any]):
if req.name is None:
raise ValueError(f"'{dep}' is not a valid requirement")
if req.name not in workspace_deps:
raise ValueError(f"{req.name} is not defined in project requirements")
raise ValueError(
f"{req.name} is not defined in project requirements"
)
group_deps.append(str(workspace_deps[req.name]))
optional_dependencies[group] = group_deps

Expand All @@ -116,7 +126,7 @@ def _patch_pdm_metadata(package: str):
cwd = Path.cwd()
_meta = Builder(cwd).meta

config = tomli.loads((cwd / "pyproject.toml").read_text(encoding='utf-8'))
config = tomli.loads((cwd / "pyproject.toml").read_text(encoding="utf-8"))

package_conf = (
config.get("tool", {}).get("mina", {}).get("packages", {}).get(package, None)
Expand Down
12 changes: 10 additions & 2 deletions mina/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
import sys
from pathlib import Path

import tomli
try:
import tomllib as tomli # type: ignore
except ImportError:
try:
from pdm.pep517._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
Expand Down Expand Up @@ -120,7 +126,9 @@ 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'))
pyproj = tomli.loads(
(project.root / "pyproject.toml").read_text(encoding="utf-8")
)
mina_packages = pyproj.get("tool", {}).get("mina", {}).get("packages", [])
packages = options.packages

Expand Down
12 changes: 10 additions & 2 deletions mina/commands/list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import sys
from argparse import Namespace

import tomli
try:
import tomllib as tomli # type: ignore
except ImportError:
try:
from pdm.pep517._vendor import tomli
except ImportError:
import tomli
from pdm.cli.commands.base import BaseCommand
from pdm.project.core import Project

Expand All @@ -11,7 +17,9 @@ 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'))
pyproj = tomli.loads(
(project.root / "pyproject.toml").read_text(encoding="utf-8")
)
mina_packages = pyproj.get("tool", {}).get("mina", {}).get("packages", [])
if not mina_packages:
project.core.ui.echo(
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies = [
"pdm-pep517>=1.0.1",
"mina-build>=0.2.1",
"twine>=4.0.0",
"tomli>=1.1.0; python_version < \"3.11\""
]
requires-python = ">=3.9"
readme = "README.md"
Expand Down Expand Up @@ -49,13 +50,14 @@ raw-dependencies = []

[tool.mina.packages."backend".project]
name = "mina-build"
version = "0.2.8"
version = "0.2.9"
description = "build backend for Mina Package Structure"
authors = [
{name = "GreyElaina", email = "[email protected]"},
]
dependencies = [
"pdm-pep517",
"tomli"
]
requires-python = ">=3.9"
readme = "README.build.md"
Expand All @@ -72,10 +74,11 @@ excludes = [

[tool.mina.packages."cli-pdm".project]
name = "pdm-mina"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"pdm",
"mina-build",
"tomli"
]
requires-python = ">=3.9"
readme = "README.md"
Expand Down

0 comments on commit a4b87b0

Please sign in to comment.