summaryrefslogtreecommitdiff
path: root/python/which/setup.py
blob: 3f6d1072c9cc39d9c1e63c0393082b59000f9654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# Copyright (c) 2002-2005 ActiveState Corp.
# Author: Trent Mick (TrentM@ActiveState.com)

"""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
    else:
        bindir = os.path.join(sys.prefix, "bin")
    return bindir


#---- setup mainline

if sys.platform == "win32":
    scripts = []
    binFiles = ["which.exe", "which.py"]
else:
    #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.py", "which")
    #scripts = ["which"]
    binFiles = []
    scripts = []

setup(name="which",
      version=_getVersion(),
      description="a portable GNU which replacement",
      author="Trent Mick",
      author_email="TrentM@ActiveState.com",
      url="http://trentm.com/projects/which/",
      license="MIT License",
      platforms=["Windows", "Linux", "Mac OS X", "Unix"],
      long_description="""\
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"],

      py_modules=['which'],
      scripts=scripts,
      # 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) ],
     )