Archive

Posts Tagged ‘setup.py’

python setup.py uninstall

November 2, 2014 Leave a comment

Problem
Sometimes you need to install a software with “python setup.py install“. However, if you want to get rid of it, there is no “python setup.py uninstall” or “python setup.py remove”. Stupid, but true.

Solution
I found the solution here. In short:

# install:
$ (sudo) python setup.py install

# uninstall:
$ pip freeze | grep PATTERN_BASED_ON_PACKAGE_NAME
# then remove with pip:
$ (sudo) pip uninstall PACKAGE_NAME
Categories: python Tags: , ,

Upload your first project to PyPI

January 25, 2012 Leave a comment

Today I uploaded my jabbapylib project to PyPI, available here.

For preparing my first public pypi project, I followed this tutorial. For understanding how to package a Python library, read Mark Pilgrim’s corresponding book chapter.

I only want to add the following remarks:

  1. In setup.py, I import “from setuptools import setup, find_packages“. Notice setuptools instead of distutils.core.
  2. In the prepared package I wanted to include the library jabbapylib/ recursively since all the source codes are there. I could do that with this line: “packages = find_packages(exclude=['demos', 'dist', 'tests'])“, i.e. include all subdirectories with the exception of the ones in the list. What remains in my case is the “jabbapylib” folder.
  3. My library has some dependencies, they are specified here: “install_requires=['html5lib', 'psutil', 'pytest']“. When jabbapylib is installed with pip, pip will install these packages too.
  4. You can create your own MANIFEST.in file to specify what to include and what to exclude. However, if you want to add the directory that contains all the sources, do as indicated in step (2).
  5. For checking, packaging and uploading I made some simple scripts.