setup.py
author robin
Tue, 24 Aug 2021 11:27:45 +0100
changeset 95 ca1fbee6a03c
parent 92 0b0a17f9d877
child 104 e61305acbc68
permissions -rw-r--r--
fix DEFINE_MAXROS handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
     1
#!/usr/bin/env python
85
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
     2
#Copyright ReportLab Europe Ltd. 2000-2021
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
     3
#see license.txt for license details
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
     4
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/rl_addons/pyRXP/setup.py
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
     5
if __name__=='__main__': #NO RUNTESTS
85
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
     6
	import os, sys, re
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
     7
	pkgDir=os.path.dirname(sys.argv[0])
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
     8
	if not pkgDir:
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
     9
		pkgDir=os.getcwd()
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    10
	elif not os.path.isabs(pkgDir):
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    11
		pkgDir=os.path.abspath(pkgDir)
85
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    12
	#test to see if we've a special command
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    13
	if 'test' in sys.argv:
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    14
		if len(sys.argv)!=2:
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    15
			raise ValueError('test command may only be used alone sys.argv[1:]=%s' % repr(sys.argv[1:]))
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    16
		cmd = sys.argv[-1]
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    17
		os.chdir(os.path.join(pkgDir,'test'))
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    18
		r = os.system(' '.join((sys.executable, 'runAll.py')))
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    19
		sys.exit(('!!!!! runAll.py --> %s exited with error !!!!!' % r) if r else r)
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    20
	elif 'null-cmd' in sys.argv or 'null-command' in sys.argv:
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    21
		sys.exit(0)
75ebfe9feba5 switch to using cibuildwheel, make tests easier; version --> 2.2.2
robin
parents: 65
diff changeset
    22
40
cd23b3db03c5 setup.py: optional setuptools import
robin
parents: 22
diff changeset
    23
	try:
cd23b3db03c5 setup.py: optional setuptools import
robin
parents: 22
diff changeset
    24
		from setuptools import setup, Extension
cd23b3db03c5 setup.py: optional setuptools import
robin
parents: 22
diff changeset
    25
	except ImportError:
cd23b3db03c5 setup.py: optional setuptools import
robin
parents: 22
diff changeset
    26
		from distutils.core import setup, Extension
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    27
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    28
	def raiseConfigError(msg):
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    29
		import exceptions 
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    30
		class ConfigError(exceptions.Exception): 
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    31
			pass 
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    32
		raise ConfigError(msg)
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    33
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    34
	LIBS = []
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    35
	LIBRARIES=[]
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    36
	EXT_MODULES = []
49
054a847970b7 allow shorter compiles under python3.5 + VS2015
robin
parents: 40
diff changeset
    37
	EXT_KWARGS = {}
92
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    38
	DEFINE_MACROS=[('CHAR_SIZE', 16)]
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    39
	for ev in ('DEBUG_INPUT',):
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    40
		evv = os.environ.get(ev,'')
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    41
		try:
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    42
			evv = int(evv)
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    43
		except:
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    44
			pass
95
ca1fbee6a03c fix DEFINE_MAXROS handling
robin
parents: 92
diff changeset
    45
		else:
ca1fbee6a03c fix DEFINE_MAXROS handling
robin
parents: 92
diff changeset
    46
			if evv:
ca1fbee6a03c fix DEFINE_MAXROS handling
robin
parents: 92
diff changeset
    47
				DEFINE_MACROS.append((ev,evv))
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    48
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    49
	#building pyRXP
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    50
	if sys.platform=="win32":
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    51
		LIBS=['wsock32']
57
6f29c9811820 bah 3.5 windoze x64 went long
robin
parents: 56
diff changeset
    52
		if sys.version_info[:2]>=(3,5) and not int(os.environ.get('PYRXP35LONG','0')):
49
054a847970b7 allow shorter compiles under python3.5 + VS2015
robin
parents: 40
diff changeset
    53
			EXT_KWARGS['extra_compile_args'] = ['/Od']
054a847970b7 allow shorter compiles under python3.5 + VS2015
robin
parents: 40
diff changeset
    54
		#EXT_KWARGS['extra_compile_args'] = ['/Zi']
054a847970b7 allow shorter compiles under python3.5 + VS2015
robin
parents: 40
diff changeset
    55
		#EXT_KWARGS['extra_link_args'] = ['/DEBUG']
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    56
	elif sys.platform=="sunos5":
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    57
		LIBS=['nsl', 'socket', 'dl']
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    58
	elif sys.platform=="aix4":
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    59
		LIBS=['nsl_r', 'dl']
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    60
	else:
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    61
		LIBS=[]
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    62
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    63
	rxpFiles = ('xmlparser.c', 'url.c', 'charset.c', 'string16.c', 'ctype16.c', 
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    64
				'dtd.c', 'input.c', 'stdio16.c', 'system.c', 'hash.c', 
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    65
				'version.c', 'namespaces.c', 'http.c', 'nf16check.c', 'nf16data.c')
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    66
	pyRXPDir = os.path.join(pkgDir,'src')
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    67
	RXPLIBSOURCES=[]
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    68
	pyRXP_c = os.path.join(pyRXPDir,'pyRXP.c')
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    69
	VERSION = re.search(r'^#\s*define\s+VERSION\s*"([^"]+)"',open(pyRXP_c,'r').read(),re.MULTILINE)
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    70
	VERSION = VERSION and VERSION.group(1) or 'unknown'
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    71
	RXPDIR=os.path.join(pyRXPDir,'rxp')
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    72
	RXPLIBSOURCES= [os.path.join(RXPDIR,f) for f in rxpFiles]
17
b0a98a6ac6a2 create py33 branch and working python33 pyRXPU
robin
parents: 11
diff changeset
    73
	EXT_MODULES =	[Extension( 'pyRXPU',
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    74
								[pyRXP_c]+RXPLIBSOURCES,
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    75
								include_dirs=[RXPDIR],
92
0b0a17f9d877 add setup.py macro handling; fix test command and artifact name
robin
parents: 85
diff changeset
    76
								define_macros=DEFINE_MACROS,
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    77
								library_dirs=[],
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    78
								# libraries to link against
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    79
								libraries=LIBS,
50
1af7b5eec5f8 fix syntax error
robin
parents: 49
diff changeset
    80
								**EXT_KWARGS
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    81
								),
11
a0a1adbc7b13 move towards standard filesystem layout
rptlab
parents: 2
diff changeset
    82
					]
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    83
65
f4ed1dc7b03e fix license for modern pip
robin <robin@reportlab.com>
parents: 63
diff changeset
    84
	with open('LICENSE.txt','r') as _:
f4ed1dc7b03e fix license for modern pip
robin <robin@reportlab.com>
parents: 63
diff changeset
    85
		license = _.read()
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    86
	setup(	name = "pyRXP",
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    87
			version = VERSION,
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    88
			description = "Python RXP interface - fast validating XML parser",
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    89
			author = "Robin Becker",
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    90
			author_email = "robin@reportlab.com",
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    91
			url = "http://www.reportlab.com",
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    92
			packages = [],
65
f4ed1dc7b03e fix license for modern pip
robin <robin@reportlab.com>
parents: 63
diff changeset
    93
			license=open('LICENSE.txt','r').read(),
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    94
			ext_modules = EXT_MODULES,
63
9ee8c8d7cc04 added a LICENSE.txt version-->2.1.2
robin <robin@reportlab.com>
parents: 62
diff changeset
    95
			package_data = {'': ['pyRXP-license.txt']},
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    96
			#license = open(os.path.join('rxp','COPYING')).read(),
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    97
            classifiers = [
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    98
				'Development Status :: 5 - Production/Stable',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
    99
				'Intended Audience :: Developers',
62
d19872af425c fix spelling of classifier yet again
robin <robin@reportlab.com>
parents: 61
diff changeset
   100
				'License :: OSI Approved :: BSD License',
1
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   101
				'Programming Language :: Python',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   102
				'Programming Language :: C',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   103
				'Operating System :: Unix',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   104
				'Operating System :: POSIX',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   105
				'Operating System :: Microsoft :: Windows',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   106
				'Topic :: Software Development :: Libraries :: Python Modules',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   107
				'Topic :: Text Processing :: Markup :: XML',
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   108
                ]
7cf042be50ba Move pyRXP into its own universe
rgbecker
parents:
diff changeset
   109
			)