Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
try:
import setuptools
except:
print('''
setuptools not found.
On linux, the package is often called python-setuptools''')
sys.exit(1)
import os
from setuptools.command.build_ext import build_ext as _build_ext
# Based on http://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
def has_webp():
return os.system("pkg-config --exists libwebp") == 0
exec(compile(open('imread/imread_version.py').read(),
'imread/imread_version.py', 'exec'))
long_description = open('README.rst').read()
undef_macros = []
define_macros = []
'atom/src/signalconnector.cpp',
'atom/src/validatebehavior.cpp',
],
include_dirs=['src'],
language='c++',
),
Extension(
'atom.datastructures.sortedmap',
['atom/src/sortedmap.cpp'],
include_dirs=['src'],
language='c++',
),
]
class BuildExt(build_ext):
""" A custom build extension for adding compiler-specific options.
"""
c_opts = {
'msvc': ['/EHsc'],
}
def initialize_options(self):
build_ext.initialize_options(self)
self.debug = False
def build_extensions(self):
# Delayed import of cppy to let setup_requires install it if necessary
import cppy
% sockaddr.upper(), 1)
else:
print('none! %s' % cached)
results['have_sockaddrs'] = result
# Save the results to our config.cache file
myfile = open(cache_file, 'wb')
try:
pickle.dump(results, myfile)
finally:
myfile.close()
# Don't bother detecting socket ioctls on Windows
if not getattr(sys, 'getwindowsversion', None):
setuptools.command.build_ext.build_ext = my_build_ext
setup (name='netifaces',
version=__version__,
description="Portable network interface information.",
license="MIT License",
long_description="""\
(Python 3.x compatibility added by Kevin Kelley .
The functionality of the module should remain unchanged.)
netifaces provides a (hopefully portable-ish) way for Python programmers to
get access to a list of the network interfaces on the local machine, and to
obtain the addresses of those network interfaces.
The package has been tested on Mac OS X, Windows XP, Windows Vista, Linux
and Solaris.
Return path to .pyd after successful build command.
:return: Path to .pyd file or None.
"""
if not os.path.isdir("./build"):
raise NotADirectoryError
for path, dirs, files in os.walk("./build"):
for file_name in files:
file_name_parts = os.path.splitext(file_name)
if file_name_parts[1] == ".pyd":
return path
return None
class StubsCommand(build_ext):
description = "Generate python stubs with documentation from C code."
def run(self):
build_ext.run(self)
print("running stubs")
# Generate .pyd file for this module
generate_stubs.GenerateStubFile(find_pyd_file(), os.path.abspath("./zroya/"))
class DocumentationCommand(Command):
description = "Generate documentation from /docs_source directory."
user_options = []
except OSError:
pass
return True
def cpp_flag(compiler):
flags = ["-std=c++17", "-std=c++14", "-std=c++11"]
for flag in flags:
if has_flag(compiler, flag):
return flag
raise RuntimeError("Unsupported compiler -- at least C++11 support is needed!")
class BuildExt(build_ext):
c_opts = {
"msvc": ["/EHsc"],
"unix": [],
}
l_opts = {
"msvc": [],
"unix": [],
}
if sys.platform == "darwin":
darwin_opts = ["-stdlib=libc++", "-mmacosx-version-min=10.7"]
c_opts["unix"] += darwin_opts
l_opts["unix"] += darwin_opts
def build_extensions(self):
ct = self.compiler.compiler_type
# Read in requirements.txt
with open(requirements_file, 'r') as f_requirements:
requirements = f_requirements.readlines()
requirements = [r.strip() for r in requirements]
return requirements
class CMakeExtension(Extension):
def __init__(self, target, name, sourcedir=''):
self.target = target
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError("CMake must be installed to build the following extensions: " +
", ".join(e.name for e in self.extensions))
if platform.system() == "Windows":
cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < '3.1.0':
raise RuntimeError("CMake >= 3.1.0 is required on Windows")
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Process BSDDB module build
import setup_bsddb
self.bsddb = setup_bsddb
self.include_dirs.extend([
'/usr/include',
'/usr/local/include',
'/usr/include'])
self.library_dirs.extend([
'/lib64',
'/usr/lib64',
'/lib',
'/usr/lib',
'/usr/local/lib'])
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except CCompilerError, x:
print ('*'*70+'\n')*3
print """WARNING: The %s extension module to the Vision
Egg could not be compiled. The Vision Egg should run, but
the features present in that file will not be
available.
Above is the ouput showing how the compilation
failed."""%ext.name
if sys.platform == 'win32':
print
print """I see you are using Windows. The default
compiler for this platform is the Microsoft Visual
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
if has_flag(self.compiler, '-fopenmp'):
opts.append('-fopenmp')
link_args.append('-fopenmp')
elif has_flag(self.compiler, '-openmp'):
opts.append('-openmp')
link_args.append('-openmp')
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = link_args
build_ext.build_extensions(self)
version_file = v.read().strip()
if version.distance:
version_file += '.dev%d' % version.distance
return version_file
def local_scheme(version):
v = ''
if version.distance:
v = '+' + version.node
return v
use_scm_version = {'write_to': 'retro/VERSION.txt',
'version_scheme': version_scheme,
'local_scheme': local_scheme}
class CMakeBuild(build_ext):
def run(self):
suffix = super(CMakeBuild, self).get_ext_filename('')
pyext_suffix = '-DPYEXT_SUFFIX:STRING=%s' % suffix
pylib_dir = ''
if not self.inplace:
pylib_dir = '-DPYLIB_DIRECTORY:PATH=%s' % self.build_lib
if self.debug:
build_type = '-DCMAKE_BUILD_TYPE=Debug'
else:
build_type = ''
python_executable = '-DPYTHON_EXECUTABLE:STRING=%s' % sys.executable
cmake_exe = find_executable('cmake')
if not cmake_exe:
try:
import cmake
except ImportError: