Package: demo-package-python
DEMO-PACKAGE-PYTHONThis sample package follows the instructions
for publishing a Python package in PyPI.This repository can be used as a template for building packages.
See sectionReusing as Templatefor more info on how.OutlineThisREADME.mdfile is organized as follows:OutlineFull InstructionsSummarized/Compact InstructionsCode StructureDemo Package Installation InstructionsReusing as TemplateAdding Additional FilesFull InstructionsFull instructions for publishing a Python package using
PyPI can be found here:https://packaging.python.org/en/latest/tutorials/packaging-projects/I made atinyurl.comshort-link for the
tutorial link above:https://tinyurl.com/how-to-package-pythonIf you want, you can include the links above in your bookmarks.Summarized/Compact InstructionsIn summary, the instructions can be divided into the outline below
if you don't feel like clicking the tutorial link again and again.Full instructions can be found in the tutorials above in case
the summary doesn't still help in recalling the procedures.Creating a packageCreate package files (see code structure below for an example)Createtests/directoryCreatepyproject.tomlwith the necessary[build-system],[project], and[project.urls]optionsConfigure metadata of project. Common metadata are shown below. For a more thorough example, seepyproject.tomlnameversionauthors (must be in array format)descriptionreadmelicenserequires-pythonclassifiersCreateREADME.mdfileCreateLICENSEfileGenerating distribution archivesStep 1: Installbuildpackagepython3 -m pip install --upgrade build`Step 2: Runpython3 -m buildon the first build and successive build updates for different versions.Generates adist/folder for the built packagePuts a.whland.tar.gzfile in the dist folder for the current version.Uploading the distribution archivesInstalltwine, a tool for uploading packages to different package indices.python3 -m pip install --upgrade twineUpload archives underdistpython3 -m twine upload --repository testpypi dist/*Code Structuredemo-package-pythondist/# distribution filesenv/# virtual environment for the packagescripts/# scriptsbuild_pyproject_toml.py# build pyproject_toml.pysrc/# source files for the packagetests/# tests for the packagemain.pyutils/build.sh# shell script for building packagepublish.sh# shell script for publishing packagesetup.sh# shell script for setting up packageLICENSE# MIT Licensepyproject.dev.toml# project configurationpyproject.toml# built project configurationrequirements.txt# requirements list generated by pip freezeDemo Package Installation InstructionsThe demo package has a simple API of 3 functions..say_hello_world().say_hi(name).random_rainbow_color()- uses thefakerpackageTo use this package:pip install demo_package_pythonThen:importdemo_package_pythonasdemo_packageprint(".sayHello() => "+demo_package.say_hello_world())print(".sayHi('John') => "+demo_package.say_hi('John'))print(".randomRainbowColor() => "+demo_package.random_rainbow_color())It should return the following:.say_hello() => Hello, World! 
.say_hi('John') => Hi, John!
.random_rainbow_color() => blueReusing as TemplateIf you intend to reuse this package as a template for future package projects, use the following command:Clone the projectgit clone https://gitlab.com/demo-package/demo-package-python.git [your_project]Go to your project directorycd [your_project]Editpyproject.dev.tomlto match your project description.Make sure to edit the right file, you might accidentally
editpyproject.tomlinstead.The filepyproject.tomlis
automatically built frompyproject.dev.tomlby adding the dependencies list
inrequirements.txtbefore building.Remove contents ofsrc/demo_package_pythonrm -rf src/demo_package_python/*Create__init__.pyinsrc/demo_package_pythontouch src/demo_package_python/__init__.pyRenamesrc/demo_package_pythontosrc/[your_project_name]mv src/demo_package_python src/[your_package_name]Make sure that your havevirtualenvinstalled and then run the followingvirtualenv envorpython3 -m venv envActivate virtual environmentsource env/bin/activateMake sure that the virtual environment is activated
before running the succeeding commands.Run from the command line:bash utils/setup.shThis command should install the packages on theenv/folder and not on the default location.Use the following commands to simplify building and publishing routines:Make sure to run the following commands in the virtual environment mode by runningsource env/bin/activateif you haven't yet.To Build Projectbash utils/build.shTo Publish Projectbash utils/publish.sh