packaging - How can I create a Package for a single Python file? -
i'm experimenting python packages. have tiny project share people. project consists of 1 python file, thought should not difficult create python package it.
i've managed register project following setup.py @ pypi:
from setuptools import setup setup( name='lumixmaptool', version='1.0.4', author='martin thoma', author_email='info@martin-thoma.de', packages=['lumix-maptool'], scripts=['lumix-maptool/lumix-maptool.py'], url='http://pypi.python.org/pypi/lumixmaptool/', license='license', description='manage gps information panasonic lumix cameras.', long_description="""panasonic offers gps metadata add sd card. metadata can contain tourist information might useful sightseeing. maptool helps copy data lumix dvd sd card inserted computer (the camera has not connected).""", install_requires=[ "argparse >= 1.2.1", "pyparsing >= 2.0.1", "pyparsing >= 2.0.1", ], entry_points={ 'console_scripts': ['lumixmaptool = lumixmaptool:main'] } )
with command
python setup.py register
and later updated with
python setup.py sdist upload
now it's here: https://pypi.python.org/pypi/lumixmaptool
but have problems following entries:
packages
scripts
entry_points
what have fill in there? have have project structure / files?
i have:
- readme.txt
- license.txt
- setup.py
- lumix-maptool.py
the projects github site here: https://github.com/martinthoma/lumix_map_tool
every package on pypi needs have file called setup.py
@ root of directory. if your’e using markdown-formatted read me file you’ll need setup.cfg
file. also, you’ll want license.txt
file describing can done code. if i’ve been working on library called mypackage
, directory structure this:
root-dir/ # arbitrary working directory name setup.py setup.cfg license.txt readme.md mypackage/ __init__.py foo.py bar.py baz.py
refer link know more packaging.
- entry point
entrypoints provide persistent, filesystem-based object name registration , name-based direct object import mechanism (implemented setuptools package).
they associate names of python objects free-form identifiers. other code using same python installation , knowing identifier can access object associated name, no matter object defined. associated names can names existing in python module; example name of class, function or variable. entry point mechanism not care name refers to, long importable.
an "entry point" typically function (or other callable function-like object) developer or user of python package might want use, though non-callable object can supplied entry point (as correctly pointed out in comments!).
the popular kind of entry point "console_script" entry point, points function want made available command-line tool whoever installs package.
- packages
packages used include python packages present in root-dir. can use find_packages()
.
for simple projects, it's easy enough manually add packages packages argument of setup(). however, large projects (twisted, peak, zope, chandler, etc.), can big burden keep package list updated. that's setuptools.find_packages()
for. refer docs.
- scripts
refer docs scripts.
Comments
Post a Comment