Custom Python Packaging

Published on 2020-08-25 by Ashok Be

Sandbox to try ThinkPy2 code

In https://github.com/kgisl/pythonFDP, in the /sandbox directory, in your code, or in IDLE prompt, do this:

>> from thinkpy2.has_duplicates import *
>> has_duplicates([1, 2, 3, 1])
True

How it was created

  1. This was created by following the instructions on https://j.mp/stepsPackage

  2. After Steps 1-4:

/sandbox
    /thinkpy2
        __init__.py
        # module files
    setup.py
  1. Added to setup.py
from setuptools import setup

setup(name='sandbox',
      packages=['thinkpy2'],
      )
  1. created a sample some_code.py with test_fun code in it.

Or even better, just skip all the above steps and simply use the script make_my_package.py

usage: python3 make_my_package.py <your_package_name>
  1. At the level of the /sandbox directory, type:

    pip3 install -e .

That's it! You are all set!

Show comments