Python setuptools.command.build_ext.build_ext() Examples
The following are 23
code examples of setuptools.command.build_ext.build_ext().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
setuptools.command.build_ext
, or try the search function
.
Example #1
Source File: cupy_setup_build.py From cupy with MIT License | 6 votes |
def run(self): if build.get_nvcc_path() is not None: def wrap_new_compiler(func): def _wrap_new_compiler(*args, **kwargs): try: return func(*args, **kwargs) except errors.DistutilsPlatformError: if not PLATFORM_WIN32: CCompiler = _UnixCCompiler else: CCompiler = _MSVCCompiler return CCompiler( None, kwargs['dry_run'], kwargs['force']) return _wrap_new_compiler ccompiler.new_compiler = wrap_new_compiler(ccompiler.new_compiler) # Intentionally causes DistutilsPlatformError in # ccompiler.new_compiler() function to hook. self.compiler = 'nvidia' if cython_available: ext_modules = get_ext_modules(True) # get .pyx modules cythonize(ext_modules, cupy_setup_options) check_extensions(self.extensions) build_ext.build_ext.run(self)
Example #2
Source File: test_build_ext.py From setuptools with MIT License | 6 votes |
def test_abi3_filename(self): """ Filename needs to be loadable by several versions of Python 3 if 'is_abi3' is truthy on Extension() """ print(get_abi3_suffix()) extension = Extension('spam.eggs', ['eggs.c'], py_limited_api=True) dist = Distribution(dict(ext_modules=[extension])) cmd = build_ext(dist) cmd.finalize_options() assert 'spam.eggs' in cmd.ext_map res = cmd.get_ext_filename('spam.eggs') if six.PY2 or not get_abi3_suffix(): assert res.endswith(get_config_var('EXT_SUFFIX')) elif sys.platform == 'win32': assert res.endswith('eggs.pyd') else: assert 'abi3' in res
Example #3
Source File: setup.py From CameraRadarFusionNet with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): from setuptools.command.build_ext import build_ext as SetupToolsBuildExt # Bypass __setatrr__ to avoid infinite recursion. self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs)
Example #4
Source File: test_build_ext.py From Flask with Apache License 2.0 | 5 votes |
def test_get_ext_filename(self): # setuptools needs to give back the same # result than distutils, even if the fullname # is not in ext_map dist = Distribution() cmd = build_ext(dist) cmd.ext_map['foo/bar'] = '' res = cmd.get_ext_filename('foo') wanted = distutils_build_ext.get_ext_filename(cmd, 'foo') assert res == wanted
Example #5
Source File: test_build_ext.py From Flask with Apache License 2.0 | 5 votes |
def test_get_ext_filename(self): # setuptools needs to give back the same # result than distutils, even if the fullname # is not in ext_map dist = Distribution() cmd = build_ext(dist) cmd.ext_map['foo/bar'] = '' res = cmd.get_ext_filename('foo') wanted = distutils_build_ext.get_ext_filename(cmd, 'foo') assert res == wanted
Example #6
Source File: setup.py From tf-retinanet with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): from setuptools.command.build_ext import build_ext as SetupToolsBuildExt # Bypass __setatrr__ to avoid infinite recursion. self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs)
Example #7
Source File: setup.py From keras-m2det with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): from setuptools.command.build_ext import build_ext as SetupToolsBuildExt # Bypass __setatrr__ to avoid infinite recursion. self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs)
Example #8
Source File: setup.py From ANTsPy with Apache License 2.0 | 5 votes |
def run(self): self.run_command("build_ext") self.create_version_file() setuptools.command.build_py.build_py.run(self)
Example #9
Source File: setup.py From football with Apache License 2.0 | 5 votes |
def __init__(self, name): # don't invoke the original build_ext for this special extension super().__init__(name, sources=[])
Example #10
Source File: setup.py From keras-retinanet with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): from setuptools.command.build_ext import build_ext as SetupToolsBuildExt # Bypass __setatrr__ to avoid infinite recursion. self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs)
Example #11
Source File: test_build_ext.py From setuptools with MIT License | 5 votes |
def test_get_ext_filename(self): """ Setuptools needs to give back the same result as distutils, even if the fullname is not in ext_map. """ dist = Distribution() cmd = build_ext(dist) cmd.ext_map['foo/bar'] = '' res = cmd.get_ext_filename('foo') wanted = orig.build_ext.get_ext_filename(cmd, 'foo') assert res == wanted
Example #12
Source File: setup.py From tree with Apache License 2.0 | 5 votes |
def run(self): for ext in self.extensions: self.bazel_build(ext) build_ext.build_ext.run(self)
Example #13
Source File: setup.py From anchor-optimization with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): from setuptools.command.build_ext import build_ext as SetupToolsBuildExt # Bypass __setatrr__ to avoid infinite recursion. self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs)
Example #14
Source File: test_build_ext.py From pledgeservice with Apache License 2.0 | 5 votes |
def test_get_ext_filename(self): # setuptools needs to give back the same # result than distutils, even if the fullname # is not in ext_map dist = Distribution() cmd = build_ext(dist) cmd.ext_map['foo/bar'] = '' res = cmd.get_ext_filename('foo') wanted = distutils_build_ext.get_ext_filename(cmd, 'foo') assert res == wanted
Example #15
Source File: setuptools_golang.py From setuptools-golang with MIT License | 5 votes |
def set_build_ext( dist: Distribution, attr: str, value: Dict[str, str], ) -> None: root = value['root'] # https://github.com/python/typeshed/pull/3742 base = dist.cmdclass.get('build_ext', _build_ext) # type: ignore dist.cmdclass['build_ext'] = _get_build_ext_cls(base, root) # type: ignore
Example #16
Source File: setuptools_golang.py From setuptools-golang with MIT License | 5 votes |
def _get_build_ext_cls(base: Type[_build_ext], root: str) -> Type[_build_ext]: attrs = {'build_extension': _get_build_extension_method(base, root)} return type('build_ext', (base,), attrs)
Example #17
Source File: chainerx_build_helper.py From chainer with MIT License | 5 votes |
def config_setup_kwargs(setup_kwargs, build_chainerx): # TODO(imanishi): Call this function with setuptools. emit_build_info(build_chainerx) if not build_chainerx: # `chainerx` package needs to be able to be imported even if ChainerX # is unavailable. setup_kwargs['packages'] += ['chainerx'] return if sys.version_info < (3, 5): raise RuntimeError( 'ChainerX is only available for Python 3.5 or later.') setup_kwargs['packages'] += [ 'chainerx', 'chainerx._docs', 'chainerx.creation', 'chainerx.manipulation', 'chainerx.math', 'chainerx.random', 'chainerx.testing', ] setup_kwargs['package_data'] = { 'chainerx': ['py.typed', '*.pyi'], } setup_kwargs.update(dict( cmdclass={'build_ext': CMakeBuild}, ext_modules=[CMakeExtension( name='chainerx._core', build_targets=['_core.so'], sourcedir='chainerx_cc')], ))
Example #18
Source File: setup.py From DeepForest with MIT License | 5 votes |
def __init__(self, *args, **kwargs): from setuptools.command.build_ext import build_ext as SetupToolsBuildExt # Bypass __setatrr__ to avoid infinite recursion. self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs)
Example #19
Source File: test_build_ext.py From oss-ftp with MIT License | 5 votes |
def test_get_ext_filename(self): # setuptools needs to give back the same # result than distutils, even if the fullname # is not in ext_map dist = Distribution() cmd = build_ext(dist) cmd.ext_map['foo/bar'] = '' res = cmd.get_ext_filename('foo') wanted = distutils_build_ext.get_ext_filename(cmd, 'foo') assert res == wanted
Example #20
Source File: setuptools_golang.py From setuptools-golang with MIT License | 4 votes |
def _get_build_extension_method( base: Type[_build_ext], root: str, ) -> Callable[[_build_ext, Extension], None]: def build_extension(self: _build_ext, ext: Extension) -> None: # If there are no .go files then the parent should handle this if not any(source.endswith('.go') for source in ext.sources): # the base class may mutate `self.compiler` compiler = copy.deepcopy(self.compiler) self.compiler, compiler = compiler, self.compiler try: return base.build_extension(self, ext) finally: self.compiler, compiler = compiler, self.compiler if len(ext.sources) != 1: raise OSError( f'Error building extension `{ext.name}`: ' f'sources must be a single file in the `main` package.\n' f'Recieved: {ext.sources!r}', ) main_file, = ext.sources if not os.path.exists(main_file): raise OSError( f'Error building extension `{ext.name}`: ' f'{main_file} does not exist', ) main_dir = os.path.dirname(main_file) # Copy the package into a temporary GOPATH environment with _tmpdir() as tempdir: root_path = os.path.join(tempdir, 'src', root) # Make everything but the last directory (copytree interface) os.makedirs(os.path.dirname(root_path)) shutil.copytree('.', root_path, symlinks=True) pkg_path = os.path.join(root_path, main_dir) env = {'GOPATH': tempdir} cmd_get = ('go', 'get', '-d') _check_call(cmd_get, cwd=pkg_path, env=env) env.update({ 'CGO_CFLAGS': _get_cflags( self.compiler, ext.define_macros or (), ), 'CGO_LDFLAGS': _get_ldflags(), }) cmd_build = ( 'go', 'build', '-buildmode=c-shared', '-o', os.path.abspath(self.get_ext_fullpath(ext.name)), ) _check_call(cmd_build, cwd=pkg_path, env=env) return build_extension
Example #21
Source File: setup.py From blenderpy with GNU General Public License v3.0 | 4 votes |
def run(self): """ Copy libraries from the bin directory and place them as appropriate """ self.announce("Moving library files", level=3) # We have already built the libraries in the previous build_ext step self.skip_build = True bin_dir = self.distribution.bin_dir libs = [os.path.join(bin_dir, _lib) for _lib in os.listdir(bin_dir) if os.path.isfile(os.path.join(bin_dir, _lib)) and os.path.splitext(_lib)[1] in [".dll", ".so"] and not (_lib.startswith("python") or _lib.startswith("bpy"))] for lib in libs: shutil.move(lib, os.path.join(self.build_dir, os.path.basename(lib))) # Mark the libs for installation, adding them to # distribution.data_files seems to ensure that setuptools' record # writer appends them to installed-files.txt in the package's egg-info # # Also tried adding the libraries to the distribution.libraries list, # but that never seemed to add them to the installed-files.txt in the # egg-info, and the online recommendation seems to be adding libraries # into eager_resources in the call to setup(), which I think puts them # in data_files anyways. # # What is the best way? self.distribution.data_files = [os.path.join(self.install_dir, os.path.basename(lib)) for lib in libs] # Must be forced to run after adding the libs to data_files self.distribution.run_command("install_data") super().run()
Example #22
Source File: setup.py From blenderpy with GNU General Public License v3.0 | 4 votes |
def run(self): """ Copy libraries from the bin directory and place them as appropriate """ self.announce("Moving library files", level=3) # We have already built the libraries in the previous build_ext step self.skip_build = True bin_dir = self.distribution.bin_dir libs = [os.path.join(bin_dir, _lib) for _lib in os.listdir(bin_dir) if os.path.isfile(os.path.join(bin_dir, _lib)) and os.path.splitext(_lib)[1] in [".dll", ".so"] and not (_lib.startswith("python") or _lib.startswith("bpy"))] for lib in libs: shutil.move(lib, os.path.join(self.build_dir, os.path.basename(lib))) # Mark the libs for installation, adding them to # distribution.data_files seems to ensure that setuptools' record # writer appends them to installed-files.txt in the package's egg-info # # Also tried adding the libraries to the distribution.libraries list, # but that never seemed to add them to the installed-files.txt in the # egg-info, and the online recommendation seems to be adding libraries # into eager_resources in the call to setup(), which I think puts them # in data_files anyways. # # What is the best way? self.distribution.data_files = [os.path.join(self.install_dir, os.path.basename(lib)) for lib in libs] # Must be forced to run after adding the libs to data_files self.distribution.run_command("install_data") super().run()
Example #23
Source File: setup.py From blenderpy with GNU General Public License v3.0 | 4 votes |
def run(self): """ Copy libraries from the bin directory and place them as appropriate """ self.announce("Moving library files", level=3) # We have already built the libraries in the previous build_ext step self.skip_build = True bin_dir = self.distribution.bin_dir libs = [os.path.join(bin_dir, _lib) for _lib in os.listdir(bin_dir) if os.path.isfile(os.path.join(bin_dir, _lib)) and os.path.splitext(_lib)[1] in [".dll", ".so"] and not (_lib.startswith("python") or _lib.startswith("bpy"))] for lib in libs: shutil.move(lib, os.path.join(self.build_dir, os.path.basename(lib))) # Mark the libs for installation, adding them to # distribution.data_files seems to ensure that setuptools' record # writer appends them to installed-files.txt in the package's egg-info # # Also tried adding the libraries to the distribution.libraries list, # but that never seemed to add them to the installed-files.txt in the # egg-info, and the online recommendation seems to be adding libraries # into eager_resources in the call to setup(), which I think puts them # in data_files anyways. # # What is the best way? self.distribution.data_files = [os.path.join(self.install_dir, os.path.basename(lib)) for lib in libs] # Must be forced to run after adding the libs to data_files self.distribution.run_command("install_data") super().run()