/string2date
/string2date
__init__.py
string2date.py
setup.py
LICENSE
README.md
__init__.py
初始化的数据,之后pip install
调包的时候会先加载这里面的数据,所以里面还需要加上
from . import string2date
写的方法
from setuptools import setup
setup(name='string2date',
version='0.0.1',
description='string to date',
url='https://github.com/BigDataFounder/string2date',
author='hurpe',
author_email='[email protected]',
license='MIT',
packages=['string2date'])
setuptools.find_packages()
去自动导入,我这里就一个包,所以直接写了自定义的一项,可以简单描述一下包是做什么的
许可证,详细信息可以去官网查看,如果用的是MIT
,可以直接复制下面的。
Copyright (c) 2018 The Python Packaging Authority
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
如果上述工作都做完了,那么恭喜你可以开始准备上传包了,之后就可以用pip install
下载工具了。
首先需要保证你有最新版的setuptools
和wheel
python -m pip install --user --upgrade setuptools wheel
Tip:如果出现问题了可以查看官网的解决方案:https://packaging.python.org/tutorials/installing-packages/
setup.py
同级目录下python setup.py sdist bdist_wheel
这时会生成两个文件
dist/
string2date-0.0.1-py2-none-any.whl
string2date-0.0.1.tar.gz
利用twine
将包上传上去
twine
python -m pip install --user --upgrade twine
之后会用到帐号密码
网站传送门:https://pypi.org/
Tip:
twine upload dist/*
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
注意:这地方我遇到了个坑,可能因为我这个电脑python装了好几个版本,还有anaconda,所以我在下载twine
的时候不在我配置环境变量的路径里,上传的命令一直不能执行,找了半天又加了一个twine
的环境变量才能用
#### 上传成功的命令行
G:\pycode\hurpe\string2date>twine upload dist/string2date-0.0.1*
Enter your username: hurpe
Enter your password:
Uploading distributions to https://upload.pypi.org/legacy/
Uploading string2date-0.0.3-py2-none-any.whl
100%|█████████████████████████████████████| 5.28k/5.28k [00:05<00:00, 1.02kB/s]
Uploading string2date-0.0.3.tar.gz
100%|█████████████████████████████████████| 3.85k/3.85k [00:01<00:00, 2.89kB/s]
这时候就可以,下载包,然后运行里面方法了
pip install string2date
G:\pycode\hurpe\string2date>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import string2date
>>>
setup.py
下的version
python setup.py sdist bdist_wheel
twine upload dist/string2date-0.0.2*
pip install --upgrade string2date
或者是先卸载,再安装
# 卸载string2date
pip uninstall string2date
# 安装string2date
pip install string2date