自动化发布Python包:从PyPI手动发布到GitHub Actions全流程
作为Python开发者,将自己的工具包发布到PyPI(Python Package Index)是分享代码的重要方式。然而,手动发布过程繁琐且容易出错。本文将带你了解如何: 手动将Python包发布到PyPI 使用GitHub Actions实现自动化构建和发布 解决发布过程中的常见问题 基于Demo分享本教程:https://github.com/Muieay/magic-tools 第一部分:手动发布到PyPI1. 创建项目结构官方推荐的一个标准的Python包结构如下: 123456789my-package/├── LICENSE├── README.md├── pyproject.toml├── src/│ └── my_package/│ ├── __init__.py│ └── module.py└── tests/ 注意事项: pypi官方包名通常建议使用短横线(-)作为分隔符。 在Python 的导入语句要求使用下划线(_)作为模块名的分隔符,因为 Python 标识符不允许使用短横线。 PyPI 包名:my-package ...
Kubernetes 1.30 新特性与迁移指南
Kubernetes 1.30 新特性与迁移指南Kubernetes 1.30 带来了许多激动人心的新特性。本文将介绍这些特性以及如何升级。 主要新特性1. CEL 用于验证规则(GA)CEL(Common Expression Language)现在正式可用: 1234567891011121314apiVersion: admissionregistration.k8s.io/v1kind: ValidatingAdmissionPolicymetadata: name: "demo-policy.example.com"spec: matchConstraints: resourceRules: - apiGroups: ["apps"] apiVersions: ["v1"] operations: ["CREATE", "UPDATE"] resources: ["deployments"] vali ...
Vue 4 Composition API 最佳实践
Vue 4 Composition API 最佳实践Vue 4 带来了更强大的 Composition API。本文将分享一些最佳实践。 使用 <script setup><script setup> 是 Vue 4 推荐的写法: 1234567891011121314151617<script setup>import { ref, computed } from 'vue'const count = ref(0)const double = computed(() => count.value * 2)function increment() { count.value++}</script><template> <div> {{ count }} x 2 = {{ double }} <button @click="increment ...
Rust 后端开发入门 - Axum 框架实战
Rust 后端开发入门 - Axum 框架实战Rust 在后端开发领域越来越流行。本文将带你使用 Axum 框架构建一个简单的 Web 服务。 为什么选择 AxumAxum 是 Tokio 团队开发的 Web 框架。它具有以下优点: 类型安全 高性能 易于使用 与 Tokio 生态系统集成良好 环境准备安装 Rust: 1curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 创建项目12cargo new axum-democd axum-demo 添加依赖编辑 Cargo.toml: 1234[dependencies]axum = "0.8"tokio = { version = "1.0", features = ["full"] }serde = { version = "1.0", features = ["derive"] } 编写代码 ...
React 19 新特性 - Server Components 深度解析
React 19 新特性 - Server Components 深度解析React 19 带来了重大更新。其中 Server Components 是最引人注目的新特性。 什么是 Server ComponentsServer Components 允许你在服务器端渲染组件。它们有以下特点: 可以直接访问后端资源 不会增加客户端 JavaScript 包大小 自动进行代码分割 创建一个 Server Component在 Next.js 15 中,组件默认就是 Server Component: 1234567891011121314151617181920// app/page.tsxasync function getPosts() { const res = await fetch('https://api.example.com/posts'); return res.json();}export default async function Home() { const posts = await getPosts ...
Go 1.23 与 Gin 构建 RESTful API 入门教程
Go 1.23 与 Gin 构建 RESTful API 入门教程Go 1.23 带来了许多新特性。本文将教你用 Go 1.23 和 Gin 框架快速构建一个 RESTful API。 环境准备首先,确保你已安装 Go 1.23 或更高版本。 1go version 创建项目创建一个新目录并初始化项目: 123mkdir go-gin-apicd go-gin-apigo mod init github.com/yourname/go-gin-api 安装 Gin安装 Gin 框架: 1go get -u github.com/gin-gonic/gin 编写代码创建 main.go 文件: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051package mainimport ( "net/http" "github.com/gin-gonic/gin")type User struct ...
Ollama 离线安装
Ollama 离线安装 在线安装参考 https://ollama.com/ 加速脚本下载: curl -fsSL https://fastscript.netlify.app/ai/ollama-install.sh | sh 步骤1:查看服务器CPU的型号 选择对应版本的安装包(当前CPU架构为x86,选择amd的版本),复制链接使用镜像加速下载 x86_64 CPU选择下载ollama-linux-amd64 aarch64|arm64 CPU选择下载ollama-linux-arm64 下载地址:https://github.com/ollama/ollama/releases 加速地址:https://moeyy.cn/gh-proxy git lfs installgit clone https://www.modelscope.cn/qwen/Qwen2-7B.gitshell 步骤2:离线下载Linux环境的Ollama安装脚本,并保存到**/home/Ollama**目录 1234567## 下载地址1,浏览器中打开下面地址https://olla ...
Unsloth微调模型
Unsloth微调模型详细参数参考:Unsloth 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103# 加载模型和分词器from unsloth import FastLanguageModelfrom local_dataset import LocalJsonDatasetfrom safetensors.torch import load_model, save_modelmax_seq_length = 2048dtype = Noneload_in_4bit = Falsemodel, tokenizer = FastLanguageModel.from_pretrained( model_name="./mod ...
Ollama 配置多并发和多模型
Ollama 配置多并发和多模型Linux为例 通过调用 编辑 systemd 服务systemctleditollama.service 这将打开一个编辑器。 1vim /etc/systemd/system/ollama.service 在[Service]部分下对于每个环境变量添加一行Environment, 如下所示 123[Service]Environment="OLLAMA_NUM_PARALLEL=4" #并行处理请求的数量Environment="OLLAMA_MAX_LOADED_MODELS=4" #同时加载的模型数 保存并退出。 3 . 重新加载systemd并重新启动 Olama: 12sudo systemctl daemon-reloadsudo systemctl restart ollama 在restart ollama前一定要调用daemon reload, 不然不会起作用。
llama.cpp量化模型文件
llama.cpp量化模型文件1. 构建llama.cpp使用克隆 llama.cpp 存储库 1git clone https://github.com/ggerganov/llama.cpp 12cd llama.cpp llama.cpp有我们需要运行的Python脚本,所以我们需要它的依赖项pip install pip install -r requirements.txt 现在,让我们建立我们的本地llama.cpp make clean && make all -j 对于任何拥有 nvidia GPU 的机器make clean && LLAMA_CUDA=1 make all -j 2. 获取模型数据下载开源模型,或者使用自己训练的模型 12git lfs installgit clone https://www.modelscope.cn/qwen/Qwen2-7B.git




