<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Package on Chang Luo</title>
		<link>https://www.luochang.ink/tags/package/</link>
		<description>Recent content in Package on Chang Luo</description>
		<generator>Hugo</generator>
		<language>zh-CN</language>
		
		
		
		
			<lastBuildDate>Wed, 18 Oct 2023 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://www.luochang.ink/tags/package/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>PyPI 打包小记</title>
				<link>https://www.luochang.ink/posts/pypi_packaging/</link>
				<pubDate>Wed, 18 Oct 2023 00:00:00 +0000</pubDate>
				<guid>https://www.luochang.ink/posts/pypi_packaging/</guid>
				<description>&lt;blockquote&gt;&#xA;&lt;p&gt;你们这些家伙，好好看看我是怎么打包的吧！&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;GitHub 项目地址：&lt;a href=&#34;https://github.com/luochang212/hit-and-blow&#34; target=&#34;_blank&#34;&gt;hit-and-blow&lt;/a&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;官方教程：&lt;a href=&#34;https://packaging.python.org/en/latest/tutorials/packaging-projects/&#34;&gt;Packaging Python Projects&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;背景知识：&lt;a href=&#34;https://docs.python.org/3/tutorial/modules.html#packages&#34;&gt;Modules&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;一文件结构介绍&#34;&gt;一、文件结构介绍&lt;/h3&gt;&#xA;&lt;p&gt;打包前，需构建如下文件结构：&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;packaging_tutorial/&#xA;├── LICENSE&#xA;├── pyproject.toml&#xA;├── README.md&#xA;├── src/&#xA;│   └── YOUR_PACKAGE_NAME/&#xA;│       ├── __init__.py&#xA;│       └── example.py&#xA;└── tests/&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;各个 &lt;code&gt;文件&lt;/code&gt; / &lt;code&gt;文件夹&lt;/code&gt; 说明：&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;packaging_tutorial&lt;/code&gt;: 项目文件夹&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;LICENSE&lt;/code&gt;: 开源协议，可由 GitHub 生成&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;pyproject.toml&lt;/code&gt;: 打包配置文件&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;README.md&lt;/code&gt;: 项目文档&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;src&lt;/code&gt;: 项目结构要求的，用来放主程序&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;YOUR_PACKAGE_NAME&lt;/code&gt;: 主程序文件夹，以“你的包名”命名文件夹&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;二添加配置文件&#34;&gt;二、添加配置文件&lt;/h3&gt;&#xA;&lt;p&gt;将以下内容修改一下，改改名字邮箱什么的，存成配置文件 &lt;code&gt;pyproject.toml&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;[build-system]&#xA;requires = [&amp;#34;hatchling&amp;#34;]&#xA;build-backend = &amp;#34;hatchling.build&amp;#34;&#xA;&#xA;[project]&#xA;name = &amp;#34;example_package_YOUR_USERNAME_HERE&amp;#34;&#xA;version = &amp;#34;0.0.1&amp;#34;&#xA;authors = [&#xA;  { name=&amp;#34;Example Author&amp;#34;, email=&amp;#34;author@example.com&amp;#34; },&#xA;]&#xA;description = &amp;#34;A small example package&amp;#34;&#xA;readme = &amp;#34;README.md&amp;#34;&#xA;requires-python = &amp;#34;&amp;gt;=3.7&amp;#34;&#xA;classifiers = [&#xA;    &amp;#34;Programming Language :: Python :: 3&amp;#34;,&#xA;    &amp;#34;License :: OSI Approved :: MIT License&amp;#34;,&#xA;    &amp;#34;Operating System :: OS Independent&amp;#34;,&#xA;]&#xA;&#xA;[project.urls]&#xA;&amp;#34;Homepage&amp;#34; = &amp;#34;https://github.com/pypa/sampleproject&amp;#34;&#xA;&amp;#34;Bug Tracker&amp;#34; = &amp;#34;https://github.com/pypa/sampleproject/issues&amp;#34;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;三打包&#34;&gt;三、打包&lt;/h3&gt;&#xA;&lt;h4 id=&#34;31-准备打包环境&#34;&gt;3.1 准备打包环境&lt;/h4&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;python3 -m pip install --upgrade pip&#xA;python3 -m pip install --upgrade build&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h4 id=&#34;32-打包&#34;&gt;3.2 打包&lt;/h4&gt;&#xA;&lt;p&gt;来到 &lt;code&gt;pyproject.toml&lt;/code&gt; 所在目录，打开命令行，运行代码：&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
