Name | pypi-pip-template JSON |
Version |
0.0.8
JSON |
| download |
home_page | |
Summary | |
upload_time | 2023-11-11 18:59:45 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | |
keywords |
pypi
pip
template
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pypi_pip_template
a template for build python package to upload pypi repository bu using pip
https://pypi.org/project/pypi-pip-template/
## Create a project with the following structure
```bash
pypi_pip_template
├── .gitignore
├── LICENSE
├── CHANGELOG.txt
├── README.md
├── setup.py
├── pypi_pip_template
│ ├── __init__.py
│ └── __main__.py
│ ├── gui
│ └── __init__.py
│ ├── utils
│ └── __init__.py
└── tests
└── test.py
```
### windows
```powershell
$package="pypi_pip_template"
New-Item CHANGELOG.txt -type file
New-Item setup.py -type file
New-Item LICENSE -type file
New-Item README.md -type file
New-Item .gitignore -type file
New-Item -Force -Path $package/gui -ItemType Directory
New-Item -Force -Path $package/utils -ItemType Directory
New-Item $package/__init__.py -type file
New-Item $package/__main__.py -type file
New-Item $package/gui/__init__.py -type file
New-Item $package/utils/__init__.py -type file
New-Item -Force -Path tests -ItemType Directory
New-Item tests/test.py -type file
```
### linux
```bash
package="pypi_pip_template"
touch CHANGELOG.txt
touch setup.py
touch LICENSE
touch README.md
touch .gitignore
mkdir -p ${package}/gui
mkdir -p ${package}/utils
touch ${package}/__init__.py
touch ${package}/__main__.py
touch ${package}/gui/__init__.py
touch ${package}/utils/__init__.py
mkdir -p tests
touch tests/test.py
```
## create virtualenv environment
windows
```powershell
python -m venv .venv
./.venv/Scripts/activate
pip list
python -m pip install --upgrade pip
python -m pip install --upgrade build setuptools wheel twine
pip freeze >requirements.txt
```
linux
```bash
python3 -m venv .venv
./.venv/Scripts/activate
pip list
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build setuptools wheel twine
pip freeze >requirements.txt
```
### Create the build
windows
```powershell
Remove-Item -LiteralPath "dist" -Force -Recurse
Remove-Item -LiteralPath "build" -Force -Recurse
Remove-Item -LiteralPath "pypi_pip_template.egg-info" -Force -Recurse
python setup.py sdist bdist_wheel
```
linux
```bash
rm -rf dist
python3 setup.py sdist bdist_wheel
```
### publish package to pypi
windows
```powershell
# python -m twine upload --repository testpypi dist/*
python -m twine upload --repository pypi dist/*
```
linux
```bash
# python3 -m twine upload --repository testpypi dist/*
python3 -m twine upload --repository pypi dist/*
```
You will be prompted for a username and password. For the username, use __token__. For the password, use the token value, including the pypi- prefix.
After the command completes, you should see output similar to this:
```bash
Uploading distributions to https://test.pypi.org/legacy/
Enter your username: __token__
Uploading example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.2/8.2 kB • 00:01 • ?
Uploading example_package_YOUR_USERNAME_HERE-0.0.1.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.8/6.8 kB • 00:00 • ?
```
### Installing your newly uploaded package
You can use pip to install your package and verify that it works. Create a virtual environment and install your package from TestPyPI:
```powershell
# python -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HERE
python -m pip install --index-url https://pypi.org/simple/ --no-deps pypi-pip-template==0.0.1
python -m pip install pypi-pip-template==0.0.1
pip install pypi-pip-template==0.0.1
pip install -i https://pypi.org/simple pypi-pip-template==0.0.1 (recomend)
```
```bash
# python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HERE
python3 -m pip install --index-url https://pypi.org/simple/ --no-deps pypi-pip-template==0.0.1
python3 -m pip install pypi-pip-template==0.0.1
pip install pypi-pip-template==0.0.1
pip install -i https://pypi.org/simple pypi-pip-template==0.0.1 ((recomend))
```
## build and publish
```cmd
.venv\Scripts\activate.bat
RMDIR /Q/S build
RMDIR /Q/S dist
RMDIR /Q/S pypi_pip_template.egg-info
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
```
```powershell
.venv/Scripts/activate.bat
Remove-Item -LiteralPath "dist" -Force -Recurse
Remove-Item -LiteralPath "build" -Force -Recurse
Remove-Item -LiteralPath "pypi_pip_template.egg-info" -Force -Recurse
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
```
```bash
.venv/Scripts/activate.bat
rm -rf dist/ build/ pypi_pip_template.egg-info/
python -m twine upload --repository pypi dist/*
python -m twine upload --repository pypi dist/*
```
### References
- https://www.youtube.com/watch?v=v4bkJef4W94
- https://packaging.python.org/tutorials/packaging-projects/
- [Python3 通过TOML进行打包与上传到Pypi的踩坑日记](https://blog.csdn.net/ViniJack/article/details/134133414)
v0.0.8: change github action yaml file to trigger it by create a tag
Raw data
{
"_id": null,
"home_page": "",
"name": "pypi-pip-template",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pypi,pip,template",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/bb/2b/ca1afb703bc590e5d0bffef173540247eda1193eff044caf69bd1c9196aa/pypi_pip_template-0.0.8.tar.gz",
"platform": null,
"description": "# pypi_pip_template\na template for build python package to upload pypi repository bu using pip\n\nhttps://pypi.org/project/pypi-pip-template/\n\n\n## Create a project with the following structure\n```bash\npypi_pip_template\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 CHANGELOG.txt\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 setup.py\n\u251c\u2500\u2500\u00a0pypi_pip_template\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 __main__.py\n\u2502 \u251c\u2500\u2500\u00a0gui\n\u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500\u00a0utils\n\u2502 \u2514\u2500\u2500 __init__.py\n\u2514\u2500\u2500 tests\n \u2514\u2500\u2500 test.py\n```\n\n### windows\n```powershell\n\n$package=\"pypi_pip_template\"\nNew-Item CHANGELOG.txt -type file\nNew-Item setup.py -type file\nNew-Item LICENSE -type file\nNew-Item README.md -type file\nNew-Item .gitignore -type file\nNew-Item -Force -Path $package/gui -ItemType Directory\nNew-Item -Force -Path $package/utils -ItemType Directory\nNew-Item $package/__init__.py -type file\nNew-Item $package/__main__.py -type file\nNew-Item $package/gui/__init__.py -type file\nNew-Item $package/utils/__init__.py -type file\nNew-Item -Force -Path tests -ItemType Directory\nNew-Item tests/test.py -type file\n\n\n```\n\n### linux\n```bash\n\npackage=\"pypi_pip_template\"\ntouch CHANGELOG.txt\ntouch setup.py\ntouch LICENSE\ntouch README.md\ntouch .gitignore\nmkdir -p ${package}/gui\nmkdir -p ${package}/utils\ntouch ${package}/__init__.py\ntouch ${package}/__main__.py\ntouch ${package}/gui/__init__.py\ntouch ${package}/utils/__init__.py\nmkdir -p tests\ntouch tests/test.py\n\n```\n\n## create virtualenv environment\nwindows\n```powershell\n\npython -m venv .venv\n./.venv/Scripts/activate \n\npip list\n\npython -m pip install --upgrade pip\npython -m pip install --upgrade build setuptools wheel twine\n\npip freeze >requirements.txt \n\n```\n\nlinux\n```bash\n\npython3 -m venv .venv\n./.venv/Scripts/activate \n\npip list\n\npython3 -m pip install --upgrade pip\npython3 -m pip install --upgrade build setuptools wheel twine\n\npip freeze >requirements.txt \n\n```\n\n### Create the build\nwindows\n```powershell\nRemove-Item -LiteralPath \"dist\" -Force -Recurse\nRemove-Item -LiteralPath \"build\" -Force -Recurse\nRemove-Item -LiteralPath \"pypi_pip_template.egg-info\" -Force -Recurse\npython setup.py sdist bdist_wheel\n\n```\nlinux\n```bash\nrm -rf dist\npython3 setup.py sdist bdist_wheel\n\n```\n\n### publish package to pypi\nwindows\n```powershell\n\n# python -m twine upload --repository testpypi dist/*\npython -m twine upload --repository pypi dist/*\n\n```\n\nlinux\n```bash\n# python3 -m twine upload --repository testpypi dist/*\npython3 -m twine upload --repository pypi dist/*\n\n\n```\n\nYou will be prompted for a username and password. For the username, use __token__. For the password, use the token value, including the pypi- prefix.\n\nAfter the command completes, you should see output similar to this:\n\n```bash\nUploading distributions to https://test.pypi.org/legacy/\nEnter your username: __token__\nUploading example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl\n100% \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 8.2/8.2 kB \u2022 00:01 \u2022 ?\nUploading example_package_YOUR_USERNAME_HERE-0.0.1.tar.gz\n100% \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501 6.8/6.8 kB \u2022 00:00 \u2022 ?\n\n```\n\n\n\n### Installing your newly uploaded package\nYou can use pip to install your package and verify that it works. Create a virtual environment and install your package from TestPyPI:\n\n```powershell\n\n# python -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HERE\npython -m pip install --index-url https://pypi.org/simple/ --no-deps pypi-pip-template==0.0.1\npython -m pip install pypi-pip-template==0.0.1\npip install pypi-pip-template==0.0.1\npip install -i https://pypi.org/simple pypi-pip-template==0.0.1 (recomend)\n\n```\n\n```bash\n\n# python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HERE\npython3 -m pip install --index-url https://pypi.org/simple/ --no-deps pypi-pip-template==0.0.1\npython3 -m pip install pypi-pip-template==0.0.1\npip install pypi-pip-template==0.0.1\npip install -i https://pypi.org/simple pypi-pip-template==0.0.1 ((recomend))\n\n```\n\n\n## build and publish\n```cmd\n\n.venv\\Scripts\\activate.bat\nRMDIR /Q/S build\nRMDIR /Q/S dist\nRMDIR /Q/S pypi_pip_template.egg-info\npython setup.py sdist bdist_wheel\npython -m twine upload --repository pypi dist/*\n\n```\n\n```powershell\n.venv/Scripts/activate.bat\nRemove-Item -LiteralPath \"dist\" -Force -Recurse\nRemove-Item -LiteralPath \"build\" -Force -Recurse\nRemove-Item -LiteralPath \"pypi_pip_template.egg-info\" -Force -Recurse\npython setup.py sdist bdist_wheel\npython -m twine upload --repository pypi dist/*\n\n```\n\n```bash\n\n.venv/Scripts/activate.bat\nrm -rf dist/ build/ pypi_pip_template.egg-info/\npython -m twine upload --repository pypi dist/*\npython -m twine upload --repository pypi dist/*\n\n```\n\n\n### References\n- https://www.youtube.com/watch?v=v4bkJef4W94\n- https://packaging.python.org/tutorials/packaging-projects/\n- [Python3 \u901a\u8fc7TOML\u8fdb\u884c\u6253\u5305\u4e0e\u4e0a\u4f20\u5230Pypi\u7684\u8e29\u5751\u65e5\u8bb0](https://blog.csdn.net/ViniJack/article/details/134133414)\n\n\nv0.0.8: change github action yaml file to trigger it by create a tag\n",
"bugtrack_url": null,
"license": "",
"summary": "",
"version": "0.0.8",
"project_urls": null,
"split_keywords": [
"pypi",
"pip",
"template"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cfac7d4687a5f8ea193217d2563272948876134b6ea828a872f296050469a7dc",
"md5": "4f87036373a7d5c94bd8daac95e435bd",
"sha256": "b0f53929dd39923f027494b99a34a7ba573977a0b0bf5dffa94177960145c2af"
},
"downloads": -1,
"filename": "pypi_pip_template-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4f87036373a7d5c94bd8daac95e435bd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5388,
"upload_time": "2023-11-11T18:59:44",
"upload_time_iso_8601": "2023-11-11T18:59:44.691911Z",
"url": "https://files.pythonhosted.org/packages/cf/ac/7d4687a5f8ea193217d2563272948876134b6ea828a872f296050469a7dc/pypi_pip_template-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bb2bca1afb703bc590e5d0bffef173540247eda1193eff044caf69bd1c9196aa",
"md5": "9eca20caa5926d81875bd38daa085a53",
"sha256": "7f19c5d65f37eff699aa378d163a9299dc98fb0d1d411ed9ec8d472d9cffb630"
},
"downloads": -1,
"filename": "pypi_pip_template-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "9eca20caa5926d81875bd38daa085a53",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4765,
"upload_time": "2023-11-11T18:59:45",
"upload_time_iso_8601": "2023-11-11T18:59:45.947028Z",
"url": "https://files.pythonhosted.org/packages/bb/2b/ca1afb703bc590e5d0bffef173540247eda1193eff044caf69bd1c9196aa/pypi_pip_template-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-11 18:59:45",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pypi-pip-template"
}