Skip to content

Publish your own project on PyPi

Written by

Nauxniqnah

Sign up for a PyPi account

Create an account · PyPI

Create a python project

To publish a project, you have to have a project of your own. We put the code in a folder like this:

This is a folder called ‘loleventdata’, and loleventdata.py is the main code of this project. The init file is required. This is the symbol of a package. You can write nothing, but you must have it.

Build a setup.py file

This file is for packaging, and the content is like this:

#!/usr/bin/env python
#-*- coding:utf-8 -*-

#############################################
# File Name: setup.py
# Author: HanQinXuan
# Mail: han981130@gmail.com
# Website: han1st.com
# Created Time:  2018-1-23 19:17:34
#############################################

from setuptools import setup, find_packages
import sys
import os

setup(
    name="loleventdata",
    version="0.2.0",
    keywords=("pip", "python", "lol", "wanplus", "api", "crawler"),
    description="team data & player data",
    long_description="team data & player data",
    license="MIT Licence",

    url="https://github.com/HanQinXuan/lol_data_api",
    author="HanQinXuan",
    author_email="han981130@gmail.com",

    packages = find_packages(),
    include_package_data = True,
    platforms = "any",
    install_requires = ["requests"]          
)

This setup.py needs to be placed in the same level directory as the ‘loleventdata’ folder.

Package project files

On the command line, use CD command to find the setup.py Then use the following command:

python setup.py sdist  

This command will generate two folders in the current directory to save all the information related to the project.

Upload project to PyPi server

Download an upload tool using pip:

pip install twine

Upload packaged projects:

twine upload dist/loleventdata-0.1.0.tar.gz

Previous article

PyPi Tsinghua source

Next article

Ajax data crawling

Join the discussion

Leave a Reply

Your email address will not be published. Required fields are marked *