forked from mvz/vb2py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
85 lines (72 loc) · 2.84 KB
/
setup.py
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
"""Install vb2Py
Much of the following code is copied from the PythonCard installation script
because the original setup.py would copy files to all sorts of weird location
on Linux.
You must run this to create the setup distribution from the site-packages!
"""
WIN_DEFAULT_COMMAND = "install"
APPLICATION_NAME = "vb2py"
from distutils.core import setup
from distutils.command.install_data import install_data
import glob, os, sys
if len(sys.argv) == 1 and sys.platform.startswith("win"):
sys.argv.append(WIN_DEFAULT_COMMAND)
"""
This script is setup.py of the vb2py package.
"""
class smart_install_data(install_data):
def run(self):
#need to change self.install_dir to the actual library dir
install_cmd = self.get_finalized_command('install')
self.install_dir = getattr(install_cmd, 'install_lib')
return install_data.run(self)
def recurseDir(startDir):
# This should all be replaced by calls to os.path.walk, but later
listX=[startDir]
for fyle in os.listdir(startDir):
file=os.path.join(startDir,fyle)
if os.path.isdir(file) and fyle != '.git':
listX.extend(recurseDir(file))
return listX
def makeDataDirs(rootDir=APPLICATION_NAME, dataDirs=[]):
"Construct a list of the data directories to be included"
# This function will return a list of tuples, each tuple being of the form;
# ( <target_directory_name>, [<list_of_files>] )
listX=[]
results=[]
for directory in dataDirs:
directories=recurseDir(directory)
results.extend(directories)
for directory in results:
# Add this directory and its contents to list
files=[]
for file in os.listdir(directory):
if file!='CVS' and file!='.cvsignore' and os.path.splitext(file)[1].lower() <> ".htm":
if os.path.isfile(os.path.join(directory, file)):
files.append(os.path.join(directory, file))
listX.append((rootDir+'/'+directory, files))
# list.append((rootDir, 'stc_styles.cfg'))
return listX
data_files = makeDataDirs(dataDirs=["./targets", "./test", "./doc", "./vb"])
data_files.append((APPLICATION_NAME, ['vb2py.ini', 'vbgrammar.txt']))
setup(name=APPLICATION_NAME,
version="0.2.3",
description="Visual Basic to Python Converter",
author="Paul Paterson",
author_email="[email protected]",
url="http://vb2py.sourceforge.net",
packages = [
"vb2py",
"vb2py.custom",
"vb2py.plugins",
"vb2py.targets",
"vb2py.targets.pythoncard",
"vb2py.targets.pythoncard.vbcontrols",
"vb2py.targets.tkinter",
],
package_dir = { APPLICATION_NAME: './vb2py' },
license="BSD",
cmdclass = { 'install_data': smart_install_data},
data_files = data_files,
scripts = ['bin/vb2py'],
)