无法获取模块以使用PyPi正确发布

时间:2018-11-09 15:12:59

标签: python pypi

我正在尝试将我的模块发布到PyPi,但是遇到了麻烦。它可以发布,并且可以通过Pip进行安装,但是似乎无法找出正确的import语句来实例化我的类。

这是我的setup.py文件,代码位于同一目录的discord_webhooks.py中。 Here's the published package

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 DiscordWebhookspip install discord-webhooks,但是似乎都没有用。任何帮助,将不胜感激!

1 个答案:

答案 0 :(得分:1)

设法自己解决这个问题。由于这是一个文件模块,因此我需要在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',
  ],
)