Let's see a simple example of distutils. We'll create a basic setup.py installation script for the palindrome module we wrote in the Chapter 11, Debugging with PDB.
The first thing we want to do is to create a directory to hold our project. Let's call this palindrome:
$ mkdir palindrome
$ cd palindrome
Let's put a copy of our palindrome.py in this directory:
"""palindrome.py - Detect palindromic integers"""
import unittest
def digits(x):
"""Convert an integer into a list of digits.
Args:
x: The number whose digits we want.
Returns: A list of the digits, in order, of ``x``.
>>> digits(4586378)
[4, 5, 8, 6, 3, 7, 8]
"""
digs = []
while x != 0:
div, mod = divmod(x, 10)
digs.append(mod)
x = div
return digs...