在项目的根目录里创建setup.py
# -*- coding: utf-8 -*- # author:navysummer # email:navysummer@yeah.net import shutil import setuptools from setuptools.command.install_scripts import install_scripts __version__ = "0.0.0" with open("README.md", "r") as fh: long_description = fh.read() class InstallScripts(install_scripts): def run(self): setuptools.command.install_scripts.install_scripts.run(self) # Rename some script files for script in self.get_outputs(): if script.endswith(".py"): dest = script[:-3] shutil.copy(script, dest) setuptools.setup( # 包名 name="navysummer", # 包的版本号 version=__version__, # 包的作者 author="navysummer", # 包的作者的邮箱 author_email="navysummer@yeah.net", # 包的描述 description="navysummer", # 包的详细描述 long_description=long_description, # 包的详细描述内容的类型 long_description_content_type="text/markdown", # 项目的地址 url="https://github.com/navysummer", # 自动搜索项目目录里的包文件 packages=setuptools.find_packages(), # 程序分类信息 classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], # python版本要求 python_requires='>=3.6', # 运行的平台 platforms='any', # 项目依赖,会在安装包的同时安装包的依赖 install_requires=[], # 可执行脚本 scripts=['bin/navysummer.py'], # 可执行文件类处理器 cmdclass={ "install_scripts": InstallScripts } ) """ 1、打包流程 打包过程中也可以多增加一些额外的操作,减少上传中的错误 # 先升级打包工具 pip install --upgrade setuptools wheel twine # 打包 python setup.py sdist bdist_wheel # 检查 twine check dist/* # 上传pypi twine upload dist/* # 安装最新的版本测试 pip install -U lesscode-py -i https://pypi.org/simple """
标签:指南,setuptools,script,python,navysummer,py,install,scripts,打包 From: https://www.cnblogs.com/navysummer/p/16950748.html