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 161 162 163 164 165 166
|
"""
::BOH
Copyright (c) 2004, 2005 Peter Kropf. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
::EOH
distutils setup file for use in creating a Python module from the owfs
project.
"""
# allows one to use the python3 syntax for print()
from __future__ import print_function
import os
# platform doesn't exist for python 2.2
#import platform
from distutils.core import setup, Extension
from distutils import sysconfig
import string
#python_version = platform.python_version()[0:3]
python_version = sysconfig.get_config_vars()["VERSION"]
classifiers = """
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Developers
Intended Audience :: System Administrators
Operating System :: POSIX :: Linux
Programming Language :: C
Programming Language :: Python
Topic :: System :: Hardware
Topic :: Utilities
"""
my_libraries = []
my_library_dirs = []
my_include_dirs = []
my_extra_link_args = []
my_extra_compile_args = []
my_runtime_library_dirs = []
my_extra_objects = []
my_define_macros = []
my_undef_macros = []
def write_configuration(define_macros, include_dirs, libraries, library_dirs,
extra_link_args, extra_compile_args,
runtime_library_dirs,extra_objects):
#Write the compilation configuration into a file
out=open('configuration.log','w')
print("Current configuration", file=out)
print("libraries", libraries, file=out)
print("library_dirs", library_dirs, file=out)
print("include_dirs", include_dirs, file=out)
print("define_macros", define_macros, file=out)
print("extra_link_args", extra_link_args, file=out)
print("extra_compile_args", extra_compile_args, file=out)
print("runtime_library_dirs", runtime_library_dirs, file=out)
print("extra_objects", extra_objects, file=out)
out.close()
have_darwin = '@HAVE_DARWIN@'
have_freebsd = '@HAVE_FREEBSD@'
bsd_fixes = have_darwin == 'true' or have_freebsd == 'true'
# have to split up the _CFLAGS, _LIBS variables since there are problem
# when they contain spaces. The append() function doesn't work very good.
# extra_l_args.append ( '@LIBUSB_CFLAGS@' )
# Should perhaps add ${LD_EXTRALIBS} ${OSLIBS} to extra_l_args too if
# supporting MacOSX.
my_extra_compile_args = [ '-D_FILE_OFFSET_BITS=64' ]
my_extra_link_args = [ ]
if bsd_fixes:
my_extra_link_args = my_extra_link_args + string.split('../../owlib/src/c/.libs/libow.so', ' ')
my_libraries = [ 'ow' ]
#if ARCH == "x64":
# my_extra_objects = [ '../../owlib/src/c/.libs/libow.a' ]
# my_libraries = [ ]
# #my_extra_link_args = my_extra_link_args + string.split('-Wl,--export-dynamic', ' ')
#elif ARCH != "x64":
# my_extra_objects = ""
# my_libraries = [ 'ow' ]
if bsd_fixes:
my_libraries = [ ]
removals = ['-Wstrict-prototypes']
if python_version == '2.5':
cv_opt = sysconfig.get_config_vars()["CFLAGS"]
for removal in removals:
cv_opt = cv_opt.replace(removal, " ")
sysconfig.get_config_vars()["CFLAGS"] = ' '.join(cv_opt.split())
cv_opt = ' '.join(my_extra_compile_args)
for removal in removals:
cv_opt = cv_opt.replace(removal, " ")
my_extra_compile_args = ' '.join(cv_opt.split())
else:
cv_opt = sysconfig.get_config_vars()["OPT"]
for removal in removals:
cv_opt = cv_opt.replace(removal, " ")
sysconfig.get_config_vars()["OPT"] = ' '.join(cv_opt.split())
# cv_opt = ' '.join(my_extra_compile_args)
# my_extra_compile_args = ' '.join(cv_opt.split())
#print "my_extra_compile_args=", my_extra_compile_args
my_extra_compile_args = [ arg for arg in my_extra_compile_args if len(arg) > 1 ]
#print "my_extra_compile_args=", my_extra_compile_args
my_extra_link_args = [ arg for arg in my_extra_link_args if len(arg) > 1 ]
my_include_dirs = [ '../../owlib/src/include', '../../../src/include' ]
my_library_dirs = [ '../../owlib/src/c/.libs' ]
my_runtime_library_dirs = [ ]
sources = [ 'ow_wrap.c' ]
write_configuration(my_define_macros, my_include_dirs, my_libraries, my_library_dirs,
my_extra_link_args, my_extra_compile_args,
my_runtime_library_dirs,my_extra_objects)
setup(
name = 'ow',
description = '1-wire hardware interface.',
version = '@VERSION@',
author = 'Peter Kropf',
author_email = 'pkropf@gmail.com',
url = 'http://www.owfs.org/',
license = 'GPL',
platforms = 'Linux',
long_description = 'Interface with 1-wire controllers and sensors from Python.',
classifiers = filter( None, classifiers.split( '\n' ) ),
packages = ['ow'],
ext_package = 'ow',
ext_modules = [ Extension( '_OW',
sources,
include_dirs = my_include_dirs,
library_dirs = my_library_dirs,
libraries = my_libraries,
extra_compile_args = my_extra_compile_args,
extra_link_args = my_extra_link_args,
runtime_library_dirs = my_runtime_library_dirs,
extra_objects=my_extra_objects)
],
)
|