podao


Namepodao JSON
Version 0.8.2 PyPI version JSON
download
home_page
SummaryA python project environment build tool.
upload_time2022-12-10 13:46:55
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License
keywords environment dependency workflow
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 朴刀 podao
一把朴刀开局。
朴刀是一个 Python 项目搭建脚手架,组合使用 pyenv、venv 和 pip 等工具搭建虚拟环境、分组依赖包。

Podao is an python project environment setup tool, it combines pyenv, venv, pip to ease the work to build an isolated environment for python project.




![朴刀](https://github.com/imlzg/image/blob/6c2dcdd72ddbfb4174733e8dae6f3043e472788f/podao.jpg)


朴刀是一种刀身窄长、刀柄较短的刀,装上“杆棒”后变为枪,名为朴刀枪,以“搠、刺”为主。

朴刀在《水浒传》里广为人知,印象里朴刀都很长,这是错的;正确的定义是:朴刀短柄,柄中空,是单手持握的短兵器,特点在于刀柄中空,旋入一根哨棒就可以当做长兵器使用,故尔武松等人都习惯手持哨棒,腰配朴刀,如此两件兵器可以在需要时合二为一,就像 pyenv 和 venv 一样。

如:“卢俊义取出朴刀,装在杆棒上,三个了丫儿扣牢了,赶著车子奔梁山泊路上来”。




### 优势 advantage
-使用 pyenv、venv 和 pip 搭建项目,零学习成本;
-使用文件夹名作为 shell session 提示符,无随机字符、好看、有意义;
-使用 pyproject.toml 和 requirements.txt 文件描述项目,不造轮子、零侵入;




### 局限 weakness
podao 只解决虚拟环境的搭建和依赖包的分组的问题,更具体的项目配置需要手动更改 pyproject.toml 文件。



### pyenv
pyenv 用于管理项目环境的 python 版本,要使用 podao 需事先安装 pyenv,参考[官网](https://github.com/pyenv/pyenv)。

#### pyenv installation
pyenv 的安装配置稍显复杂,安装过程可分 3 步:
1. 安装 pyenv 依赖,包括 `git`,[wiki](https://github.com/pyenv/pyenv/wiki#suggested-build-environment)
2. 安装 pyenv,[wiki](https://github.com/pyenv/pyenv-installer)
3. 配置 pyenv 环境,[wiki](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)

有人将安装过程封装成了[安装脚本](https://github.com/zaemiel/ubuntu-pyenv-installer),目前只有 Ubuntu 版。




### 安装 install
```shell
pip install podao
```


一般将 podao 安装在系统环境,也可以安装在虚拟环境:

#### 安装在系统环境
1. 切换到项目路径
2. 执行 `podao init .`

#### 安装在虚拟环境
1. 激活安装有 podao 的虚拟环境
2. 切换到项目路径
3. 执行 `podao init .`
4. 退出安装有 podao 的虚拟环境 `deactivate`
5. 激活项目虚拟环境 `source bin/activate`




### 示例 examples

#### 创建项目环境
```shell
pd init . 3.10.4
pd init ~/workspace/project_name 
```

#### 安装软件包
```shell
pd install pytest -d
pd install 'ReportLab>=1.2' -g pdf
```

#### 卸载软件包
```shell
pd uninstall requests
```

#### 创建快照
```shell
pd freeze
pd freeze -a
pd freeze -d
pd freeze -g pdf

```



### 使用 usage
#### pd init dir [python] [-ide]
`pd init` 命令使用 dir 目录和 python 版本创建虚拟环境,包括 src、test、pyproject.toml、LICENSE、README.md和.gitignore。使用目录名作为项目名、当前系统用户作为author、MIT 为默认 LICENSE、当前年份和系统用户作为 LICENSE 时间和用户。
- `dir` - 项目目录,必填项,使用 `.` 表示当前目录
- `python` - python 版本号,如果不指定 python,则使用当前系统安装的最高版本的python
- `-ide` - 如果指定 IDE 会生成 IDE 的配置文件,目前仅支持 vscode



#### pd install packages
`pd install` 命令使用当前虚拟环境的 `pip install -U` 命令安装 packages 所指定的包,并将包添加到 pyproject 的相应依赖组中。
- `-d` - 将软件包添加到 `optional-dependencies` 表的 `dev` 组
- `-g` - 将软件包添加到 `optional-dependencies` 表的指定的组
- 不使用选项,将软件包默认安装到 dependencies 表



#### pd uninstall packages
`pd uninstall` 命令使用 `pip uninstall` 命令卸载 packages 所指定的包



#### pd freeze
`pd freeze` 命令结合 `pip freeze` 和 `pyproject.toml` 生成当前系统所需的软件包的版本快照到 `requirements.txt` 文件,然后使用 `pip install -r requirements.txt` 命令安装即可。
- `-d` - 创建 dev 依赖和主依赖的版本快照
- `-a` - 创建所有依赖的版本快照
- 不适用选项,将创建主依赖的版本快照



#### source bin/activate
激活虚拟环境,会在 shell 提示符左侧显示当前虚拟环境的名字,即虚拟环境文件夹的名字。



#### pip install -r requirements.txt
将通过 requirements.txt 文件定义的虚拟环境快照按照到当前环境。




### License
[MIT](LICENSE) © Li zhigang

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "podao",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "environment,dependency,workflow",
    "author": "",
    "author_email": "Li zhigang <imlzg@126.com>",
    "download_url": "https://files.pythonhosted.org/packages/54/4c/b720288e012fad99585dc97f897c37a7e61f05624e3b323bd84b65acd41b/podao-0.8.2.tar.gz",
    "platform": null,
    "description": "# \u6734\u5200 podao\n\u4e00\u628a\u6734\u5200\u5f00\u5c40\u3002\n\u6734\u5200\u662f\u4e00\u4e2a Python \u9879\u76ee\u642d\u5efa\u811a\u624b\u67b6\uff0c\u7ec4\u5408\u4f7f\u7528 pyenv\u3001venv \u548c pip \u7b49\u5de5\u5177\u642d\u5efa\u865a\u62df\u73af\u5883\u3001\u5206\u7ec4\u4f9d\u8d56\u5305\u3002\n\nPodao is an python project environment setup tool, it combines pyenv, venv, pip to ease the work to build an isolated environment for python project.\n\n\n\n\n![\u6734\u5200](https://github.com/imlzg/image/blob/6c2dcdd72ddbfb4174733e8dae6f3043e472788f/podao.jpg)\n\n\n\u6734\u5200\u662f\u4e00\u79cd\u5200\u8eab\u7a84\u957f\u3001\u5200\u67c4\u8f83\u77ed\u7684\u5200\uff0c\u88c5\u4e0a\u201c\u6746\u68d2\u201d\u540e\u53d8\u4e3a\u67aa\uff0c\u540d\u4e3a\u6734\u5200\u67aa\uff0c\u4ee5\u201c\u6420\u3001\u523a\u201d\u4e3a\u4e3b\u3002\n\n\u6734\u5200\u5728\u300a\u6c34\u6d52\u4f20\u300b\u91cc\u5e7f\u4e3a\u4eba\u77e5\uff0c\u5370\u8c61\u91cc\u6734\u5200\u90fd\u5f88\u957f\uff0c\u8fd9\u662f\u9519\u7684\uff1b\u6b63\u786e\u7684\u5b9a\u4e49\u662f\uff1a\u6734\u5200\u77ed\u67c4\uff0c\u67c4\u4e2d\u7a7a\uff0c\u662f\u5355\u624b\u6301\u63e1\u7684\u77ed\u5175\u5668\uff0c\u7279\u70b9\u5728\u4e8e\u5200\u67c4\u4e2d\u7a7a\uff0c\u65cb\u5165\u4e00\u6839\u54e8\u68d2\u5c31\u53ef\u4ee5\u5f53\u505a\u957f\u5175\u5668\u4f7f\u7528\uff0c\u6545\u5c14\u6b66\u677e\u7b49\u4eba\u90fd\u4e60\u60ef\u624b\u6301\u54e8\u68d2\uff0c\u8170\u914d\u6734\u5200\uff0c\u5982\u6b64\u4e24\u4ef6\u5175\u5668\u53ef\u4ee5\u5728\u9700\u8981\u65f6\u5408\u4e8c\u4e3a\u4e00\uff0c\u5c31\u50cf pyenv \u548c venv \u4e00\u6837\u3002\n\n\u5982\uff1a\u201c\u5362\u4fca\u4e49\u53d6\u51fa\u6734\u5200\uff0c\u88c5\u5728\u6746\u68d2\u4e0a\uff0c\u4e09\u4e2a\u4e86\u4e2b\u513f\u6263\u7262\u4e86\uff0c\u8d76\u8457\u8f66\u5b50\u5954\u6881\u5c71\u6cca\u8def\u4e0a\u6765\u201d\u3002\n\n\n\n\n### \u4f18\u52bf advantage\n-\u4f7f\u7528 pyenv\u3001venv \u548c pip \u642d\u5efa\u9879\u76ee\uff0c\u96f6\u5b66\u4e60\u6210\u672c\uff1b\n-\u4f7f\u7528\u6587\u4ef6\u5939\u540d\u4f5c\u4e3a shell session \u63d0\u793a\u7b26\uff0c\u65e0\u968f\u673a\u5b57\u7b26\u3001\u597d\u770b\u3001\u6709\u610f\u4e49\uff1b\n-\u4f7f\u7528 pyproject.toml \u548c requirements.txt \u6587\u4ef6\u63cf\u8ff0\u9879\u76ee\uff0c\u4e0d\u9020\u8f6e\u5b50\u3001\u96f6\u4fb5\u5165\uff1b\n\n\n\n\n### \u5c40\u9650 weakness\npodao \u53ea\u89e3\u51b3\u865a\u62df\u73af\u5883\u7684\u642d\u5efa\u548c\u4f9d\u8d56\u5305\u7684\u5206\u7ec4\u7684\u95ee\u9898\uff0c\u66f4\u5177\u4f53\u7684\u9879\u76ee\u914d\u7f6e\u9700\u8981\u624b\u52a8\u66f4\u6539 pyproject.toml \u6587\u4ef6\u3002\n\n\n\n### pyenv\npyenv \u7528\u4e8e\u7ba1\u7406\u9879\u76ee\u73af\u5883\u7684 python \u7248\u672c\uff0c\u8981\u4f7f\u7528 podao \u9700\u4e8b\u5148\u5b89\u88c5 pyenv\uff0c\u53c2\u8003[\u5b98\u7f51](https://github.com/pyenv/pyenv)\u3002\n\n#### pyenv installation\npyenv \u7684\u5b89\u88c5\u914d\u7f6e\u7a0d\u663e\u590d\u6742\uff0c\u5b89\u88c5\u8fc7\u7a0b\u53ef\u5206 3 \u6b65\uff1a\n1. \u5b89\u88c5 pyenv \u4f9d\u8d56\uff0c\u5305\u62ec `git`\uff0c[wiki](https://github.com/pyenv/pyenv/wiki#suggested-build-environment)\n2. \u5b89\u88c5 pyenv\uff0c[wiki](https://github.com/pyenv/pyenv-installer)\n3. \u914d\u7f6e pyenv \u73af\u5883\uff0c[wiki](https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv)\n\n\u6709\u4eba\u5c06\u5b89\u88c5\u8fc7\u7a0b\u5c01\u88c5\u6210\u4e86[\u5b89\u88c5\u811a\u672c](https://github.com/zaemiel/ubuntu-pyenv-installer)\uff0c\u76ee\u524d\u53ea\u6709 Ubuntu \u7248\u3002\n\n\n\n\n### \u5b89\u88c5 install\n```shell\npip install podao\n```\n\n\n\u4e00\u822c\u5c06 podao \u5b89\u88c5\u5728\u7cfb\u7edf\u73af\u5883\uff0c\u4e5f\u53ef\u4ee5\u5b89\u88c5\u5728\u865a\u62df\u73af\u5883\uff1a\n\n#### \u5b89\u88c5\u5728\u7cfb\u7edf\u73af\u5883\n1. \u5207\u6362\u5230\u9879\u76ee\u8def\u5f84\n2. \u6267\u884c `podao init .`\n\n#### \u5b89\u88c5\u5728\u865a\u62df\u73af\u5883\n1. \u6fc0\u6d3b\u5b89\u88c5\u6709 podao \u7684\u865a\u62df\u73af\u5883\n2. \u5207\u6362\u5230\u9879\u76ee\u8def\u5f84\n3. \u6267\u884c `podao init .`\n4. \u9000\u51fa\u5b89\u88c5\u6709 podao \u7684\u865a\u62df\u73af\u5883 `deactivate`\n5. \u6fc0\u6d3b\u9879\u76ee\u865a\u62df\u73af\u5883 `source bin/activate`\n\n\n\n\n### \u793a\u4f8b examples\n\n#### \u521b\u5efa\u9879\u76ee\u73af\u5883\n```shell\npd init . 3.10.4\npd init ~/workspace/project_name \n```\n\n#### \u5b89\u88c5\u8f6f\u4ef6\u5305\n```shell\npd install pytest -d\npd install 'ReportLab>=1.2' -g pdf\n```\n\n#### \u5378\u8f7d\u8f6f\u4ef6\u5305\n```shell\npd uninstall requests\n```\n\n#### \u521b\u5efa\u5feb\u7167\n```shell\npd freeze\npd freeze -a\npd freeze -d\npd freeze -g pdf\n\n```\n\n\n\n### \u4f7f\u7528 usage\n#### pd init dir [python] [-ide]\n`pd init` \u547d\u4ee4\u4f7f\u7528 dir \u76ee\u5f55\u548c python \u7248\u672c\u521b\u5efa\u865a\u62df\u73af\u5883\uff0c\u5305\u62ec src\u3001test\u3001pyproject.toml\u3001LICENSE\u3001README.md\u548c.gitignore\u3002\u4f7f\u7528\u76ee\u5f55\u540d\u4f5c\u4e3a\u9879\u76ee\u540d\u3001\u5f53\u524d\u7cfb\u7edf\u7528\u6237\u4f5c\u4e3aauthor\u3001MIT \u4e3a\u9ed8\u8ba4 LICENSE\u3001\u5f53\u524d\u5e74\u4efd\u548c\u7cfb\u7edf\u7528\u6237\u4f5c\u4e3a LICENSE \u65f6\u95f4\u548c\u7528\u6237\u3002\n- `dir` - \u9879\u76ee\u76ee\u5f55\uff0c\u5fc5\u586b\u9879\uff0c\u4f7f\u7528 `.` \u8868\u793a\u5f53\u524d\u76ee\u5f55\n- `python` - python \u7248\u672c\u53f7\uff0c\u5982\u679c\u4e0d\u6307\u5b9a python\uff0c\u5219\u4f7f\u7528\u5f53\u524d\u7cfb\u7edf\u5b89\u88c5\u7684\u6700\u9ad8\u7248\u672c\u7684python\n- `-ide` - \u5982\u679c\u6307\u5b9a IDE \u4f1a\u751f\u6210 IDE \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u76ee\u524d\u4ec5\u652f\u6301 vscode\n\n\n\n#### pd install packages\n`pd install` \u547d\u4ee4\u4f7f\u7528\u5f53\u524d\u865a\u62df\u73af\u5883\u7684 `pip install -U` \u547d\u4ee4\u5b89\u88c5 packages \u6240\u6307\u5b9a\u7684\u5305\uff0c\u5e76\u5c06\u5305\u6dfb\u52a0\u5230 pyproject \u7684\u76f8\u5e94\u4f9d\u8d56\u7ec4\u4e2d\u3002\n- `-d` - \u5c06\u8f6f\u4ef6\u5305\u6dfb\u52a0\u5230 `optional-dependencies` \u8868\u7684 `dev` \u7ec4\n- `-g` - \u5c06\u8f6f\u4ef6\u5305\u6dfb\u52a0\u5230 `optional-dependencies` \u8868\u7684\u6307\u5b9a\u7684\u7ec4\n- \u4e0d\u4f7f\u7528\u9009\u9879\uff0c\u5c06\u8f6f\u4ef6\u5305\u9ed8\u8ba4\u5b89\u88c5\u5230 dependencies \u8868\n\n\n\n#### pd uninstall packages\n`pd uninstall` \u547d\u4ee4\u4f7f\u7528 `pip uninstall` \u547d\u4ee4\u5378\u8f7d packages \u6240\u6307\u5b9a\u7684\u5305\n\n\n\n#### pd freeze\n`pd freeze` \u547d\u4ee4\u7ed3\u5408 `pip freeze` \u548c `pyproject.toml` \u751f\u6210\u5f53\u524d\u7cfb\u7edf\u6240\u9700\u7684\u8f6f\u4ef6\u5305\u7684\u7248\u672c\u5feb\u7167\u5230 `requirements.txt` \u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528 `pip install -r requirements.txt` \u547d\u4ee4\u5b89\u88c5\u5373\u53ef\u3002\n- `-d` - \u521b\u5efa dev \u4f9d\u8d56\u548c\u4e3b\u4f9d\u8d56\u7684\u7248\u672c\u5feb\u7167\n- `-a` - \u521b\u5efa\u6240\u6709\u4f9d\u8d56\u7684\u7248\u672c\u5feb\u7167\n- \u4e0d\u9002\u7528\u9009\u9879\uff0c\u5c06\u521b\u5efa\u4e3b\u4f9d\u8d56\u7684\u7248\u672c\u5feb\u7167\n\n\n\n#### source bin/activate\n\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff0c\u4f1a\u5728 shell \u63d0\u793a\u7b26\u5de6\u4fa7\u663e\u793a\u5f53\u524d\u865a\u62df\u73af\u5883\u7684\u540d\u5b57\uff0c\u5373\u865a\u62df\u73af\u5883\u6587\u4ef6\u5939\u7684\u540d\u5b57\u3002\n\n\n\n#### pip install -r requirements.txt\n\u5c06\u901a\u8fc7 requirements.txt \u6587\u4ef6\u5b9a\u4e49\u7684\u865a\u62df\u73af\u5883\u5feb\u7167\u6309\u7167\u5230\u5f53\u524d\u73af\u5883\u3002\n\n\n\n\n### License\n[MIT](LICENSE) \u00a9 Li zhigang\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A python project environment build tool.",
    "version": "0.8.2",
    "split_keywords": [
        "environment",
        "dependency",
        "workflow"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "f257b6a0b1a24c8f5c886390b5518e81",
                "sha256": "9dca1ee9b3e07adbbba4312768906591cb19e94ea24d2b27eaf251abb1b12e29"
            },
            "downloads": -1,
            "filename": "podao-0.8.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f257b6a0b1a24c8f5c886390b5518e81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10863,
            "upload_time": "2022-12-10T13:46:53",
            "upload_time_iso_8601": "2022-12-10T13:46:53.608929Z",
            "url": "https://files.pythonhosted.org/packages/2e/d1/5da544727a89d010008f2d7193c927fe2595574fa48d8606b048885eca6d/podao-0.8.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "9252e419d8bc29bbbaf6dbb2725b7bcb",
                "sha256": "e3e9e06aa1cdf8db584a2871ae1f300103f144c38c726acd2211e604e50a13a1"
            },
            "downloads": -1,
            "filename": "podao-0.8.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9252e419d8bc29bbbaf6dbb2725b7bcb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 12277,
            "upload_time": "2022-12-10T13:46:55",
            "upload_time_iso_8601": "2022-12-10T13:46:55.804640Z",
            "url": "https://files.pythonhosted.org/packages/54/4c/b720288e012fad99585dc97f897c37a7e61f05624e3b323bd84b65acd41b/podao-0.8.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-10 13:46:55",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "podao"
}
        
Elapsed time: 0.03364s