Publishing a Package on PyPI
Posted on 31 Oct, 2019
I just published my first package on pypi 😍 I used the following steps to do it :
Put your python files/classes inside the folder
package-name
.Also make sure your main class file has the same namepackage-name
.Add the
__init__.py
file in the same folder. Use the init file like this.pythonfrom coderunner.coderunner import Run
Now make a file
setup.py
inside the root of your github folder. Add the following contents in it:
python
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="plagcheck",
version="0.1",
author="Bhupesh Varshney",
author_email="varshneybhupesh@gmail.com",
description="A Powerful Moss results scrapper",
keywords='mosspy moss plagiarism cheat',
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/codeclassroom/PlagCheck",
project_urls={
"Documentation": "https://github.com/codeclassroom/PlagCheck/blob/master/docs/docs.md",
"Source Code": "https://github.com/codeclassroom/PlagCheck",
"Funding": "https://www.patreon.com/bePatron?u=18082750",
"Say Thanks!": "https://github.com/codeclassroom/PlagCheck/issues/new?assignees=&labels=&template=---say-thank-you.md&title=",
},
packages=setuptools.find_packages(),
install_requires=[
'requests',
'mosspy',
'beautifulsoup4',
'lxml',
],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
'Topic :: Software Development :: Build Tools',
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
- Now make a file
setup.cfg
. It is used for displaying project description on PyPI.
txt
[metadata]
description-file = README.md
- Install the followig libraries.
bash
pip3 install setuptools wheel twine
- Run the following command.
bash
python3 setup.py sdist bdist_wheel
- Finally upload it to PyPI.
bash
twine upload dist/*
This will prompt for your PyPi username and password.