Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean up setup.py
  • Loading branch information
pxinwr committed Feb 26, 2019
commit a42825ec58785facef60aa2a86b1ce972903b557
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def get_platform():
return sys.platform
host_platform = get_platform()

_vxworks = ('vxworks' in host_platform)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the variable to VXWORKS to better distinguish local and global variables in functions below.

By the way, I would also prefer to rename host_platform to HOST_PLATFORM for the same reason, but it should be done in a separated PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: all the variables that are not supposed to be modified should be defined as constants, right? If this is true, besides host_platform, cross_compiling is another one to fix. I looked through PEP-8 but didn't find the guidance.


# Were we compiled --with-pydebug or with #define Py_DEBUG?
COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))

Expand Down Expand Up @@ -509,12 +511,12 @@ def add_multiarch_paths(self):
finally:
os.unlink(tmpfile)

def add_gcc_paths(self):
gcc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'gccpaths')
def add_cross_compiling_paths(self):
cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'ccpaths')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (gcc, tmpfile))
ret = os.system('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
is_gcc = False
Comment thread
pxinwr marked this conversation as resolved.
is_clang = False
in_incdirs = False
Expand All @@ -526,7 +528,7 @@ def add_gcc_paths(self):
for line in fp.readlines():
if line.startswith("gcc version"):
is_gcc = True
if line.startswith("clang version"):
elif line.startswith("clang version"):
is_clang = True
elif line.startswith("#include <...>"):
in_incdirs = True
Expand All @@ -553,7 +555,7 @@ def detect_modules(self):
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
# only change this for cross builds for 3.3, issues on Mageia
if cross_compiling:
self.add_gcc_paths()
self.add_cross_compiling_paths()
self.add_multiarch_paths()

# Add paths specified in the environment variables LDFLAGS and
Expand Down Expand Up @@ -725,7 +727,7 @@ def detect_modules(self):
# pwd(3)
exts.append( Extension('pwd', ['pwdmodule.c']) )
# grp(3)
if 'vxworks' not in host_platform:
if not _vxworks:
exts.append( Extension('grp', ['grpmodule.c']) )
# spwd, shadow passwords
if (config_h_vars.get('HAVE_GETSPNAM', False) or
Expand Down Expand Up @@ -864,7 +866,7 @@ def detect_modules(self):
else:
libs = []

if 'vxworks' not in host_platform:
if not _vxworks:
exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) )
elif self.compiler.find_library_file(lib_dirs, 'OPENSSL'):
libs = ['OPENSSL']
Expand All @@ -877,7 +879,7 @@ def detect_modules(self):
exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) )

# socket(2)
if 'vxworks' not in host_platform :
if not _vxworks:
exts.append( Extension('_socket', ['socketmodule.c'],
depends = ['socketmodule.h']) )
elif self.compiler.find_library_file(lib_dirs, 'net'):
Expand Down Expand Up @@ -1334,7 +1336,7 @@ class db_found(Exception): pass

# Unix-only modules
if host_platform != 'win32':
if 'vxworks' not in host_platform :
if not _vxworks:
# Steen Lumholt's termios module
exts.append( Extension('termios', ['termios.c']) )
# Jeremy Hylton's rlimit interface
Expand Down