2 个版本
0.1.1 | 2022 年 12 月 7 日 |
---|---|
0.1.0 | 2022 年 12 月 7 日 |
#67 in #初始化
23KB
275 行
pynit
pynit
加速创建新 Python 项目的流程。它可以使用 git
、虚拟环境(使用 venv
模块)以及创建基本文件夹结构(如果需要)来初始化项目。
用法
Small CLI tool to initialize a python project
Usage: pynit [OPTIONS] <COMMAND>
Commands:
new
init
help Print this message or the help of the given subcommand(s)
Options:
-v, --verbose Output will be more verbose
-c, --complete Initialize with minimal fields for "pyproject.toml"
--git Initialize folder with a git repository
--venv <VENV> Initialize a new virtual environment with given name in initialized directory
--layout <LAYOUT> Define a layout for your project (https://setuptools.pypa.io/en/latest/userguide/package_discovery.html) [possible values: src, flat]
-h, --help Print help information
-V, --version Print version information
有 2 个子命令可用: new
和 init
。每个都有相同的标志(全局定义)。
全局标志
--verbose
添加此标志将使 STDOUT
更加详细。
注意:当前标志没有任何作用,因为日志记录尚未实现。
-c/--complete
--complete
允许您控制初始化 pyproject.toml
期间将询问多少问题。默认情况下,仅询问必需字段: build-sytem
部分、project.name
和 project.version
。
--git
初始化 Git 仓库
--venv
为您的 Python 项目添加具有给定 name
的虚拟环境。
--layout
向您的项目添加默认的流行文件夹结构。有两个选项: flat
和 src
。
更多信息,请参阅 此 setuptools 部分。
new
new
的行为类似于 cargo new
。它接受一个参数,即项目名称。项目名称将是文件夹名称,并在询问创建基本 pyproject.toml
时用作默认值。
在创建项目之前,目录必须不存在。
示例
$ pynit --git --venv .env --layout flat new my_project
$ exa -a --tree --level=2 my_project
my_project
├── .env
│ ├── ...
├── .git
│ ├── ...
├── .gitignore
├── my_project
│ └── __init__.py
└── pyproject.toml
init
与 new
类似,init
执行相同的功能。不同之处在于它将初始化当前目录。
注意:如果存在 .gitignore
和/或 pyproject.toml
,则将截断它们。
依赖关系
~4–14MB
~148K SLoC