python - 无法使用 PyPi 正确发布模块
问题描述
我正在尝试将我的模块发布到 PyPi,但我遇到了麻烦。它发布,我可以通过 Pip 安装它,但我似乎无法找出正确的导入语句来实例化我的类。
这是我的setup.py
文件,代码位于discord_webhooks.py
同一目录中。这是已发布的包。
from setuptools import setup, find_packages
long_description = open('README.md').read()
setup(
name='Discord Webhooks',
version='1.0.1',
packages=find_packages(exclude=['tests', 'tests.*']),
url='https://github.com/JamesIves/discord-webhooks',
author='James Ives',
author_email='iam@jamesiv.es',
description='Easy to use package for Python which allows for sending of webhooks to a Discord server.',
long_description=long_description,
license='MIT',
install_requires=[
'requests==2.20.0'
],
classifiers=[
'Programming Language :: Python :: 3'
],
)
我已经尝试过import DiscordWebhooks
,并且from discord_webhooks import DiscordWebhooks
在做了之后,pip install discord-webhooks
但似乎都没有工作。任何帮助,将不胜感激!
解决方案
我自己设法解决了这个问题。由于这是一个单文件模块,我需要py_modules
在文件内部使用setup.py
。
这是更新的文件:
from setuptools import setup, find_packages
long_description = open('README.md').read()
setup(
name='Discord Webhooks',
version='1.0.3',
py_modules=['discord_webhooks'],
url='https://github.com/JamesIves/discord-webhooks',
author='James Ives',
author_email='iam@jamesiv.es',
description='Easy to use package for Python which allows for sending of webhooks to a Discord server.',
long_description=long_description,
license='MIT',
install_requires=[
'requests==2.20.0'
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Other Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
],
)
推荐阅读
- c# - 如何将转义的 unicode 转换为常规格式的 unicode
- python - 打印功能重要性百分比
- django - Django jsonfield,是否可以使用json数组值长度进行过滤?
- python - 错误:找不到满足 pyautogui 要求的版本(来自版本:无)
- electron - 有没有办法在 Electron 应用程序包根目录中复制或创建文件夹?
- java - Springdoc 将安全性指定为打开
- java - 如何使用 bufferedreader 捕获 csv 文件中的字段值
- javascript - 如何使用现代 FileApi 在本地 fs 中创建文件?
- xamarin - Xamarin 在 Andriod 设备上使用黑色背景和白色二维码形成 Zxing 扫描问题
- linux - 根据命令行中同一行中的单词的条件更改另一个单词?