author Gregory Szorc <>
Thu, 20 Sep 2012 20:54:46 -0700
changeset 111304 88a1e8e2df95185d41e414ff6b95b61e07105cc0
permissions -rw-r--r--
Bug 792135 - Part 1: Add which Python package; r=glandium Version 1.1.0 obtained from and added to tree without modifications aside from the removal of which.exe, which has no reason to be in the tree.

#!/usr/bin/env python
# Copyright (c) 2002-2005 ActiveState Corp.
# Author: Trent Mick (

"""Distutils setup script for 'which'."""

import sys
import os
import shutil
from distutils.core import setup

#---- support routines

def _getVersion():
    import which
    return which.__version__

def _getBinDir():
    """Return the current Python's bindir."""
    if sys.platform.startswith("win"):
        bindir = sys.prefix
        bindir = os.path.join(sys.prefix, "bin")
    return bindir

#---- setup mainline

if sys.platform == "win32":
    scripts = []
    binFiles = ["which.exe", ""]
    #XXX Disable installing which as a script on non-Windows platforms.
    #    It can get in the way of the system which.
    #if os.path.exists("which"):
    #    os.remove("which")
    #shutil.copy2("", "which")
    #scripts = ["which"]
    binFiles = []
    scripts = []

      description="a portable GNU which replacement",
      author="Trent Mick",
      license="MIT License",
      platforms=["Windows", "Linux", "Mac OS X", "Unix"],
This is a GNU which replacement with the following features:
    - it is portable (Windows, Linux);
    - it understands PATHEXT on Windows;
    - it can print <em>all</em> matches on the PATH;
    - it can note "near misses" on the PATH (e.g. files that match but
      may not, say, have execute permissions; and
    - it can be used as a Python module.
      keywords=["which", "find", "path", "where"],

      # Install the Windows script/executable bits as data files with
      # distutils chosen scripts install dir on Windows,
      # "<prefix>/Scripts", is just wrong.
      data_files=[ (_getBinDir(), binFiles) ],