Friday, 30 January 2015

Python package installation - Unknown distribution option: 'include_package_data', 'zip_safe' etc

Packaging a python application is always tricky! The reasons are historical (setuptools vs distribute issues) and there is lot of material available on the internet to confuse you...

Anyway, I also got fumbled in packaging a python application and encountered the following error:

psj@psj-desktop:~/Downloads/nsrl$ python setup.py --help-commands
/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'include_package_data'
  warnings.warn(msg)
/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'zip_safe'
  warnings.warn(msg)
/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
Standard commands:
  build            build everything needed to install
  build_py         "build" pure Python modules (copy to build directory)
  build_ext        build C/C++ extensions (compile/link to build directory)
  build_clib       build C/C++ libraries used by Python extensions
  build_scripts    "build" scripts (copy and fixup #! line)
  clean            clean up temporary files from 'build' command
  install          install everything from build directory
  install_lib      install all Python modules (extensions and pure Python)
  install_headers  install C/C++ header files
  install_scripts  install scripts (Python or otherwise)
  install_data     install data files
  sdist            create a source distribution (tarball, zip file, etc.)
  register         register the distribution with the Python package index
  bdist            create a built (binary) distribution
  bdist_dumb       create a "dumb" built distribution
  bdist_rpm        create an RPM distribution
  bdist_wininst    create an executable installer for MS Windows
  upload           upload binary package to PyPI

After google searches, this error means that setuptools package is missing or is not at right location.

To get rid of this error, do this:

psj@psj-desktop:~ wget http://bootstrap.pypa.io/ez_setup.py -O - | sudo python
....
Processing setuptools-3.3-py2.6.egg
Copying setuptools-3.3-py2.6.egg to /usr/local/lib/python2.6/dist-packages
Adding setuptools 3.3 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.6 script to /usr/local/bin

Installed /usr/local/lib/python2.6/dist-packages/setuptools-3.3-py2.6.egg
Processing dependencies for setuptools==3.3
Finished processing dependencies for setuptools==3.3

After this, the problem disappeared.

psj@psj-desktop:~/Downloads/nsrl$ python setup.py --help-commands
Standard commands:
  build             build everything needed to install
  build_py          "build" pure Python modules (copy to build directory)
  build_ext         build C/C++ extensions (compile/link to build directory)
  build_clib        build C/C++ libraries used by Python extensions
  build_scripts     "build" scripts (copy and fixup #! line)
  clean             clean up temporary files from 'build' command


Python packaging links that I referred:

  1. http://www.jeffknupp.com/blog/2013/08/16/open-sourcing-a-python-project-the-right-way/
  2. https://www.digitalocean.com/community/tutorials/how-to-package-and-distribute-python-applications
  3. https://packaging.python.org/en/latest/
  4. http://www.scotttorborg.com/python-packaging/
  5. http://pythonhosted.org/setuptools/setuptools.html#including-data-files
  6. http://gehrcke.de/2014/02/distributing-a-python-command-line-application/
  7. https://parijatmishra.wordpress.com/2008/10/08/python-packaging-setuptools-and-eggs/


1 comment: