lib-not-dr/README.md

106 lines
2.3 KiB
Markdown
Raw Normal View History

2023-06-10 00:23:46 +08:00
# lib-not-dr
2023-06-24 21:01:09 +08:00
A python lib came from [Difficult Rocket](https://github.com/shenjackyuanjie/Difficult-Rocket) development
一个在 [Difficult Rocket](https://github.com/shenjackyuanjie/Difficult-Rocket) 开发中 分离出来的 python 库
## Information/信息
2023-12-15 13:36:51 +08:00
- Version / 版本: 0.3.11
2023-11-18 23:42:10 +08:00
- Author / 作者: shenjackyuanjie <3695888@qq.com>
2023-06-24 21:01:09 +08:00
2023-12-09 16:09:28 +08:00
[shenjackyuanjie](https://github.com/shenjackyuanjie)
2023-12-13 12:02:59 +08:00
> [更新日志|Change Log](docs/change_logs)
2023-06-24 21:01:09 +08:00
### License/许可证
[MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/)
## 安装/Install
```bash title="install.sh"
2023-06-24 21:01:09 +08:00
pip install lib-not-dr
2023-11-25 18:06:29 +08:00
pip install lib-not-dr[nuitka]
# install with nuitka support
# 安装支持 nuitka 的版本
2023-06-24 21:01:09 +08:00
```
## 使用/Usage
### Logger
> WIP
2023-12-03 19:35:41 +08:00
> 等待 0.4.0
```python title="logger.py"
2023-12-03 22:05:14 +08:00
from lib_not_dr import loggers
2023-12-03 22:05:14 +08:00
logger = loggers.get_logger("test")
logger.fine('Hello World!')
logger.debug('Hello World!')
logger.trace('Hello tracing!')
logger.info('Hello World!') # info!
logger.warn('warnnnnnnn')
logger.error('Hello World!')
logger.fatal('good bye world')
# tag
logger.info('this message if from tag', tag='test')
logger.debug('this debug log if from admin', tag='admin')
# end
logger.debug('and this message ends with none', end=' ')
logger.trace('so this message will be in the same line', tag='same line!')
```
### Nuitka pyproject paser
2023-11-26 15:27:15 +08:00
> `pyproject.toml` 内的配置
2023-12-09 16:09:28 +08:00
>
2023-11-26 15:27:15 +08:00
> Config in `pyproject.toml`
2023-12-03 22:08:04 +08:00
前往 [example/nuitka](/example/nuitka) 查看更多例子
```toml title="pyproject.toml"
2023-12-03 17:24:31 +08:00
[tool.lndl.nuitka.cli]
main = "main.py"
# --main=main.py
2023-11-25 16:21:01 +08:00
standalone = true
onefile = false
2023-12-03 19:35:41 +08:00
[tool.lndl.nuitka]
script = "xxx.py"
2023-11-25 16:21:01 +08:00
```
2023-11-26 15:27:15 +08:00
> 通过 `lndl_nuitka` 命令行工具使用
2023-12-09 16:09:28 +08:00
>
2023-11-26 15:27:15 +08:00
> Use with `lndl_nuitka` command line tool
> 建议使用 `pip install lib-not-dr[nuitka]` 安装 lib-not-dr
2023-11-25 16:21:01 +08:00
```bash
2023-11-25 16:50:51 +08:00
lndl_nuitka .
lndl_nuitka . -- --onefile
2023-11-25 16:21:01 +08:00
# add --onefile to nuitka
2023-11-25 16:50:51 +08:00
lndl_nuitka . -y
# run without confirmation
lndl_nuitka . -n
# do not run
2023-12-09 16:09:28 +08:00
```
2023-11-25 19:02:11 +08:00
2023-11-26 15:27:15 +08:00
> 通过 `lib_not_dr.nuitka.reader` 模块使用
2023-12-09 16:09:28 +08:00
>
2023-11-26 15:27:15 +08:00
> Use with `lib_not_dr.nuitka.reader`
2023-11-25 19:02:11 +08:00
```python
from tomli import loads
from lib_not_dr.nuitka.reader import main, run_nuitka
pyproject_toml = loads(open("pyproject.toml", "r").read())
nuitka_config = pyproject_toml["tool"]["lndl"]["nuitka"]
nuitka_config["product_version"] = "0.1.0"
command = main(nuitka_config)
run_nuitka(command)
```