Every package requires a [setup.py](<https://docs.python.org/3/distutils/setupscript.html#writing-the-setup-script>)
file which describes the package.
Consider the following directory structure for a simple package:
+-- package_name
| |
| +-- __init__.py
|
+-- setup.py
The __init__.py
contains only the line def foo(): return 100
.
The following setup.py
will define the package:
from setuptools import setup
setup(
name=‘package\\_name’, # package name
version=‘0.1’, # version
description=‘Package Description’, # short description
url=‘<http://example.com>’, # package URL
install\\_requires=\\[\\], # list of packages this package depends
# on.
packages=\\[‘package\\_name’\\], # List of module names that installing
# this package will provide.
)
virtualenv is great to test package installs without modifying your other Python environments:
$ virtualenv .virtualenv
...
$ source .virtualenv/bin/activate
$ python setup.py install
running install
...
Installed .../package_name-0.1-....egg
...
$ python
>>> import package_name
>>> package_name.foo()
100