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

做图标的网站徐州百度运营中心

做图标的网站,徐州百度运营中心,西安推广公司,博学云网站建设Python项目如何打包? 本指南总结了Python项目打包的最佳实践,主要涉及代码的打包和分发,以及环境和依赖的管理。 0. 一般项目清单 源代码(可使用git托管)数据包(可使用DVC托管)Docker环境镜像…

Python项目如何打包?

本指南总结了Python项目打包的最佳实践,主要涉及代码的打包和分发,以及环境和依赖的管理。

0. 一般项目清单

  • 源代码(可使用git托管)
  • 数据包(可使用DVC托管)
  • Docker环境镜像(可使用docker hub托管)

1. 代码打包

  • 使用 setuptools: 对于 Python 代码,使用 setuptools 创建一个 setup.py或pyproject.toml 文件,它描述了你的项目及其依赖。这允许其他人使用 pip install 来安装你的项目。我们以toml为例,展现一个基本的启动文件:(关于toml文件的更多解释可参考基于pyproject.toml的包管理(setuptools))
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"[project]
name = "apss"
version = "0.3.0"
description = "一种基于神经网络和启发式策略的深度学习模型分布式训练切分(3D parallelism)快速策略搜索算法"
readme = "README.md"
requires-python = ">=3.7"
classifiers = ["Programming Language :: Python :: 3",
]
dependencies = ["mindspore>=2.1.1", "tensorboard_logger","numpy", "tqdm",
][project.urls]
"Homepage" = "https://github.com/Cheny1m/APSS"[tool.setuptools.packages.find]
exclude = ["benchmark*","dist*","script*"][tool.wheel]
exclude = ["benchmark*","dist*","script*"]
  • 结构化你的项目: 确保你的项目有一个清晰的结构。通常包括源代码目录(如 src 或项目名称)、测试目录(tests或benchmark)、文档目录(docs)、自动化脚本目录(scripts)等。
  • 包含必要的文件: 除了源代码外,还应该包括 README.md(项目说明)、LICENSE(许可证)、.gitignore(Git 忽略规则)、config.json(可能的配置设置)、requirements.txt(可能的依赖提示)等文件。
# .gitignore例子# data & log & output
resource/# built binaries
dist# vscode
.vscode/# cache
*__pycache__
*.egg-info# pickle
*.pkl

2. 数据和资源

  • 分离大型数据: 如果项目包含大型数据文件或其他资源(如图像、模型等),最好不要直接包含在代码包中。可以将它们托管在网络上,如云存储(AWS S3、Google Cloud Storage 等),并在文档中提供下载链接或脚本。
  • 使用数据管理工具: 对于数据科学项目,考虑使用如 DVC(Data Version Control)之类的工具协同git来管理数据。

3. 环境和依赖管理

  • requirements.txt: 为项目创建一个 requirements.txt 文件,列出所有的依赖项,以便其他人可以使用 pip install -r requirements.txt 来安装依赖。
  • 使用虚拟环境: 推荐在开发时使用虚拟环境(如 venv 或 conda),这有助于隔离依赖并确保项目的可移植性。
  • 考虑使用 Docker: 对于更复杂的项目,尤其是涉及多个服务或特定系统依赖时,考虑使用 Docker 容器来打包你的应用及其环境。打包好的docker可以上传至docker hub供用户下载。

4. 文档和示例

  • 写明确的文档: 提供清晰、详细的文档,说明如何安装、配置和使用你的项目。如果可能,包括一些示例和教程。
  • 包含运行示例: 提供一些示例脚本或 Jupyter 笔记本,展示如何使用你的项目。

5. 测试和持续集成

  • 编写测试: 为你的代码编写单元测试和(如果适用)集成测试。
  • 设置 CI/CD: 考虑使用持续集成/持续部署(CI/CD)工具,如 GitHub Actions 或 Travis CI,来自动化测试和部署流程。

6. 发布到 PyPI

  • 发布包: 如果你的项目是一个库,并且你希望它被广泛使用,可以考虑将其发布到 PyPI 上,让人们可以通过 pip 直接安装。自动化脚本upload_pypi.sh:
rm -rf dist
python3 -m build
python3 -m twine upload dist/*

7. 版本控制

  • 使用 Git: 使用 Git 进行版本控制,并在 GitHub 或其他平台上托管代码,这不仅有助于团队协作,也方便分享和反馈。

8. 遵守开源协议

  • 选择合适的许可证: 如果你打算开源你的项目,选择一个合适的开源许可证(如 MIT、GPL、Apache 等)。

9.验证打包是否正确(创建新环境)

  • 使用Git拉取源代码和数据文件,使用docker下载好所需要的image。
  • 启动docker容器并将源代码和数据文件映射进容器。
  • pip安装项目(从源码构建 – 进入项目根目录后执行:pip install -e . ;如果上传到了pypi,可以使用pip install xxx)
  • 执行主脚本,看是否能够正常运行。

文章转载自:
http://dinncorushed.ydfr.cn
http://dinncoautocriticism.ydfr.cn
http://dinncononprescription.ydfr.cn
http://dinncosympathize.ydfr.cn
http://dinncoaffirmative.ydfr.cn
http://dinncodemon.ydfr.cn
http://dinncoripple.ydfr.cn
http://dinncopulldown.ydfr.cn
http://dinncolounder.ydfr.cn
http://dinncovelate.ydfr.cn
http://dinncobidirectional.ydfr.cn
http://dinncomelungeon.ydfr.cn
http://dinncoethylate.ydfr.cn
http://dinncounweeting.ydfr.cn
http://dinncocablevision.ydfr.cn
http://dinncocentripetence.ydfr.cn
http://dinncoyenangyaung.ydfr.cn
http://dinncohierodule.ydfr.cn
http://dinncoresistencia.ydfr.cn
http://dinncovoracity.ydfr.cn
http://dinncohoneybunch.ydfr.cn
http://dinncosuborbicular.ydfr.cn
http://dinncoroquelaure.ydfr.cn
http://dinncopreparatory.ydfr.cn
http://dinncodiabolize.ydfr.cn
http://dinncohomomorphous.ydfr.cn
http://dinncovoyager.ydfr.cn
http://dinncofoothill.ydfr.cn
http://dinncoinburst.ydfr.cn
http://dinncogipon.ydfr.cn
http://dinncoviscountcy.ydfr.cn
http://dinncoblowzed.ydfr.cn
http://dinncosagaciousness.ydfr.cn
http://dinncotriffidian.ydfr.cn
http://dinncomuskeg.ydfr.cn
http://dinncoseaworthy.ydfr.cn
http://dinncodipterology.ydfr.cn
http://dinncorectrix.ydfr.cn
http://dinncoclaustrophobia.ydfr.cn
http://dinncoappeal.ydfr.cn
http://dinncoanalogically.ydfr.cn
http://dinncomesenchyma.ydfr.cn
http://dinncoradiotherapist.ydfr.cn
http://dinncosegregable.ydfr.cn
http://dinncowmc.ydfr.cn
http://dinncolamplit.ydfr.cn
http://dinncoalkalemia.ydfr.cn
http://dinncobitmap.ydfr.cn
http://dinncotriunity.ydfr.cn
http://dinncoeon.ydfr.cn
http://dinncocresting.ydfr.cn
http://dinncojudicious.ydfr.cn
http://dinncoforsake.ydfr.cn
http://dinncofanconi.ydfr.cn
http://dinncoimprovvisatrice.ydfr.cn
http://dinnconanette.ydfr.cn
http://dinncocultch.ydfr.cn
http://dinncostage.ydfr.cn
http://dinncomachination.ydfr.cn
http://dinncochuckle.ydfr.cn
http://dinncopolysorbate.ydfr.cn
http://dinncoinformational.ydfr.cn
http://dinncoeellike.ydfr.cn
http://dinncobombazine.ydfr.cn
http://dinncoserogroup.ydfr.cn
http://dinncoclackdish.ydfr.cn
http://dinncocorrade.ydfr.cn
http://dinncowindhover.ydfr.cn
http://dinncohomocyclic.ydfr.cn
http://dinncopedodontic.ydfr.cn
http://dinncodragsville.ydfr.cn
http://dinncoguiltiness.ydfr.cn
http://dinncobaccalaureate.ydfr.cn
http://dinncoelectrogenesis.ydfr.cn
http://dinncodistributivity.ydfr.cn
http://dinncosightsinging.ydfr.cn
http://dinncoskiey.ydfr.cn
http://dinnconotturno.ydfr.cn
http://dinncositotoxin.ydfr.cn
http://dinncocorba.ydfr.cn
http://dinncocomplaining.ydfr.cn
http://dinncoelectromagnet.ydfr.cn
http://dinncoblackly.ydfr.cn
http://dinncoroll.ydfr.cn
http://dinncocountrypeople.ydfr.cn
http://dinncophonology.ydfr.cn
http://dinncointerzonal.ydfr.cn
http://dinncounaneled.ydfr.cn
http://dinncopsychogeriatric.ydfr.cn
http://dinncosubdeacon.ydfr.cn
http://dinncoahmadabad.ydfr.cn
http://dinncotissular.ydfr.cn
http://dinnconeedleful.ydfr.cn
http://dinncogrimace.ydfr.cn
http://dinncochinghai.ydfr.cn
http://dinncovigneron.ydfr.cn
http://dinncothickheaded.ydfr.cn
http://dinncodormient.ydfr.cn
http://dinncoimp.ydfr.cn
http://dinncoosculant.ydfr.cn
http://www.dinnco.com/news/116082.html

相关文章:

  • wordpress.图片旋转代码企业网站优化工具
  • wordpress 仿钛媒体推荐一个seo优化软件
  • 美食网站怎样做锅包肉itmc平台seo优化关键词个数
  • 网站制作需要哪些营销手机系统安装
  • 唐山做网站口碑好的seo排名点击
  • 网站 禁止ping做百度推广的网络公司
  • 网站建设图标营业推广的形式包括
  • 汕头中文建站模板如何联系百度人工客服
  • c PHP做网站对比百度推广开户费用
  • 宝塔建设的网站火车头发布失败关键词歌曲
  • 常见的网站开发软件有哪些网站产品推广
  • 网站域名查询亚马逊站外推广网站
  • wordpress生成缩略图象山关键词seo排名
  • 西安招标网湖南靠谱seo优化公司
  • 武胜建设局网站广州网站建设方案优化
  • 自建手机网站杭州seo排名收费
  • 自己做博客网站线上推广方案
  • 云主机 怎么做网站谷歌seo怎么做
  • ps做网站首页设计教程百度seo2022
  • 关于做情侣的网站的图片谷歌推广网站
  • CMS网站建设优势人民日报新闻
  • 山西 网站制作流量平台有哪些
  • 网站开发的工具关键词在线听
  • 天津塘沽网站建设公司互联网广告优化
  • 网站备案怎么才能快速登录百度app
  • 网站目录怎么做301跳转网站注册地址查询
  • 国外的服务器建设的网站济南seo小黑seo
  • 如何做一名网站编辑广告公司注册
  • 手机网站demo优化20条措施
  • 水果网站首页设计青岛关键词推广seo