diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..3392a162b7322c0b7f680181dbe64d4d95827041 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ +[project] +name = "ulang" +authors = [ + {name = "吴烜", email = "mulanrevive@gmail.com"}, +] +description = "木兰编程语言重现" +readme = "README.md" +requires-python = ">=3.7,<3.10" +license = {text = "GNU GPLv3"} +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License (GPL)", + "Operating System :: OS Independent", +] +dependencies = [ + "rply-ulang", + "codegen", +] +dynamic = ["version"] + +[tool.setuptools] +packages = ["木兰"] + +[project.scripts] +"木兰" = "木兰.中:中" + +[project.urls] +Homepage = "https://www.oschina.net/p/mulan-rework" +Source = "https://gitee.com/MulanRevive/mulan-rework" +Changelog = "https://gitee.com/MulanRevive/mulan-rework#版本历史介绍" + +[tool.setuptools.dynamic] +# 在`木兰/__init__.py`中修改版本号即可 +version = {attr = "木兰.__版本__"} + +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 834a4a61f80731d28b4ed361cf498f0075f2c0ca..0000000000000000000000000000000000000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -import setuptools - -with open("README.md", encoding="utf-8", mode="r") as readme: - longDescription = readme.read() - -setuptools.setup( - name="ulang", - # 木兰/__init__.py 中保持一致 - version="0.1.5", - license="GNU GPLv3", - author="吴烜", - author_email="mulanrevive@gmail.com", - entry_points = { - "console_scripts": ['木兰 = 木兰.中:中'] - }, - description="木兰编程语言重现", - long_description=longDescription, - long_description_content_type="text/markdown", - url="https://www.oschina.net/p/mulan-rework", - project_urls={ - "Source": "https://gitee.com/MulanRevive/mulan-rework", - "Changelog": "https://gitee.com/MulanRevive/mulan-rework#版本历史介绍", - }, - packages=setuptools.find_packages(), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License (GPL)", - "Operating System :: OS Independent", - ], - install_requires=[ - 'rply-ulang', - 'codegen', - ], - python_requires=">=3.7,<3.10", -) diff --git "a/\346\226\207\346\241\243/\345\212\237\350\203\275/Python\347\211\210\346\234\254\346\224\257\346\214\201\346\203\205\345\206\265/\351\200\202\351\205\215\346\226\260\347\211\210\346\234\254\346\214\207\345\215\227.md" "b/\346\226\207\346\241\243/\345\212\237\350\203\275/Python\347\211\210\346\234\254\346\224\257\346\214\201\346\203\205\345\206\265/\351\200\202\351\205\215\346\226\260\347\211\210\346\234\254\346\214\207\345\215\227.md" index b182ddecf4512bfb1b08818ebda27a9d73f935ad..038222d01bcc4e545d960cb5ed872d5d6c733c69 100644 --- "a/\346\226\207\346\241\243/\345\212\237\350\203\275/Python\347\211\210\346\234\254\346\224\257\346\214\201\346\203\205\345\206\265/\351\200\202\351\205\215\346\226\260\347\211\210\346\234\254\346\214\207\345\215\227.md" +++ "b/\346\226\207\346\241\243/\345\212\237\350\203\275/Python\347\211\210\346\234\254\346\224\257\346\214\201\346\203\205\345\206\265/\351\200\202\351\205\215\346\226\260\347\211\210\346\234\254\346\214\207\345\215\227.md" @@ -14,12 +14,12 @@ pip install -e . ## 适配新版本 -### 更改 `setup.py` +### 更改兼容 Python 版本 -在`setup.py`中,将`python_requires`字段的值修改为新版本范围,例如: +在`pyproject.toml`中,将`python_requires`字段的值修改为新版本范围,例如: ```python -python_requires='>=3.7, <3.10', +python_requires='>=3.7,<3.10', ``` ### 运行测试 @@ -87,6 +87,6 @@ OK 在当前目录下,参考`py3.8支持.md`记录适配新版本的过程,包括以上数个方面的更改。 -在根目录下的`setup.py`及相关文件中,更新本项目的版本号。 +在`木兰/__init__.py`中,更新本项目的版本号。 在`CHANGELOG.md`中,记录本次更新的内容。 diff --git "a/\346\226\207\346\241\243/\345\274\200\345\217\221\346\227\245\345\277\227.md" "b/\346\226\207\346\241\243/\345\274\200\345\217\221\346\227\245\345\277\227.md" index 744d333072a2ce519869c6837c20b2f59711477e..128923c6b8bec688f696f3240c817ec1937cb428 100644 --- "a/\346\226\207\346\241\243/\345\274\200\345\217\221\346\227\245\345\277\227.md" +++ "b/\346\226\207\346\241\243/\345\274\200\345\217\221\346\227\245\345\277\227.md" @@ -2,21 +2,22 @@ ### 打包 -``` -python3 setup.py sdist bdist_wheel +```shell +python3 -m pip install --upgrade build +python3 -m build ``` ### 测试平台 上传 -``` +```shell python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/* ``` 安装 -``` +```shell python3 -m pip install -U --index-url https://test.pypi.org/simple/ ulang ``` @@ -24,13 +25,13 @@ python3 -m pip install -U --index-url https://test.pypi.org/simple/ ulang 上传 -``` +```shell python3 -m twine upload --repository pypi dist/* ``` 安装 -``` +```shell python3 -m pip install --index-url https://pypi.org/simple/ ulang ``` @@ -60,14 +61,14 @@ pip install <包名>==<版本号> 比如字符串插值为何使用 ast.Mod,可用木兰代码: -``` +```javascript a = 3 print("`a`b`a`") ``` 运行转换为 python 代码,可见 % 运算符: -``` +```terminal $ python3 -m ulang --dump-py test/str.ul import sys from math import * @@ -78,7 +79,7 @@ print('%sb%s' % (str(a), str(a))) ## 常见错误 -``` +```plaintext File "/Users/xuanwu/work/木兰/prototype/分析器.py", line 120, in 语法分析器 @分析器母机.production('操作符: 名词_操作符 二元操作符 操作数 块') File "/opt/miniconda3/lib/python3.7/site-packages/rply/parsergenerator.py", line 77, in production @@ -96,7 +97,7 @@ TypeError: expected some sort of operator, but got <_ast.And object at 0x105a065 运行测试用例: -``` +```terminal $ pytest tests ================================================================= test session starts ================================================================== platform darwin -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 @@ -141,7 +142,7 @@ VSC 下终端使用的 python 无法转为与系统终端相同的 conda 环境 fork 分支与原库同步: -``` +```shell git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git git fetch upstream @@ -151,7 +152,7 @@ git merge upstream/master 同时push到gitee和github两个库: -``` +```shell git remote set-url --add --push origin https://gitee.com/MulanRevive/mulan-rework.git git remote set-url --add --push origin https://github.com/MulanRevive/mulan-rework.git ``` @@ -188,12 +189,12 @@ Stopping `mongodb-community`... (might take a while) ### 代码统计 -``` -$ scc --by-file --count-as ul:ruby +```shell +scc --by-file --count-as ul:ruby ``` ### RST 文件验证 -``` +```shell python -m readme_renderer README.rst -o /tmp/README.html -``` \ No newline at end of file +``` diff --git "a/\346\234\250\345\205\260/__init__.py" "b/\346\234\250\345\205\260/__init__.py" index 5ac2116aa7a75896684fe40dde85518fc0e842ef..563a9f5cfc8d2dc649655d43a0248593ae30b496 100644 --- "a/\346\234\250\345\205\260/__init__.py" +++ "b/\346\234\250\345\205\260/__init__.py" @@ -1 +1 @@ -__版本__ = '0.1.4' +__版本__ = '0.1.5'