[go: up one dir, main page]

Menu

[r560]: / trunk / setup.py  Maximize  Restore  History

Download this file

161 lines (133 with data), 5.8 kB

  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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
"""
Python distutils setup.py script:
Usage:
------
Install as a python package.
$ python setup.py install
Other supported modes:
----------------------
Make source distribution (zip file for ease on windows and linux.)
$ python setup.py sdist --format=zip
Make windows installer
$ python setup.py bdist_wininst --install-script ptk_postinstall.py --user-access-control auto
Make a wheel
$ python setup.py sdist bdist_wheel
Other distutils modes are currently unsupported.
"""
import setuptools
from distutils.core import setup
import os
import shutil
import os.path
import sys
import ptk_lib
#-------------------------------------------------------------------------------
# Helper functions
#-------------------------------------------------------------------------------
def is_package(path):
return (
os.path.isdir(path) and
os.path.isfile(os.path.join(path, '__init__.py'))
)
def find_packages(path, base="" ):
""" Find all packages in path """
packages = {}
for item in os.listdir(path):
dir = os.path.join(path, item)
if is_package( dir ):
if base:
module_name = "%(base)s.%(item)s" % vars()
else:
module_name = item
packages[module_name] = dir
packages.update(find_packages(dir, module_name))
return packages
#-------------------------------------------------------------------------------
# Determine mode of operation and set scripts and package data to use
#-------------------------------------------------------------------------------
if sys.argv[1] == 'sdist':
#building a source distribution add everything...
SCRIPTS = ['PTK.pyw','PTKengine.pyw','windows/ptk_postinstall.py']
PACKAGE_DATA = {'ptk_lib': ['resources/tips.txt',
'resources/ptk.ico',
'resources/ptkicon.svg']}
DATA_FILES =[
('.',[ 'README.txt','LICENSE.txt','CHANGES.txt']),
('.', ['linux/PTK.desktop']),
]
elif sys.argv[1] == 'bdist_wininst':
#building a windows installer
SCRIPTS = ['PTK.pyw','PTKengine.pyw','windows/ptk_postinstall.py']
PACKAGE_DATA = {'ptk_lib': ['resources/tips.txt',
'resources/ptk.ico',
'resources/ptkicon.svg']}
DATA_FILES = []
elif sys.argv[1] == 'install':
if sys.platform.startswith('win'):
#installing on windows
SCRIPTS = ['PTK.pyw','PTKengine.pyw','windows/ptk_postinstall.py']
PACKAGE_DATA = {'ptk_lib': ['resources/tips.txt',
'resources/ptk.ico',
'resources/ptkicon.svg']}
DATA_FILES = []
elif sys.platform.startswith('darwin'):
#On linux/mac we want to be able to type PTK to start the app using PTK
#so make a copy and use that as the script
shutil.copyfile('PTK.pyw', 'PTK')
shutil.copyfile('PTKengine.pyw', 'PTKengine')
SCRIPTS = ['PTK','PTKengine']
PACKAGE_DATA = {'ptk_lib': ['resources/tips.txt',
'resources/ptk.ico',
'resources/ptkicon.svg']}
DATA_FILES = [ ]
#TODO add mac launch script??? where does this go on a mac?
else:
#On linux/mac we want to be able to type PTK to start the app using PTK
#so make a copy and use that as the script
shutil.copyfile('PTK.pyw', 'PTK')
shutil.copyfile('PTKengine.pyw', 'PTKengine')
SCRIPTS = ['PTK','PTKengine']
PACKAGE_DATA = {'ptk_lib': ['resources/tips.txt',
'resources/ptk.ico',
'resources/ptkicon.svg']}
DATA_FILES = [ ( '/usr/share/applications', ['linux/PTK.desktop'] ),
( '/usr/share/pixmaps', ['ptk_lib/resources/ptkicon.svg']) ]
else:
#unkown do everything
SCRIPTS = ['PTK.pyw','PTKengine.pyw','windows/ptk_postinstall.py']
PACKAGE_DATA = {'ptk_lib': ['resources/tips.txt',
'resources/ptk.ico',
'resources/ptkicon.svg']}
DATA_FILES =[
('.',[ 'README.txt','LICENSE.txt','CHANGES.txt']),
('.', ['linux/PTK.desktop']),
]
#-------------------------------------------------------------------------------
# Collect data for the distutils setup() call.
#-------------------------------------------------------------------------------
VERSION = ptk_lib.VERSION
DESCRIP = "PythonToolkit (PTK) an interactive python environment"
LONG_DESCRIP = """PythonToolkit (PTK) is an interactive environment for python.
It was designed to provide a python based environment similiar to Matlab
for scientists and engineers however it can also be used as a general
purpose interactive python environment."""
#Find packages to install
PACKAGES = find_packages(path='.', base="" )
#-------------------------------------------------------------------------------
#Do the python distutils setup
#-------------------------------------------------------------------------------
setup(
name = 'PythonToolkit',
version = VERSION,
description = DESCRIP,
long_description = LONG_DESCRIP,
author = 'T.Charrett',
author_email = 'tohc1@users.sourceforge.net',
url = "http://pythontoolkit.sourceforge.net",
packages = PACKAGES,
classifiers=(
"Programming Language :: Python :: 2.7",
"License :: OSI Approved :: GNU General Public License (GPL)"),
scripts = SCRIPTS,
package_data = PACKAGE_DATA,
data_files = DATA_FILES)