Search code examples
pythonpypi

Unable to get module to publish correctly with PyPi


I'm attempting to publish my module to PyPi but I'm running into troubles. It publishes, and I can install it via Pip, but I cannot seem to figure out the correct import statement to instantiate my class.

This is my setup.py file, the code lives in discord_webhooks.py within the same directory. 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='[email protected]',
      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'
      ],
    )

I've attempted import DiscordWebhooks, and from discord_webhooks import DiscordWebhooks after doing pip install discord-webhooks but neither seem to work. Any help would be appreciated!


Solution

  • Managed to solve this one on my own. As this is a single file module I need to use py_modules inside of the setup.py file.

    Here's the updated file:

    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='[email protected]',
      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',
      ],
    )