Introduction
suggest changeA package needs metadata such as its name and version. Current projects usually put that in pyproject.toml. The setup.py file below is the older setuptools form. distutils was removed from the standard library, so that file imports setuptools.
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'], # modules that installing this package provides
)
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
python setup.py install is deprecated. From this directory, pip install . is the current install command. The transcript above was not re-run.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents