In this post, I document the full procedure for turning a personal Python project into a public package, available on both GitHub and the Python Package Index (PyPI).
As a demonstration, I create a small package named PalAniSh (Palette of Animation of Shanghai), which extracts and displays color palettes from classical Chinese animations produced by the Shanghai Animation Film Studio.
1. Color Palette generation
Herein, I will use some of the screenshots from the Chinese traditional animations, e.g., the 1956 animation _The Proud General (骄傲的将军). All raw images as source of color palette were derived from Bilibili.
The extraction and combination of colors were similar to the web-based tool Adobe color or Colormind (http://colormind.io/image).
Below is the core workflow:
1 | from PIL import Image |
Example output
1 | input_name = './SA_palette/九色鹿/九色鹿9.jpg' |
Other examples are shown as follows
2. Packaging the Code and Uploading to GitHub
Usually, a package will have such structure:
1 | palanish/ |
First step, add the folder of palanish
as previous listed and add the main function into the color_extractor.py
.
Later, within the __init__.py
, add following line:
1 | from .color_extractor import get_color_palette, hex_sort |
Then, write the script of the setup.py
as follows:
1 | from setuptools import setup, find_packages |
As well as writing a small README.md,
1 | # PalAniSh |
The final step is uploading to Github
1 | cd palanish |
After all steps done, anyone can install via:
1 | pip install git+https://github.com/envhyf/palanish.git |
3. Web app
With
Comments