# yq-pystand-setup
python 脚本工具
自动创建一个使用 [PyStand](https://github.com/skywind3000/PyStand) 的项目
它会在 PyStand 的基础上,自动安装 pip 。
# 安装
```
pip install yq-pystand-setup
```
# 使用
## 创建项目
```
py -m yq_pystand_setup [Project Name]
```
## 已有项目初始化
```
py -m yq_pystand_setup --init /path/to/project
```
## 安装包
首先激活环境
进入项目目录下,执行
### Activate in cmd
```
call activate.cmd
```
### Activate in Powershell
```
. activate.ps1
```
激活之后 python pip 都会指向项目使用的,如下所示
```
$ Get-Command python | Format-List -Property path
Path : D:\path\to\your\project\runtime\python.exe
$ Get-Command pip | Format-List -Property Path
Path : D:\path\to\your\project\runtime\pip_wrapper\bin\pip.exe
```
然后正常使用 pip 安装,例如
```
pip install flask
```
# PyCharm 配置
手动将项目下的 runtime/Lib/site-packages 标记为 Sources Root ,不然识别不了你安装在这里的包
解析器直接选择 runtime/python.exe
因为我们放了一些 activate 开头的空文件在 runtime , PyCharm 会将它识别为当前项目的 virtualenv
# 参考
[PyStand](https://github.com/skywind3000/PyStand)
[Portable Python Bundles on Windows](https://dev.to/treehouse/portable-python-bundles-on-windows-41ac)
# 实现
1. 在当前目录下创建项目文件夹
2. 安装 PyStand (PyStand-py38-x64.7z)
3. 安装 pip
4. 其他设置(放一些空文件,让 PyCharm 认为这是一个 vritualenv)
Raw data
{
"_id": null,
"home_page": "https://github.com/yetsing/yq-pystand-setup",
"name": "yq-pystand-setup",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "pystand",
"author": "yeqing",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/bf/c1/2d7326a88f8478b290cb3b0ddba61c63847420355882549bb46bf9f551a3/yq_pystand_setup-0.1.2.tar.gz",
"platform": null,
"description": "# yq-pystand-setup\n\npython \u811a\u672c\u5de5\u5177\n\n\u81ea\u52a8\u521b\u5efa\u4e00\u4e2a\u4f7f\u7528 [PyStand](https://github.com/skywind3000/PyStand) \u7684\u9879\u76ee\n\n\u5b83\u4f1a\u5728 PyStand \u7684\u57fa\u7840\u4e0a\uff0c\u81ea\u52a8\u5b89\u88c5 pip \u3002\n\n# \u5b89\u88c5\n\n```\npip install yq-pystand-setup\n```\n\n# \u4f7f\u7528\n\n## \u521b\u5efa\u9879\u76ee\n\n```\npy -m yq_pystand_setup [Project Name]\n```\n\n## \u5df2\u6709\u9879\u76ee\u521d\u59cb\u5316\n\n```\npy -m yq_pystand_setup --init /path/to/project\n```\n\n## \u5b89\u88c5\u5305\n\n\u9996\u5148\u6fc0\u6d3b\u73af\u5883\n\n\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u4e0b\uff0c\u6267\u884c\n\n### Activate in cmd\n\n```\ncall activate.cmd\n```\n\n### Activate in Powershell\n\n```\n. activate.ps1\n```\n\n\u6fc0\u6d3b\u4e4b\u540e python pip \u90fd\u4f1a\u6307\u5411\u9879\u76ee\u4f7f\u7528\u7684\uff0c\u5982\u4e0b\u6240\u793a\n\n```\n$ Get-Command python | Format-List -Property path\nPath : D:\\path\\to\\your\\project\\runtime\\python.exe\n\n$ Get-Command pip | Format-List -Property Path\nPath : D:\\path\\to\\your\\project\\runtime\\pip_wrapper\\bin\\pip.exe\n```\n\n\u7136\u540e\u6b63\u5e38\u4f7f\u7528 pip \u5b89\u88c5\uff0c\u4f8b\u5982\n\n```\npip install flask\n```\n\n# PyCharm \u914d\u7f6e\n\n\u624b\u52a8\u5c06\u9879\u76ee\u4e0b\u7684 runtime/Lib/site-packages \u6807\u8bb0\u4e3a Sources Root \uff0c\u4e0d\u7136\u8bc6\u522b\u4e0d\u4e86\u4f60\u5b89\u88c5\u5728\u8fd9\u91cc\u7684\u5305\n\n\u89e3\u6790\u5668\u76f4\u63a5\u9009\u62e9 runtime/python.exe\n\n\u56e0\u4e3a\u6211\u4eec\u653e\u4e86\u4e00\u4e9b activate \u5f00\u5934\u7684\u7a7a\u6587\u4ef6\u5728 runtime \uff0c PyCharm \u4f1a\u5c06\u5b83\u8bc6\u522b\u4e3a\u5f53\u524d\u9879\u76ee\u7684 virtualenv\n\n# \u53c2\u8003\n\n[PyStand](https://github.com/skywind3000/PyStand)\n\n[Portable Python Bundles on Windows](https://dev.to/treehouse/portable-python-bundles-on-windows-41ac)\n\n# \u5b9e\u73b0\n\n1. \u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u521b\u5efa\u9879\u76ee\u6587\u4ef6\u5939\n2. \u5b89\u88c5 PyStand \uff08PyStand-py38-x64.7z\uff09\n3. \u5b89\u88c5 pip\n4. \u5176\u4ed6\u8bbe\u7f6e\uff08\u653e\u4e00\u4e9b\u7a7a\u6587\u4ef6\uff0c\u8ba9 PyCharm \u8ba4\u4e3a\u8fd9\u662f\u4e00\u4e2a vritualenv\uff09\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Setup PyStand",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/yetsing/yq-pystand-setup"
},
"split_keywords": [
"pystand"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a577894a9d3500c226f6f62f120c5d3fa90935c1e48aeac9e7b03e39458679aa",
"md5": "8736f5ddb18c43a7e014d8da50d7b552",
"sha256": "f95dd0cba321d78a32cd0088a1fe1b4fefa663f6c6bdff5aaea7c2a1f3befa06"
},
"downloads": -1,
"filename": "yq_pystand_setup-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8736f5ddb18c43a7e014d8da50d7b552",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5727,
"upload_time": "2025-03-09T17:03:02",
"upload_time_iso_8601": "2025-03-09T17:03:02.929158Z",
"url": "https://files.pythonhosted.org/packages/a5/77/894a9d3500c226f6f62f120c5d3fa90935c1e48aeac9e7b03e39458679aa/yq_pystand_setup-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bfc12d7326a88f8478b290cb3b0ddba61c63847420355882549bb46bf9f551a3",
"md5": "5304abb633de0448c4289ea10b68f9fe",
"sha256": "597a5b2635d22f5b8fdde89bab3f280334d63f4f281818ec5df0a25ea61009e7"
},
"downloads": -1,
"filename": "yq_pystand_setup-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "5304abb633de0448c4289ea10b68f9fe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5373,
"upload_time": "2025-03-09T17:03:03",
"upload_time_iso_8601": "2025-03-09T17:03:03.982019Z",
"url": "https://files.pythonhosted.org/packages/bf/c1/2d7326a88f8478b290cb3b0ddba61c63847420355882549bb46bf9f551a3/yq_pystand_setup-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-03-09 17:03:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yetsing",
"github_project": "yq-pystand-setup",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "yq-pystand-setup"
}