Skip to content

Commit

Permalink
feat: rewrite the backend to use the build hook (#19)
Browse files Browse the repository at this point in the history
* feat: rewrite the backend to use the build hook

Signed-off-by: Frost Ming <[email protected]>

* fix: remove debug print

Signed-off-by: Frost Ming <[email protected]>

* fix: overriding deps

Signed-off-by: Frost Ming <[email protected]>

* chore: some personal perferences

* misc: narrow word {default-target => default-build-target}

* feat: deprecated workspace dep ref, wip

* fix: missing skip attr

* feat: use editable ref between packages

* chore: donot patch deps

---------

Signed-off-by: Frost Ming <[email protected]>
Co-authored-by: Elaina <[email protected]>
  • Loading branch information
frostming and GreyElaina authored Feb 4, 2024
1 parent 78f416d commit 2a7b3ba
Show file tree
Hide file tree
Showing 16 changed files with 370 additions and 863 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion .pdm-python

This file was deleted.

8 changes: 0 additions & 8 deletions .vscode/settings.json

This file was deleted.

29 changes: 20 additions & 9 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <package>` 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

Expand All @@ -26,19 +26,34 @@ 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`:

```toml
[build-system]
requires = ["mina-build>=0.2.5"]
build-backend = "mina.backend"
build-backend = "pdm.backend"
```

### Edit pyproject.toml
Expand Down Expand Up @@ -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 = ["..."]
Expand Down
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,47 @@
`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 <package>` 指令,
但你也可以通过环境变量 `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` 中配置以下项:

```toml
[build-system]
requires = ["mina-build>=0.2.5"]
build-backend = "mina.backend"
build-backend = "pdm.backend"
```

### 编辑 pyproject.toml
Expand Down Expand Up @@ -80,10 +95,6 @@ includes = [
]
# 相当于 tool.pdm.includes, 如果不填我不知道会发生什么, 可能就是普通的情况 -- 打包 name 所指向的模块.

# raw-dependencies = [...]
# 这一配置项会在处理完 project.dependencies 后直接排入依赖声明.
# 你可以用这个特性来声明分包之间的依赖.

# override = false

[tool.mina.packages."core".project]
Expand Down Expand Up @@ -127,4 +138,4 @@ override = true # 仅在 core 分包启用该特性

# 开源协议

本项目使用 MIT 协议开源.
本项目使用 MIT 协议开源.
Loading

0 comments on commit 2a7b3ba

Please sign in to comment.