Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhengda committed May 7, 2024
1 parent 8616101 commit e66ba90
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 89 deletions.
11 changes: 11 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# * 这段代码是用于配置 bumpversion 工具的配置文件。其中:
# [bumpversion] 部分指定了版本升级的一般设置。
# current_version 指定了当前项目的版本号。
# commit 和 tag 都设置为 True,表示在升级版本时,bumpversion 应该在版本控制中创建一个提交和标签。
# [bumpversion:file:python_template/__init__.py] 部分指定了要在哪个文件中进行搜索和替换。
# search 指定了要在文件中搜索的模式。
# replace 指定了要用来替换搜索到的模式的内容。
# [bumpversion:file:pyproject.toml] 部分类似地指定了要在哪个文件中进行搜索和替换。


# 当使用这个配置运行 bumpversion 时,它将根据提供的模式更新指定文件中的版本号。
[bumpversion]
current_version = 0.1.0
commit = True
Expand Down
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# * 这个代码片段展示了一个.gitattributes文件的内容。.gitattributes文件用于指定特定文件或路径的属性,比如文本处理方式和换行符类型。

# 在这个例子中,文件指定了以下规则:
# examples/* linguist-documentation:将examples目录下的所有文件标记为linguist-documentation,这可能会影响GitHub对这些文件的语言识别。
# docs/* linguist-documentation:将docs目录下的所有文件标记为linguist-documentation。
# *.ipynb linguist-documentation:将所有.ipynb文件标记为linguist-documentation。
# Makefile linguist-documentation:将Makefile文件标记为linguist-documentation。


# 最后一行* text=auto eol=lf指定了默认规则,即将所有文件视为文本文件(text=auto),并使用LF作为换行符(eol=lf)。

examples/* linguist-documentation
docs/* linguist-documentation
*.ipynb linguist-documentation
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 这是一个.gitignore文件的示例,用于指定Git版本控制系统忽略的文件和目录。
# 在这个示例中,文件中列出了一些常见的不需要纳入版本控制的文件和目录,比如Python字节码文件、构建产物、日志文件、临时文件、缓存文件、数据库文件、虚拟环境、IDE和工具生成的文件等。
# 通过这个文件,可以确保这些文件和目录不会被意外提交到版本库中。

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
63 changes: 30 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
# Contributing
# 贡献

If you want to contribute to this repository here are some helpful guidelines.
如果您想要为这个仓库做贡献,以下是一些有用的指南。

## Reporting bugs, feature requests, etc.
简体中文 | [English](CONTRIBUTING_EN.md)

To report bugs, request new features or similar, please open an issue on the Github
repository.
## 报告 bug、提出新功能等

A good bug report includes:
要报告 bug、请求新功能或类似的事情,请在 Github 仓库上开启一个 issue。

- Expected behavior
- Actual behavior
- Steps to reproduce (preferably as minimal as possible)
- Possibly any output from the browser console (typically available via Ctrl + Shift + J or via F12).
一个好的 bug 报告包括:

## Minor changes, typos etc.
- 期望的行为
- 实际的行为
- 重现步骤(最好尽可能简洁)
- 可能的浏览器控制台输出(通常可以通过 Ctrl + Shift + J 或 F12 获得)

Minor changes can be contributed by navigating to the relevant files on the Github repository,
and clicking the "edit file" icon. By following the instructions on the page you should be able to
create a pull-request proposing your changes. A repository maintainer will then review your changes,
and either merge them, propose some modifications to your changes, or reject them (with a reason for
the rejection).
## 小改动、错别字等

## Setting up a development environment
可以通过导航到 Github 仓库上相关文件,并点击“编辑文件”图标来贡献小改动。按照页面上的说明,您应该能够创建一个拉取请求(pull-request)来提议您的更改。
仓库维护者将会审查您的更改,并且要么合并它们,要么提出一些修改意见,或者拒绝它们(并附上拒绝的原因)。

If you want to help resolve an issue by making some changes that are larger than that covered by the above paragraph, it is recommended that you:
## 设置开发环境

- Fork the repository on Github
- Clone your fork to your computer
- Run the following commands inside the cloned repository:
- `make develop` - This will install the package in development
mode
- Validate the install by running the tests:
- `make lint` - This command will run any static analysis tools/lints
- `make test` - This command will run the unit tests
- `make check` - This command will run any other checks
如果您想通过进行一些大于上述段落所涵盖的更改来帮助解决问题,建议您:

Once you have such a development setup, you should:
- 在 Github 上 fork 该仓库
- 将您的 fork 克隆到您的计算机上
- 在克隆的仓库内运行以下命令:
- `make develop` - 这将以开发模式安装该包
- 通过运行测试来验证安装:
- `make lint` - 这个命令将运行任何静态分析工具/检查
- `make test` - 这个命令将运行单元测试
- `make check` - 这个命令将运行任何其他检查

- Make the changes you consider necessary
- Run the tests to ensure that your changes does not break anything
- If you add new code, preferably write one or more tests for checking that your code works as expected.
- Commit your changes and publish the branch to your github repo.
- Open a pull-request (PR) back to the main repo on Github.
一旦您拥有这样的开发设置,您应该:

- 进行您认为必要的更改
- 运行测试以确保您的更改不会破坏任何东西
- 如果您添加了新代码,最好编写一个或多个测试来检查您的代码是否按预期工作
- 提交您的更改并将分支发布到您的 Github 仓库
- 在 Github 上向主仓库开启一个拉取请求(PR)。
45 changes: 45 additions & 0 deletions CONTRIBUTING_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Contributing

If you want to contribute to this repository here are some helpful guidelines.

## Reporting bugs, feature requests, etc.

To report bugs, request new features or similar, please open an issue on the Github
repository.

A good bug report includes:

- Expected behavior
- Actual behavior
- Steps to reproduce (preferably as minimal as possible)
- Possibly any output from the browser console (typically available via Ctrl + Shift + J or via F12).

## Minor changes, typos etc.

Minor changes can be contributed by navigating to the relevant files on the Github repository,
and clicking the "edit file" icon. By following the instructions on the page you should be able to
create a pull-request proposing your changes. A repository maintainer will then review your changes,
and either merge them, propose some modifications to your changes, or reject them (with a reason for
the rejection).

## Setting up a development environment

If you want to help resolve an issue by making some changes that are larger than that covered by the above paragraph, it is recommended that you:

- Fork the repository on Github
- Clone your fork to your computer
- Run the following commands inside the cloned repository:
- `make develop` - This will install the package in development
mode
- Validate the install by running the tests:
- `make lint` - This command will run any static analysis tools/lints
- `make test` - This command will run the unit tests
- `make check` - This command will run any other checks

Once you have such a development setup, you should:

- Make the changes you consider necessary
- Run the tests to ensure that your changes does not break anything
- If you add new code, preferably write one or more tests for checking that your code works as expected.
- Commit your changes and publish the branch to your github repo.
- Open a pull-request (PR) back to the main repo on Github.
17 changes: 17 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# MANIFEST.in 文件的作用是告诉 Python 的打包工具(如 setuptools)在构建分发包时应该包含哪些文件,以及应该排除哪些文件。通常,这个文件会列出一系列的包含(include)和排除(exclude)规则,告诉打包工具如何处理项目中的各种文件。

# 具体来说,MANIFEST.in 文件的作用包括:

# 1. **指定包含的文件和目录**:通过指定 `include` 和 `graft` 指令,可以告诉打包工具应该包含哪些文件和目录。

# 2. **指定排除的文件和目录**:通过指定 `exclude` 和 `prune` 指令,可以告诉打包工具应该排除哪些文件和目录,不包含在分发包中。

# 3. **全局排除规则**:可以使用 `global-exclude` 指令指定一些全局的排除规则,告诉打包工具哪些文件应该在所有目录中排除。

# 4. **指定特定文件的包含和排除**:可以使用具体的文件路径或者通配符来指定特定文件的包含和排除规则。

# 5. **指定额外的元数据文件**:除了 setup.py 文件中的元数据,还可以通过 MANIFEST.in 文件指定一些额外的元数据文件,如 LICENSE、README 等。

总的来说,MANIFEST.in 文件提供了一种灵活的方式,让开发者能够控制分发包中包含哪些文件,从而确保分发包的内容符合预期。
graft python_template

include LICENSE
include README.md
include README_EN.md

prune docs
prune .vscode
Expand All @@ -12,6 +28,7 @@ prune .ruff_cache
prune .mypy_cache

exclude CONTRIBUTING.md
exclude CONTRIBUTING_EN.md
exclude .bumpversion.cfg
exclude pyproject.toml
exclude Makefile
Expand Down
52 changes: 30 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
# * 这是一个Makefile文件,用于定义各种任务和命令。文件中包含了一些常见的任务,例如构建(build)、代码检查(lints)、测试(tests)、文档生成(docs)、版本管理(version)、分发(dist)和清理(clean)等。

# * 每个任务都有一个或多个命令,以及对应的注释说明。例如,develop任务用于安装依赖并构建库,lint任务用于运行Python代码检查工具,test任务用于运行Python测试等。

# * 文件还定义了一些伪目标(.PHONY),以及一些带有别名的任务,这些别名可以简化用户在命令行中输入的操作。

# * 最后,文件还定义了一个默认目标(.DEFAULT_GOAL),用于在没有指定具体任务时显示帮助信息。帮助信息通过解析Makefile文件中的注释来生成,以便用户了解可以执行的任务及其说明。

#########
# BUILD #
#########
.PHONY: develop build install

develop: ## install dependencies and build library
develop: ## install dependencies and build library / 安装依赖并构建ython库
python -m pip install -e .[develop]

build: ## build the python library
build: ## build the python library / 构建Python库
python setup.py build build_ext --inplace

install: ## install library
install: ## install library / 安装ython库
python -m pip install .

#########
# LINTS #
#########
.PHONY: lint lints fix format

lint: ## run python linter with ruff
lint: ## run python linter with ruff / 使用ruff运行Python代码检查工具
python -m isort python_template setup.py --check
python -m ruff python_template setup.py

# Alias
lints: lint

fix: ## fix python formatting with ruff
fix: ## fix python formatting with ruff / 使用ruff修复Python格式
python -m isort python_template setup.py
python -m ruff format python_template setup.py

Expand All @@ -36,29 +44,29 @@ format: fix
################
.PHONY: check-manifest semgrep checks check annotate

check-manifest: ## check python sdist manifest with check-manifest
check-manifest: ## check python sdist manifest with check-manifest / 使用check-manifest检查Python sdist清单
check-manifest -v

semgrep: ## check for possible errors with semgrep
semgrep: ## check for possible errors with semgrep / 使用semgrep检查可能的错误
semgrep ci --config auto

checks: check-manifest semgrep

# Alias
check: checks

annotate: ## run python type annotation checks with mypy
annotate: ## run python type annotation checks with mypy / 使用mypy运行Python类型注解检查
python -m mypy ./python_template

#########
# TESTS #
#########
.PHONY: test coverage tests

test: ## run python tests
test: ## run python tests / 运行Python测试
python -m pytest -v python_template/tests --junitxml=junit.xml

coverage: ## run tests and collect test coverage
coverage: ## run tests and collect test coverage / 运行测试并收集测试覆盖率
python -m pytest -v python_template/tests --junitxml=junit.xml --cov=python_template --cov-branch --cov-fail-under=75 --cov-report term-missing --cov-report xml

# Alias
Expand All @@ -69,53 +77,53 @@ tests: test
########
.PHONY: docs show-docs

docs: ## build html documentation
docs: ## build html documentation / 构建HTML文档
make -C ./docs html

show-docs: ## show docs with running webserver
show-docs: ## show docs with running webserver / 通过运行web服务器显示文档
cd ./docs/_build/html/ && PYTHONBUFFERED=1 python -m http.server | sec -u "s/0\.0\.0\.0/$$(hostname)/g"

###########
# VERSION #
###########
.PHONY: show-version patch minor major

show-version: ## show current library version
show-version: ## show current library version / 显示当前库版本
bump2version --dry-run --allow-dirty setup.py --list | grep current | awk -F= '{print $2}'

patch: ## bump a patch version
patch: ## bump a patch version / 增加一个补丁版本
bump2version patch

minor: ## bump a minor version
minor: ## bump a minor version / 增加一个次要版本
bump2version minor

major: ## bump a major version
major: ## bump a major version / 增加一个主要版本
bump2version major

########
# DIST #
########
.PHONY: dist dist-build dist-sdist dist-local-wheel publish

dist-build: # build python dists
dist-build: # build python dists / 构建Python分发包
python -m build -w -s

dist-check: ## run python dist checker with twine
dist-check: ## run python dist checker with twine / 使用twine运行Python分发检查
python -m twine check dist/*

dist: clean build dist-build dist-check ## build all dists
dist: clean build dist-build dist-check ## build all dists / 清理、构建和运行分发检查的任务

publish: dist # publish python assets
publish: dist # publish python assets / 发布Python资源

#########
# CLEAN #
#########
.PHONY: deep-clean clean

deep-clean: ## clean everything from the repository
deep-clean: ## clean everything from the repository / 清理仓库中的所有内容
git clean -fdx

clean: ## clean the repository
clean: ## clean the repository / 清理仓库
rm -rf .coverage coverage cover htmlcov logs build dist *.egg-info

############################################################################################
Expand Down
48 changes: 41 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
# Python Project Template
# Python 项目模板

A pure-python project template
一个纯粹的 Python 项目模板

[![Build Status](https://github.com/python-project-templates/python/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/python-project-templates/python/actions?query=workflow%3A%22Build+Status%22)
[![codecov](https://codecov.io/gh/python-project-templates/python/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/python)
[![License](https://img.shields.io/github/license/python-project-templates/python)](https://github.com/python-project-templates/python)
[![PyPI](https://img.shields.io/pypi/v/python_template.svg)](https://pypi.python.org/pypi/python_template)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/python-project-templates/python/main?urlpath=lab)
[![构建状态](https://github.com/chenzhengda/python-project-templates/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/chenzhengda/python-project-templates/actions?query=workflow%3A%22Build+Status%22)
[![codecov](https://codecov.io/gh/python-project-templates/python/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/python)
[![许可证](https://img.shields.io/github/license/python-project-templates/python)](https://github.com/chenzhengda/python-project-templates)
[![PyPI](https://img.shields.io/pypi/v/python_template.svg)](https://pypi.python.org/pypi/python_template)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/python-project-templates/python/main?urlpath=lab)

简体中文 | [English](README_EN.md)

## 项目介绍
本项目是一个简单的 Python 项目模板,旨在帮助开发者快速开始一个新的 Python 项目。

## 安装
您可以通过 pip 安装本项目:
```
pip install python_template
```
## 使用方法
安装完成后,您可以在 Python 中导入并使用本项目:
```python
import python_template

# 使用项目的功能
```
## 贡献
我们欢迎任何形式的贡献,包括但不限于:
- 报告 bug
- 提交修复
- 添加新功能
- 改进文档

如果您有兴趣参与项目,请遵循我们的 [贡献指南](CONTRIBUTING.md)

## 许可证
本项目遵循 [许可证链接](https://github.com/chenzhengda/python-project-templates)

## 联系方式
如有任何问题,请通过以下方式联系我们:
- GitHub Issues: [https://github.com/chenzhengda/python-project-templates/issues](https://github.com/chenzhengda/python-project-templates/issues)
```
9 changes: 9 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Python Project Template

A pure-python project template

[![Build Status](https://github.com/python-project-templates/python/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/python-project-templates/python/actions?query=workflow%3A%22Build+Status%22)
[![codecov](https://codecov.io/gh/python-project-templates/python/branch/main/graph/badge.svg)](https://codecov.io/gh/python-project-templates/python)
[![License](https://img.shields.io/github/license/python-project-templates/python)](https://github.com/python-project-templates/python)
[![PyPI](https://img.shields.io/pypi/v/python_template.svg)](https://pypi.python.org/pypi/python_template)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/python-project-templates/python/main?urlpath=lab)
Loading

0 comments on commit e66ba90

Please sign in to comment.