当前位置: 首页 > news >正文

企业邮箱注册需要什么材料wordpress 博客主题 seo

企业邮箱注册需要什么材料,wordpress 博客主题 seo,wordpress国旗,小程序微信公众平台Python 中我们经常会用到第三方的包#xff0c;默认情况下#xff0c;用到的第三方工具包基本都是从 Pypi.org 里面下载。这些第三方的包都是开发者们发布的自己的库。我们有自己的想法#xff0c;或者有一些常用的方法想要分享出去#xff0c;就可以发布自己的库#xff…Python 中我们经常会用到第三方的包默认情况下用到的第三方工具包基本都是从 Pypi.org 里面下载。这些第三方的包都是开发者们发布的自己的库。我们有自己的想法或者有一些常用的方法想要分享出去就可以发布自己的库也就是我们常说的造轮子。 PyPI (Python Package Index) 是 python 官方的第三方库的仓库所有人都可以下载第三方库或上传自己开发的库到PyPI。PyPI 推荐使用 pip 包管理器来下载第三方库。截至目前PyPI 已经有 574,662 个项目很多知名项目都发布在上面。 造轮子的步骤 包源代码开发git 版本管理编写setup.py编写说明文档发布到 Pypi后续维护升级 1 包源代码开发 包的功能可以使各种各样的关于包的源代码编写就不过多阐述这里就只是写了一个件简单的例子用来输出Hello Pypi。项目工程地址https://github.com/Taot-chen/hellopypi/tree/main 1.1 创建项目必须文件 touch README.md hellopypi.py setup.py文件结构 hellopypi/ ├── hellopypi.py ├── README.md └── setup.py1.2 创建 git 仓库 现在我们已经创建了项目结构下面将初始化一个 GitHub 存储库来托管代码 git init git add * git commit -m init repo git branch -M main git remote set-url origin https://your_tokengithub.com/USERNAME/hellopypi.git git push -u origin main也可以通过在 github 手动建好仓库之后再通过 clone 建好的仓库之后再往仓库添加文件的方式。 1.3 包源代码开发 这里的主程序就是前面的hellopypi.py里面的内容很简单 __version__ 0.1.0def hello_pypi():print(Hello Pypi!)def main():hello_pypi()if __name__ __main__:main()1.4 编写setup.py setup.py是每个能从 PyPi 上能下载到的库都有的文件它是发布的关键所在。 kennethreitz 大神编写了一个 for human 的setup.py模板项目地址传送门只需要把它复制过来修改自己项目需要的地方即可不需要额外的编写setup.cfg等其他文件。 我这里修改完的内容如下 #!/usr/bin/env python # -*- coding: utf-8 -*-# Note: To use the upload functionality of this file, you must: # $ pipenv install twine --devimport io import os import sys from shutil import rmtreefrom setuptools import find_packages, setup, Command# Package meta-data. NAME hellopypi DESCRIPTION print Hello Pypi in terminal. URL https://github.com/Taot-chen/hellopypi EMAIL oehuosifoxmail.com AUTHOR oehuosi REQUIRES_PYTHON 3.6.0 VERSION 0.1.0# What packages are required for this module to be executed? REQUIRED [# requests, maya, records, ]# What packages are optional? EXTRAS {# fancy feature: [django], }# The rest you shouldnt have to touch too much :) # ------------------------------------------------ # Except, perhaps the License and Trove Classifiers! # If you do change the License, remember to change the Trove Classifier for that!here os.path.abspath(os.path.dirname(__file__))# Import the README and use it as the long-description. # Note: this will only work if README.md is present in your MANIFEST.in file! try:with io.open(os.path.join(here, README.md), encodingutf-8) as f:long_description \n f.read() except FileNotFoundError:long_description DESCRIPTION# Load the packages __version__.py module as a dictionary. about {} if not VERSION:project_slug NAME.lower().replace(-, _).replace( , _)with open(os.path.join(here, project_slug, __version__.py)) as f:exec(f.read(), about) else:about[__version__] VERSIONclass UploadCommand(Command):Support setup.py upload.description Build and publish the package.user_options []staticmethoddef status(s):Prints things in bold.print(\033[1m{0}\033[0m.format(s))def initialize_options(self):passdef finalize_options(self):passdef run(self):try:self.status(Removing previous builds…)rmtree(os.path.join(here, dist))except OSError:passself.status(Building Source and Wheel (universal) distribution…)os.system({0} setup.py sdist bdist_wheel --universal.format(sys.executable))self.status(Uploading the package to PyPI via Twine…)os.system(twine upload dist/*)self.status(Pushing git tags…)os.system(git tag v{0}.format(about[__version__]))os.system(git push --tags)sys.exit()# Where the magic happens: setup(nameNAME,versionabout[__version__],descriptionDESCRIPTION,long_descriptionlong_description,long_description_content_typetext/markdown,authorAUTHOR,author_emailEMAIL,python_requiresREQUIRES_PYTHON,urlURL,# packagesfind_packages(exclude[tests, *.tests, *.tests.*, tests.*]),# If your package is a single module, use this instead of packages:py_modules[hellopypi],entry_points{console_scripts: [hellopypihello:main], },install_requiresREQUIRED,extras_requireEXTRAS,include_package_dataTrue,licenseApache-2.0,classifiers[# Trove classifiers# Full list: https://pypi.python.org/pypi?%3Aactionlist_classifiersLicense :: OSI Approved :: Apache-2.0 license,Programming Language :: Python,Programming Language :: Python :: 3,Programming Language :: Python :: 3.6,Programming Language :: Python :: Implementation :: CPython,Programming Language :: Python :: Implementation :: PyPy],# $ setup.py publish support.cmdclass{upload: UploadCommand,}, )配置信息说明 项目的配置信息 # Package meta-data. NAME mypackage DESCRIPTION 填写你的项目简短描述. URL https://github.com/你的github账户/mypackage EMAIL meexample.com # 你的邮箱 AUTHOR Awesome Soul # 你的名字 REQUIRES_PYTHON 3.6.0 # 项目支持的python版本 VERSION 0.1.0 # 项目版本号项目的依赖库(没有就不填) # What packages are required for this module to be executed? REQUIRED [# requests, maya, records, ]setup部分: 这里大部分内容都不用填只有以下几个注意点 long_description这里默认是项目的README.md文件注释掉的entry_points部分是用来生成命令行工具或者GUI工具的理论上是跨平台的这里我生成了一个hellopypi的命令来代替hello.py的main函数安装成功以后就可以直接使用hellopypi命令 entry_points{ console_scripts: [hellopypihello:main], },如果你的项目文件夹下只有一个py文件来实现你的功能的话需要将packagesfind_packages(exclude[tests, *.tests, *.tests.*, tests.*]),注释掉然后取消py_modules的注释并进行相应修改。 setup(nameNAME,versionabout[__version__],descriptionDESCRIPTION,long_descriptionlong_description,long_description_content_typetext/markdown,authorAUTHOR,author_emailEMAIL,python_requiresREQUIRES_PYTHON,urlURL,# packagesfind_packages(exclude[tests, *.tests, *.tests.*, tests.*]),# If your package is a single module, use this instead of packages:py_modules[hellopypi],entry_points{console_scripts: [hellopypihello:main], },install_requiresREQUIRED,extras_requireEXTRAS,include_package_dataTrue,licenseApache-2.0,classifiers[# Trove classifiers# Full list: https://pypi.python.org/pypi?%3Aactionlist_classifiersLicense :: OSI Approved :: Apache-2.0 license,Programming Language :: Python,Programming Language :: Python :: 3,Programming Language :: Python :: 3.6,Programming Language :: Python :: Implementation :: CPython,Programming Language :: Python :: Implementation :: PyPy],# $ setup.py publish support.cmdclass{upload: UploadCommand,}, )1.5 编写说明文档 一个好的项目需要有一个条理清晰的文档的在 README.md 对项目进行详尽的说明。 2 发布到 Pypi 2.1 生成分发档案 为包生成分发包。这些是上传到包索引的档案可以通过pip安装。 确保有setuptools, wheel 安装了最新版本 python3 -m pip install --user --upgrade setuptools wheel检查setup.py是否有错误: 运行python setup.py check如果没报错误则输出一般是running check如果有错误就根据报错信息来修一下。 准备好上面的步骤, 一个包就基本完整了, 剩下的就是打包了。 2.1.1 生成 tar.gz 包 python3 setup.py sdist build在当前目录的 dist 文件夹下, 就会多出一个tar.gz结尾的包了。 2.1.2 也可以打包一个 wheel 格式的包 python3 setup.py bdist_wheel --universal在 dist 文件夹下面生成一个whl文件. 也可以一次性生成tar.gz包和whl包 python3 setup.py sdist bdist_wheel会在dist目录下生成一个tar.gz的源码包和一个.whl的 Wheel 包。 2.2 发布包到 Pypi 先去pypi注册账号记住账号和密码后面上传包会使用。 注册号账号之后接下来就是上传包。 上传的时候会用到twine需要先安装twine(用 twine上传分发包并且只有 twine 1.11.0 才能将元数据正确发送到 Pypi上)。 pip install twine前面编写的setup.py具备上传包的功能 python3 setup.py upload不出意外的话到这里我们自己的包就发布完成了。但是这里可能会遇到这样的报错The user xxx isnt allowed to upload to project xxx. See https://pypi.org/help/#project-name for more information. 这个是由于软件包名字是PyPI用以区分的唯一标识因此必须全球唯一此时表明可能已经存在了相同名字的包了那么换个不重复的名字即可。我这里就遇到了这个问题因此我把名字改成了hellopypi_oh就可以了。 2.3 验证发布 PYPI 成功 上传完成了会显示 success, 我们直接可以在 PyPI 上看到。 可以使用pip来安装包并验证它是否有效: pip install hellopypi_oh安装成功之后直接在 Terminal 中执行 hellopypi_oh命令看到输出 Hello Pypi!表明发布成功。 3 后续维护升级 有更新升级之后首先删除旧版本打包文件然后生成新文件 python3 setup.py sdist bdist_wheel输入以下命令上传新版本即可 python setup.py upload这个命令还会自动把代码改动更新到 github 仓库。
http://www.hkea.cn/news/14414435/

相关文章:

  • 涉县移动网站建设报价企业网址怎么申请
  • 免费用手机建立网站深圳商业网站建设系统
  • 光谷网站建设公司邯郸做紧固件网站
  • 珠海网站建设网络有限公司企业整合营销
  • 网站开发如何赚钱公司网站引导页
  • 网站架设流程网站悬浮窗口代码
  • 做画册好的网站网站开发总结 优帮云
  • 揭秘低价网站建设危害贵州景点网站建设方案
  • 网站需要域名吗长沙新媒体营销
  • 深圳外贸网站建设企业学校 门户网站建设方案
  • 联通企业网站建设转短链接在线生成
  • 建设一个班级网站的具体步骤word可以制作网页
  • 上海市建设协会考试网站东莞樟木头做网站哪家好
  • 做网站图片要求wordpress 500错误
  • 网站建设开发费入什么科目搭建论坛需要多少钱
  • 做仿站如何修改网站管理权限电子商务网站建设的语言及特点
  • 定制网站建设公司哪家好郑州平台制作
  • 网站建设中界面模板网站优化工具分析工具
  • 金品诚企网站建设网站怎么做网页
  • 网站dns服务域名建网站
  • 模仿网站侵权吗图片分享 wordpress
  • 品牌网站设计企业服务wordpress柒比贰主题破解版
  • 个人能建网站吗学校实验室网站建设现状
  • 网站开发两端对齐底行左对齐wordpress简约下载站模板
  • 一个服务器可以备案几个网站亚马逊关联乱码店铺怎么处理
  • 建设网站商城有什么好的提供外链网站
  • 哈尔滨站建筑如何保存自己做的网站
  • 网站建设费支付请示西昌手机网站建设成都彩钢顶防水
  • 天津网站建设教程厦门新闻头条最新消息
  • 网站建设费属于服务类么产品网页设计教程