26/12/2017 permalink linked site
I upload python packages on pypi on a regular basis since a few years. Since today, i never found anything helpful in the official packaging documentations.
Because there is plenty of it, and as soon as you start a real project, you somehow end up in a corner case that the doc covers, if ever, superficially.
And, today, i found consecutively (and unexpectedly) two things.
- This funny presentation (slides) from pycon.fr 2017, where many interesting tools are presented, after a very efficient explanation of
- The linked doc page, that is litterally the first packaging-related official documentation i found helpful.
One big change to me was the usage of
setup.cfg instead of
setup.py. (Not so) Surprisingly, it's much more efficient and easy ; and the py is now two lines long (see below for an example).
Just one caveat: you have to cheat a little if you want to install the requirements without passing by the complete setuptools machinery. Just put that line in your Makefiles or in your bash aliases, and you can forget about it.
I however one weird problem quickly,
since i followed the presentation blindly,
and therefore forgot to add few lines they didn't talk about.
The problem was, after installation in another repository of graffunc,
that any import of graffunc itself would fail with an
ImportError: No module named 'graffunc'.
So, here is my working
from setuptools import setup setup()
Which is quite simple and easy to maintain (i will probably reuse the very same for most of my projects, now).
And here is my working
setup.cfg for the graffunc package:
[metadata] name = graffunc version = 0.2.2 description = high level graph of function long_description = file: README.mkd url = https://github.com/aluriak/graffunc license = GPL keywords = graph, function, data structure classifiers = Development Status :: 2 - Pre-Alpha Intended Audience :: Science/Research License :: OSI Approved :: GNU General Public License (GPL) Natural Language :: English Programming Language :: Python :: 3 Programming Language :: Python :: 3.4 Topic :: Software Development :: Libraries :: Python Modules [options] zip_safe = False include_package_data = True packages = find: install_requires = pytest>=3.1.2 networkx==1.11
You will note the
[option] part, populated with one absolute line:
packages = find:, which allow python to look for your package and include it correctly.
Without that, you will encounter the
I would expect zest.releaser to detect and warn me about a so absurd error. But it didn't, and i'm so happy that i found the right doc page so quickly, i had to share :)