def test_SCardGetErrorMessage(self):
        res = SCardGetErrorMessage(SCARD_S_SUCCESS)

        # do not test on Windows
        # the error messages are different and localized
        if get_platform() in ('win32', 'win-amd64'):
            return

        expected = "Command successful."
        self.assertEqual(res, expected)

        res = SCardGetErrorMessage(SCARD_F_INTERNAL_ERROR)
        expected = "Internal error."
        self.assertEqual(res, expected)

        res = SCardGetErrorMessage(1)
        expected = "Unknown error: 0x00000001"
        # macOS bug not yet fixed
        if get_platform().startswith('macosx-'):
            version = get_platform()  # something like 'macosx-10.14-x86_64'
            version = version.split('-')[1]  # '10.14'
            major, minor = map(int, version.split('.'))  # (10, 14)
            if major == 10 and minor < 13:
                expected = "Unkown error: 0x00000001"

        self.assertEqual(res, expected)
Example #2
0
    def initialize(self, plat_name=None):
        # multi-init means we would need to check platform same each time...
        assert not self.initialized, "don't init multiple times"
        if plat_name is None:
            plat_name = get_platform()
        # sanity check for platforms to prevent obscure errors later.
        if plat_name not in PLAT_TO_VCVARS:
            raise DistutilsPlatformError("--plat-name must be one of {}".format(tuple(PLAT_TO_VCVARS)))

        # On x86, 'vcvarsall.bat amd64' creates an env that doesn't work;
        # to cross compile, you use 'x86_amd64'.
        # On AMD64, 'vcvarsall.bat amd64' is a native build env; to cross
        # compile use 'x86' (ie, it runs the x86 compiler directly)
        if plat_name == get_platform() or plat_name == "win32":
            # native build or cross-compile to win32
            plat_spec = PLAT_TO_VCVARS[plat_name]
        else:
            # cross compile from win32 -> some 64bit
            plat_spec = "{}_{}".format(PLAT_TO_VCVARS[get_platform()], PLAT_TO_VCVARS[plat_name])

        vc_env = _get_vc_env(plat_spec)
        if not vc_env:
            raise DistutilsPlatformError("Unable to find a compatible " "Visual Studio installation.")

        paths = vc_env.get("path", "").split(os.pathsep)
        self.cc = _find_exe("cl.exe", paths)
        self.linker = _find_exe("link.exe", paths)
        self.lib = _find_exe("lib.exe", paths)
        self.rc = _find_exe("rc.exe", paths)  # resource compiler
        self.mc = _find_exe("mc.exe", paths)  # message compiler
        self.mt = _find_exe("mt.exe", paths)  # message compiler

        for dir in vc_env.get("include", "").split(os.pathsep):
            if dir:
                self.add_include_dir(dir)

        for dir in vc_env.get("lib", "").split(os.pathsep):
            if dir:
                self.add_library_dir(dir)

        self.preprocess_options = None
        self.compile_options = ["/nologo", "/Ox", "/MD", "/W3", "/GL", "/DNDEBUG"]
        self.compile_options_debug = ["/nologo", "/Od", "/MDd", "/Zi", "/W3", "/D_DEBUG"]

        self.ldflags_shared = ["/nologo", "/DLL", "/INCREMENTAL:NO", "/LTCG", "/nodefaultlib:libucrt.lib", "ucrt.lib"]
        self.ldflags_shared_debug = [
            "/nologo",
            "/DLL",
            "/INCREMENTAL:no",
            "/LTCG",
            "/DEBUG:FULL",
            "/nodefaultlib:libucrtd.lib",
            "ucrtd.lib",
        ]
        self.ldflags_static = ["/nologo"]

        self.initialized = True
Example #3
0
    def compileTestCase(self):
        libdir = os.path.join('build', 'temp.%s-%d.%d'%(get_platform(), sys.version_info[0], sys.version_info[1]))
        if hasattr(sys, 'gettotalrefcount'):
            libdir += "-pydebug"
        libdir = os.path.join(libdir, 'libffi-src')

        libffiobjects = self.object_files(libdir)


        if self.filename.endswith('.m'):
            extra_link = '-framework Foundation'
        else:
            extra_link = ''

        commandline='MACOSX_DEPLPOYMENT_TARGET=%s %s %s -g -DMACOSX -Ilibffi-src/include -Ilibffi-src/powerpc -o /tmp/test.bin %s %s %s 2>&1'%(
                get_config_var('MACOSX_DEPLOYMENT_TARGET'),
                get_config_var('CC'),
                get_config_var('CFLAGS'), self.filename, ' '.join(libffiobjects),
		extra_link)

        fp = os.popen(commandline)
        data = fp.read()
        xit = fp.close()
        if xit != None:
            self.fail("Compile failed[%s]:\n%s"%(xit, data))
Example #4
0
    def run(self):
        """
        """
        if not self.skip_build:
            self.run_command('build')
            # If we built for any other platform, we can't install.
            build_plat = self.distribution.get_command_obj('build').plat_name
            # check warn_dir - it is a clue that the 'install' is happening
            # internally, and not to sys.path, so we don't check the platform
            # matches what we are running.
            if self.warn_dir and build_plat != get_platform():
                raise DistutilsPlatformError("Can't test when "
                                             "cross-compiling")
        sys.path.insert(0, os.path.join(os.getcwd(), 'test'))
        import main
        if self.build_lib is None:
            if os.path.exists(self.build_purelib):
                self.build_lib = self.build_purelib
            elif os.path.exists(self.build_platlib):
                self.build_lib = self.build_platlib
        link = os.path.join(self.build_scripts,  "blast2seqids.py")
        os.symlink("blast2seqids", link)

        test_res = main.run(self.build_scripts, [], verbosity = self.verbosity)
        res_path = os.path.join("build", ".tests_results")
        os.unlink(link)
        with open(res_path, 'w') as _file:
            print >> _file, int(test_res.wasSuccessful())
        if not test_res.wasSuccessful():
            sys.exit("some tests fails. Run python setup.py test -vv to have more details")
Example #5
0
def getbuilddir():
    from distutils.util import get_platform
    s = os.path.join("build", "lib.%s-%.3s" % (get_platform(), sys.version))
    if (sys.version[:3] >= '2.6' and
        hasattr(sys, 'gettotalrefcount')):
        s += '-pydebug'
    return s
Example #6
0
def addbuilddir():
    """Append ./build/lib.<platform> in case we're running in the build dir
    (especially for Guido :-)"""
    from distutils.util import get_platform
    s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
    s = os.path.join(os.path.dirname(sys.path[-1]), s)
    sys.path.append(s)
Example #7
0
def get_ncarg_files():
  plat_dir = os.path.join("build","lib."+get_platform()+"-"+sys.version[:3], \
                          "PyNGL")

  ncl_lib       = os.path.join(ncarg_root,'lib')
  ncl_ncarg_dir = os.path.join(ncl_lib,'ncarg')
  ncarg_dirs    = ["colormaps","data","database","fontcaps","graphcaps"]

  cwd = os.getcwd()          # Retain current directory.
  if not os.path.exists('ncarg'):
    os.mkdir('ncarg')          # make a directory to copy files to
  os.chdir(ncl_ncarg_dir)    # cd to $NCARG_ROOT/lib/ncarg

# Walk through each directory and copy some data files. Skip over
# the rangs directory.
  for ncarg_dir in ncarg_dirs:
    for root, dirs, files in os.walk(ncarg_dir):
      dir_to_copy_to = os.path.join(cwd,'ncarg',root)
      if not os.path.exists(dir_to_copy_to):
        os.mkdir(dir_to_copy_to)
      for name in files:
        if root != "database/rangs":
          file_to_copy = os.path.join(ncl_ncarg_dir,root,name)
          cmd = "cp " + file_to_copy + " " + dir_to_copy_to
          os.system(cmd)
          DATA_FILES.append(os.path.join('ncarg',root,name))

  os.chdir(cwd)    # cd back to original directory

# Special 'sysresfile'
  os.system("cp sysresfile ncarg")
  DATA_FILES.append(os.path.join('ncarg','sysresfile'))

  return
Example #8
0
 def finalize_options(self):
     from distutils.util import get_platform
     self.name = self.name if self.name else self.distribution.metadata.name
     self.version = self.version if self.version else self.distribution.metadata.version
     self.platform = self.platform if self.platform else get_platform()
     self.app_name = "%s-%s-%s" % (self.name, self.version, self.platform)
     self.dist_dir = self.dist_dir if self.dist_dir else os.path.join("dist", self.name)
Example #9
0
File: bdist.py Project: 0xcc/pyston
    def finalize_options(self):
        # have to finalize 'plat_name' before 'bdist_base'
        if self.plat_name is None:
            if self.skip_build:
                self.plat_name = get_platform()
            else:
                self.plat_name = self.get_finalized_command('build').plat_name

        # 'bdist_base' -- parent of per-built-distribution-format
        # temporary directories (eg. we'll probably have
        # "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.)
        if self.bdist_base is None:
            build_base = self.get_finalized_command('build').build_base
            self.bdist_base = os.path.join(build_base,
                                           'bdist.' + self.plat_name)

        self.ensure_string_list('formats')
        if self.formats is None:
            try:
                self.formats = [self.default_format[os.name]]
            except KeyError:
                raise DistutilsPlatformError, \
                      "don't know how to create built distributions " + \
                      "on platform %s" % os.name

        if self.dist_dir is None:
            self.dist_dir = "dist"
Example #10
0
def bootstrap():
    # Set PETSC_DIR and PETSC_ARCH
    PETSC_DIR  = os.path.abspath(os.getcwd())
    PETSC_ARCH = get_platform() + '-python'
    os.environ['PETSC_DIR']  = PETSC_DIR
    os.environ['PETSC_ARCH'] = PETSC_ARCH
    sys.path.insert(0, os.path.join(PETSC_DIR, 'config'))
    # Generate package __init__.py file
    from distutils.dir_util import mkpath
    pkgdir = os.path.join('config', 'pypi')
    if not os.path.exists(pkgdir): mkpath(pkgdir)
    pkgfile = os.path.join(pkgdir, '__init__.py')
    fh = open(pkgfile, 'wt')
    fh.write(init_py)
    fh.close()
    # Simple-minded lookup for MPI and mpi4py
    mpi4py = mpicc = None
    try:
        import mpi4py
        conf = mpi4py.get_config()
        mpicc = conf.get('mpicc')
    except ImportError: # mpi4py is not installed
        mpi4py = None
        mpicc = os.environ.get('MPICC') or find_executable('mpicc')
    except AttributeError: # mpi4py is too old
        pass
    if ('setuptools' in sys.modules):
        metadata['zip_safe'] = False
        if not mpi4py and mpicc:
            metadata['install_requires']= ['mpi4py>=1.2.2']
Example #11
0
    def run(self):
        from distutils.ccompiler import new_compiler
        if not self.extensions:
            return
        else:
            if self.distribution.has_c_libraries():
                build_clib = self.get_finalized_command('build_clib')
                self.libraries.extend(build_clib.get_library_names() or [])
                self.library_dirs.append(build_clib.build_clib)
            self.compiler = new_compiler(compiler=self.compiler, verbose=self.verbose, dry_run=self.dry_run, force=self.force)
            customize_compiler(self.compiler)
            if os.name == 'nt' and self.plat_name != get_platform():
                self.compiler.initialize(self.plat_name)
            if self.include_dirs is not None:
                self.compiler.set_include_dirs(self.include_dirs)
            if self.define is not None:
                for name, value in self.define:
                    self.compiler.define_macro(name, value)

            if self.undef is not None:
                for macro in self.undef:
                    self.compiler.undefine_macro(macro)

            if self.libraries is not None:
                self.compiler.set_libraries(self.libraries)
            if self.library_dirs is not None:
                self.compiler.set_library_dirs(self.library_dirs)
            if self.rpath is not None:
                self.compiler.set_runtime_library_dirs(self.rpath)
            if self.link_objects is not None:
                self.compiler.set_link_objects(self.link_objects)
            self.build_extensions()
            return
Example #12
0
def get_sys_path(p=None):
    if p is None:
        p = sys.path
    p = p[:]
    try:
        from distutils.util import get_platform
    except ImportError:
        return p
    p0 = ""
    if p:
        p0 = p[0]
    #
    plat = get_platform()
    plat_specifier = "%s-%s" % (plat, sys.version[:3])
    ##print plat, plat_specifier
    #
    for prefix in (p0, os.curdir, os.pardir):
        if not prefix:
            continue
        d = os.path.join(prefix, "build")
        for subdir in ("lib", "lib." + plat_specifier, "lib." + plat):
            dir = os.path.normpath(os.path.join(d, subdir))
            if os.path.isdir(dir):
                if dir not in p:
                    p.insert(1, dir)
    #
    return p
Example #13
0
def set_package_path(level=1):
    """ Prepend package directory to sys.path.

    set_package_path should be called from a test_file.py that
    satisfies the following tree structure:

      <somepath>/<somedir>/test_file.py

    Then the first existing path name from the following list

      <somepath>/build/lib.<platform>-<version>
      <somepath>/..

    is prepended to sys.path.
    The caller is responsible for removing this path by using

      restore_path()
    """
    from distutils.util import get_platform
    f = get_frame(level)
    if f.f_locals['__name__']=='__main__':
        testfile = sys.argv[0]
    else:
        testfile = f.f_locals['__file__']
    d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))
    d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))
    if not os.path.isdir(d1):
        d1 = os.path.dirname(d)
    if DEBUG:
        print 'Inserting %r to sys.path for test_file %r' % (d1, testfile)
    sys.path.insert(0,d1)
    return
Example #14
0
def configuration(parent_package='',top_path=None):
    sys.argv.extend ( ['config_fc', '--fcompiler=gnu95'])
    config = Configuration('tt', parent_package, top_path) 
    config.set_options(ignore_setup_xxx_py=True,
                       assume_default_configuration=True,
                       delegate_options_to_subpackages=True,
                       quiet=False,     
    )
    plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
    inc_dir = ['build/temp%s' % plat_specifier]
    
    tt_dir = 'tt-fort'
    tt_src = ['nan.f90', 'timef.f90', 'say.f90', 'rnd.f90', 'ptype.f90', 'sort.f90', 'trans.f90', 'ort.f90', 
              'mat.f90', 'check.f90', 'lr.f90', 'maxvol.f90', 'svd.f90', 'matrix_util.f90', 'tt.f90', 'ttaux.f90', 
              'ttop.f90', 'ttio.f90',  'tts.f90', 'python_conv.f90','tt_linalg.f90']
    tt_src = [tt_dir+'/'+x for x in tt_src] 
    
    print_dir = 'tt-fort/print'
    print_src = ['putstrmodule.F90','dispmodule.f90']
    print_src = [print_dir+'/'+x for x in print_src]
    config.add_include_dirs(inc_dir)
    config.add_library('print_lib',sources=print_src) 
    config.add_library('mytt',sources=tt_src)
    
    
    config.add_subpackage('core')
    config.add_subpackage('amr')
    config.add_subpackage('kls')
    config.add_subpackage('ksl')
    config.add_subpackage('eigb')
    return config
Example #15
0
def bootstrap():
    # Set PETSC_DIR and PETSC_ARCH
    PETSC_DIR  = os.path.abspath(os.getcwd())
    PETSC_ARCH = 'arch-python-' + get_platform()
    os.environ['PETSC_DIR']  = PETSC_DIR
    os.environ['PETSC_ARCH'] = PETSC_ARCH
    sys.path.insert(0, os.path.join(PETSC_DIR, 'config'))
    sys.path.insert(0, os.path.join(PETSC_DIR, 'lib','petsc','conf'))
    # Generate package __init__.py file
    from distutils.dir_util import mkpath
    pkgdir = os.path.join('config', 'pypi')
    if not os.path.exists(pkgdir): mkpath(pkgdir)
    pkgfile = os.path.join(pkgdir, '__init__.py')
    fh = open(pkgfile, 'w')
    fh.write(init_py)
    fh.close()
    # Configure options
    options = os.environ.get('PETSC_CONFIGURE_OPTIONS', '')
    CONFIGURE_OPTIONS.extend(split_quoted(options))
    if '--with-mpi=0' not in CONFIGURE_OPTIONS:
        # Simple-minded lookup for MPI and mpi4py
        mpi4py = mpicc = None
        try:
            import mpi4py
            conf = mpi4py.get_config()
            mpicc = conf.get('mpicc')
        except ImportError: # mpi4py is not installed
            mpi4py = None
            mpicc = (os.environ.get('MPICC') or
                     find_executable('mpicc'))
        except AttributeError: # mpi4py is too old
            pass
        if not mpi4py and mpicc:
            metadata['install_requires'] = ['mpi4py>=1.2.2']
Example #16
0
    def test_finalize_options(self):
        pkg_dir, dist = self.create_dist()
        cmd = build(dist)
        cmd.finalize_options()

        # if not specified, plat_name gets the current platform
        self.assertEquals(cmd.plat_name, get_platform())

        # build_purelib is build + lib
        wanted = os.path.join(cmd.build_base, 'lib')
        self.assertEquals(cmd.build_purelib, wanted)

        # build_platlib is 'build/lib.platform-x.x[-pydebug]'
        # examples:
        #   build/lib.macosx-10.3-i386-2.7
        plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3])
        if hasattr(sys, 'gettotalrefcount'):
            self.assertTrue(cmd.build_platlib.endswith('-pydebug'))
            plat_spec += '-pydebug'
        wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
        self.assertEquals(cmd.build_platlib, wanted)

        # by default, build_lib = build_purelib
        self.assertEquals(cmd.build_lib, cmd.build_purelib)

        # build_temp is build/temp.<plat>
        wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
        self.assertEquals(cmd.build_temp, wanted)

        # build_scripts is build/scripts-x.x
        wanted = os.path.join(cmd.build_base, 'scripts-' +  sys.version[0:3])
        self.assertEquals(cmd.build_scripts, wanted)

        # executable is os.path.normpath(sys.executable)
        self.assertEquals(cmd.executable, os.path.normpath(sys.executable))
Example #17
0
def get_grib2_codetables():
  plat_dir = os.path.join("build","lib."+get_platform()+"-"+sys.version[:3], \
                          "PyNIO")

  ncl_lib       = os.path.join(ncarg_root,'lib')
  ncl_ncarg_dir = os.path.join(ncl_lib,'ncarg')
  ncarg_dirs    = ["grib2_codetables"]

  cwd = os.getcwd()          # Retain current directory.
  if not os.path.exists('ncarg'):
    os.mkdir('ncarg')          # make a directory to copy files to
  os.chdir(ncl_ncarg_dir)    # cd to $NCARG_ROOT/lib/ncarg

# Walk through each directory and copy some data files.
  for ncarg_dir in ncarg_dirs:
    for root, dirs, files in os.walk(ncarg_dir):
      dir_to_copy_to = os.path.join(cwd,'ncarg',root)
      if not os.path.exists(dir_to_copy_to):
        os.mkdir(dir_to_copy_to)
      for name in files:
        file_to_copy = os.path.join(ncl_ncarg_dir,root,name)
        cmd = "cp " + file_to_copy + " " + dir_to_copy_to
        os.system(cmd)
        data_files.append(os.path.join('ncarg',root,name))

  os.chdir(cwd)    # cd back to original directory

  return
Example #18
0
 def finalize_options(self):
     build_scripts = self.build_scripts
     old_build.finalize_options(self)
     plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
     if build_scripts is None:
         self.build_scripts = os.path.join(self.build_base,
                                           'scripts' + plat_specifier)
Example #19
0
    def finalize_options (self):

        plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])

        # 'build_purelib' and 'build_platlib' just default to 'lib' and
        # 'lib.<plat>' under the base build directory.  We only use one of
        # them for a given distribution, though --
        if self.build_purelib is None:
            self.build_purelib = os.path.join(self.build_base, 'lib')
        if self.build_platlib is None:
            self.build_platlib = os.path.join(self.build_base,
                                              'lib' + plat_specifier)

        # 'build_lib' is the actual directory that we will use for this
        # particular module distribution -- if user didn't supply it, pick
        # one of 'build_purelib' or 'build_platlib'.
        if self.build_lib is None:
            if self.distribution.ext_modules:
                self.build_lib = self.build_platlib
            else:
                self.build_lib = self.build_purelib

        # 'build_temp' -- temporary directory for compiler turds,
        # "build/temp.<plat>"
        if self.build_temp is None:
            self.build_temp = os.path.join(self.build_base,
                                           'temp' + plat_specifier)
        if self.build_scripts is None:
            self.build_scripts = os.path.join(self.build_base,
                                              'scripts-' + sys.version[0:3])
Example #20
0
 def new():
     if get_platform().startswith("macosx"):
         from geocommit.provider.corelocation import CoreLocationProvider
         return CoreLocationProvider()
     else:
         from geocommit.networkmanager import NetworkManager
         return NetworkManager()
Example #21
0
    def get_tag(self):
        supported_tags = pep425tags.get_supported()

        if self.distribution.is_pure():
            if self.universal:
                impl = 'py2.py3'
            else:
                impl = self.python_tag
            tag = (impl, 'none', 'any')
        else:
            plat_name = self.plat_name
            if plat_name is None:
                plat_name = get_platform()
            plat_name = plat_name.replace('-', '_').replace('.', '_')
            impl_name = get_abbr_impl()
            impl_ver = get_impl_ver()
            # PEP 3149 -- no SOABI in Py 2
            # For PyPy?
            # "pp%s%s" % (sys.pypy_version_info.major,
            # sys.pypy_version_info.minor)
            abi_tag = sysconfig.get_config_vars().get('SOABI', 'none')
            if abi_tag.startswith('cpython-'):
                abi_tag = 'cp' + abi_tag.rsplit('-', 1)[-1]

            tag = (impl_name + impl_ver, abi_tag, plat_name)
            # XXX switch to this alternate implementation for non-pure:
            assert tag == supported_tags[0]
        return tag
Example #22
0
    def run(self):
        def subst_file(_file, vars_2_subst):
            input_file = os.path.join(self.get_build_script(), _file)
            output_file = input_file + '.tmp'
            subst_vars(input_file, output_file, vars_2_subst)
            os.unlink(input_file)
            self.move_file(output_file, input_file)

        #TODO : ask to bertrand why he is not a problem in his setup.py in the same section
        # Obviously have to build before we can substitute PREFIXDATA and after install without build
        if not self.skip_build:
            self.run_command('build')
            # If we built for any other platform, we can't install.
            build_plat = self.distribution.get_command_obj('build').plat_name
            # check warn_dir - it is a clue that the 'install' is happening
            # internally, and not to sys.path, so we don't check the platform
            # matches what we are running.
            if self.warn_dir and build_plat != get_platform():
                raise DistutilsPlatformError("Can't install when "
                                             "cross-compiling")
            self.skip_build = 1

        inst = self.distribution.command_options.get('install')
        vars_2_subst = {'PREFIXDATA': os.path.join(get_install_data_dir(inst), 'regate'),
                        }
        for _file in self.distribution.fix_prefix:
            subst_file(_file, vars_2_subst)
        install.run(self)
    def _import(self):
        "Import the new extension module into our client's namespace"
        from distutils.util import get_platform
        import sys, os
        
        # Add the module's lib directory to the Python path.
        plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
        build_platlib = os.path.join(self._buildDir,
                                     'build',
                                     'lib' + plat_specifier)
        sys.path.append(build_platlib)

        # Load the module.
        import imp
        fp, pathname, description = imp.find_module(self._moduleName)

        try:
            module = imp.load_module(self._moduleName, fp,
                                     pathname, description)
        finally:
            # Since we may exit via an exception, close fp explicitly.
            if fp:
                fp.close()

        if self._options.has_key('targetmodule'):
            # Load each of the module's methods into the caller's
            # global namespace.
            setattr(self._options.get('targetmodule'), self._moduleName, module)
            for method in self._methods:
                setattr(self._options.get('targetmodule'), method['name'],
                        getattr(module, method['name']))
                
        return module
Example #24
0
def get_build_dir():
    '''
    Walk from the current directory up until a directory is found
    which contains a regular file called "setup.py" and a directory
    called "build". If found return the fully qualified path to
    the build directory's platform specific directory, this is where
    the architecture specific build produced by setup.py is located.

    There is no API in distutils to return the platform specific
    directory so we use as much as distutils exposes, the rest was
    determined by looking at the source code for distutils.

    If the build directory cannont be found in the tree None is returned.
    '''
    cwd = os.getcwd()
    path_components = cwd.split('/')
    while (len(path_components)):
        path = os.path.join('/', *path_components)
        setup_path = os.path.join(path, 'setup.py')
        build_path = os.path.join(path, 'build')
        # Does this directory contain the file "setup.py" and the directory "build"?
        if os.path.exists(setup_path) and os.path.exists(build_path) and \
           os.path.isfile(setup_path) and os.path.isdir(build_path):
            # Found, return the path contentated with the architecture
            # specific build directory
            platform_specifier = "lib.%s-%s" % (get_platform(), sys.version[0:3])
            return os.path.join(build_path, platform_specifier)

        # Not found, ascend to parent directory and try again
        path_components.pop()

    # Failed to find the build directory
    return None
Example #25
0
    def build_extension(self, extension):
        build_ext.build_extension(self, extension)
        sysVer = sys.version_info[:2]

        # For Python versions that use MSVC compiler 2008, re-insert the
        # manifest into the resulting .pyd file.
        if self.compiler_is_msvc() and sysVer == (2, 7):
            platform = get_platform()
            # Default to the x86 manifest
            manifest = '_psycopg.vc9.x86.manifest'
            if platform == 'win-amd64':
                manifest = '_psycopg.vc9.amd64.manifest'
            try:
                ext_path = self.get_ext_fullpath(extension.name)
            except AttributeError:
                ext_path = os.path.join(self.build_lib,
                        'psycopg2', '_psycopg.pyd')
            # Make sure spawn() will work if compile() was never
            # called. https://github.com/psycopg/psycopg2/issues/380
            if not self.compiler.initialized:
                self.compiler.initialize()
            self.compiler.spawn(
                ['mt.exe', '-nologo', '-manifest',
                 os.path.join('psycopg', manifest),
                 '-outputresource:%s;2' % ext_path])
Example #26
0
    def get_tag(self):
        # bdist sets self.plat_name if unset, we should only use it for purepy
        # wheels if the user supplied it.
        if self.plat_name_supplied:
            plat_name = self.plat_name
        elif self.root_is_pure:
            plat_name = 'any'
        else:
            plat_name = self.plat_name or get_platform()
        plat_name = plat_name.replace('-', '_').replace('.', '_')

        if self.root_is_pure:
            if self.universal:
                impl = 'py2.py3'
            else:
                impl = self.python_tag
            tag = (impl, 'none', plat_name)
        else:
            impl_name = get_abbr_impl()
            impl_ver = get_impl_ver()
            # PEP 3149
            abi_tag = str(get_abi_tag()).lower()
            tag = (impl_name + impl_ver, abi_tag, plat_name)
            supported_tags = pep425tags.get_supported(
                supplied_platform=plat_name if self.plat_name_supplied else None)
            # XXX switch to this alternate implementation for non-pure:
            assert tag == supported_tags[0]
        return tag
Example #27
0
def distutil_destination():
    """Internal utility that makes the goofy destination directory string so that PyDSTool
    can find where the distutils fortran/gcc compilers put things.

    If your temp directory turns out to be different to the one created here, contact us
    on sourceforge.net, but in the meantime you can override destdir with whatever directory
    name you find that is being used.
    """
    import scipy
    osname = str.lower(platform.system())
    pyname = platform.python_version_tuple()
    machinename = platform.machine()
    if osname == 'linux':
        destdir = 'src.'+osname+'-'+machinename+'-'+pyname[0] + '.' + pyname[1]
    elif osname in ['darwin', 'freebsd']:
        # use the same version string as numpy.distutils.core.setup used by ContClass.CompileAutoLib
        osver = get_platform()
        destdir = 'src.' + osver + '-' +pyname[0] + '.' + pyname[1]
    elif osname == 'windows':
        destdir = 'src.win32-'+pyname[0]+'.'+pyname[1]
    else:
        destdir = ''
    # TEMP for debugging
    #import os
    #os.system('echo %s > temp_dist.txt' % (os.path.abspath('.') + " : " + destdir))
    return destdir
Example #28
0
def show_sys_vars():
	print('os.name = %s, sys.platform = %s' % (os.name, sys.platform))

	from distutils import util, ccompiler
	print('platform = %s' % util.get_platform())
	print('compiler = %s' % ccompiler.get_default_compiler())

	from SCons.Environment import Environment
	env = Environment()
	vars = [
		'CC',
		'CXX',
		'PLATFORM',
		'MSVC_VERSION',
		'TARGET',
		'TARGET_ARCH',
		'TARGET_OS',
		'MSVS',
		'MSVS_VERSION',
		'MSVS_ARCH',
		'TOOLS',
		'HOST_ARCH',
		'HOST_OS',
		'MSVC_BATCH',
		'MSVC_USE_SCRIPT',
	]
	for var in vars:
		print('%s = %r' % (var, env.subst('$' + var)))
Example #29
0
File: site.py Project: pymo/pymo
def addbuilddir():
    """Append ./build/lib.<platform> in case we're running in the build dir
    (especially for Guido :-)"""
    s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
    if os.path.exists(s):
        s = os.path.join(os.getcwd(), s)
        sys.path.append(s)
Example #30
0
    def finalize_options(self):
        '''Overloaded build_ext implementation to append custom openssl
        include file and library linking options'''

        build_ext.build_ext.finalize_options(self)

        includeDir = os.path.join(self.openssl, 'include')
        opensslIncludeDir = os.path.join(self.openssl, 'include', 'openssl')
        opensslLibraryDir = os.path.join(self.openssl, 'lib')
        
        self.swig_opts = ['-I%s' % i for i in self.include_dirs + \
                          [opensslIncludeDir, includeDir]]
        if get_platform() == 'linux-x86_64':
            self.swig_opts.append('-D__x86_64__')
        self.swig_opts.append('-outdir')
        self.swig_opts.append(os.path.join(os.getcwd(),'M2Crypto'))
        #self.swig_opts.append('-includeall')
        #self.swig_opts.append('-D__i386__') # Uncomment for early OpenSSL 0.9.7 versions, or on Fedora Core if build fails
        #self.swig_opts.append('-DOPENSSL_NO_EC') # Try uncommenting if you can't build with EC disabled
        
        self.include_dirs += [os.path.join(self.openssl, opensslIncludeDir),
                              os.path.join(os.getcwd(), 'SWIG')]        
            
        if sys.platform == 'cygwin':
            # Cygwin SHOULD work (there's code in distutils), but
            # if one first starts a Windows command prompt, then bash,
            # the distutils code does not seem to work. If you start
            # Cygwin directly, then it would work even without this change.
            # Someday distutils will be fixed and this won't be needed.
            self.library_dirs += [os.path.join(self.openssl, 'bin')]
               
        self.library_dirs += [os.path.join(self.openssl, opensslLibraryDir)]
Example #31
0
class bdist_wininst(Command):
    description = 'create an executable installer for MS Windows'
    user_options = [('bdist-dir=', None, 'temporary directory for creating the distribution'),
     ('plat-name=', 'p', 'platform name to embed in generated filenames (default: %s)' % get_platform()),
     ('keep-temp', 'k', 'keep the pseudo-installation tree around after ' + 'creating the distribution archive'),
     ('target-version=', None, 'require a specific python version' + ' on the target system'),
     ('no-target-compile', 'c', 'do not compile .py to .pyc on the target system'),
     ('no-target-optimize', 'o', 'do not compile .py to .pyo (optimized)on the target system'),
     ('dist-dir=', 'd', 'directory to put final built distributions in'),
     ('bitmap=', 'b', 'bitmap to use for the installer instead of python-powered logo'),
     ('title=', 't', 'title to display on the installer background instead of default'),
     ('skip-build', None, 'skip rebuilding everything (for testing/debugging)'),
     ('install-script=', None, 'basename of installation script to be run afterinstallation or before deinstallation'),
     ('pre-install-script=', None, 'Fully qualified filename of a script to be run before any files are installed.  This script need not be in the distribution'),
     ('user-access-control=', None, "specify Vista's UAC handling - 'none'/default=no handling, 'auto'=use UAC if target Python installed for all users, 'force'=always use UAC")]
    boolean_options = ['keep-temp',
     'no-target-compile',
     'no-target-optimize',
     'skip-build']

    def initialize_options(self):
        self.bdist_dir = None
        self.plat_name = None
        self.keep_temp = 0
        self.no_target_compile = 0
        self.no_target_optimize = 0
        self.target_version = None
        self.dist_dir = None
        self.bitmap = None
        self.title = None
        self.skip_build = None
        self.install_script = None
        self.pre_install_script = None
        self.user_access_control = None
        return

    def finalize_options(self):
        self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
        if self.bdist_dir is None:
            if self.skip_build and self.plat_name:
                bdist = self.distribution.get_command_obj('bdist')
                bdist.plat_name = self.plat_name
            bdist_base = self.get_finalized_command('bdist').bdist_base
            self.bdist_dir = os.path.join(bdist_base, 'wininst')
        if not self.target_version:
            self.target_version = ''
        if not self.skip_build and self.distribution.has_ext_modules():
            short_version = get_python_version()
            if self.target_version and self.target_version != short_version:
                raise DistutilsOptionError, "target version can only be %s, or the '--skip-build' option must be specified" % (short_version,)
            self.target_version = short_version
        self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'), ('plat_name', 'plat_name'))
        if self.install_script:
            for script in self.distribution.scripts:
                if self.install_script == os.path.basename(script):
                    break
            else:
                raise DistutilsOptionError, "install_script '%s' not found in scripts" % self.install_script

        return

    def run(self):
        if sys.platform != 'win32' and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries()):
            raise DistutilsPlatformError('distribution contains extensions and/or C libraries; must be compiled on a Windows 32 platform')
        if not self.skip_build:
            self.run_command('build')
        install = self.reinitialize_command('install', reinit_subcommands=1)
        install.root = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0
        install.plat_name = self.plat_name
        install_lib = self.reinitialize_command('install_lib')
        install_lib.compile = 0
        install_lib.optimize = 0
        if self.distribution.has_ext_modules():
            target_version = self.target_version
            if not target_version:
                if not self.skip_build:
                    raise AssertionError('Should have already checked this')
                    target_version = sys.version[0:3]
                plat_specifier = '.%s-%s' % (self.plat_name, target_version)
                build = self.get_finalized_command('build')
                build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
            for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
                value = string.upper(key)
                if key == 'headers':
                    value = value + '/Include/$dist_name'
                setattr(install, 'install_' + key, value)

            log.info('installing to %s', self.bdist_dir)
            install.ensure_finalized()
            sys.path.insert(0, os.path.join(self.bdist_dir, 'PURELIB'))
            install.run()
            del sys.path[0]
            from tempfile import mktemp
            archive_basename = mktemp()
            fullname = self.distribution.get_fullname()
            arcname = self.make_archive(archive_basename, 'zip', root_dir=self.bdist_dir)
            self.create_exe(arcname, fullname, self.bitmap)
            if self.distribution.has_ext_modules():
                pyversion = get_python_version()
            else:
                pyversion = 'any'
            self.distribution.dist_files.append(('bdist_wininst', pyversion, self.get_installer_filename(fullname)))
            log.debug("removing temporary file '%s'", arcname)
            os.remove(arcname)
            self.keep_temp or remove_tree(self.bdist_dir, dry_run=self.dry_run)

    def get_inidata(self):
        lines = []
        metadata = self.distribution.metadata
        lines.append('[metadata]')
        info = (metadata.long_description or '') + '\n'

        def escape(s):
            return string.replace(s, '\n', '\\n')

        for name in ['author',
         'author_email',
         'description',
         'maintainer',
         'maintainer_email',
         'name',
         'url',
         'version']:
            data = getattr(metadata, name, '')
            if data:
                info = info + '\n    %s: %s' % (string.capitalize(name), escape(data))
                lines.append('%s=%s' % (name, escape(data)))

        lines.append('\n[Setup]')
        if self.install_script:
            lines.append('install_script=%s' % self.install_script)
        lines.append('info=%s' % escape(info))
        lines.append('target_compile=%d' % (not self.no_target_compile))
        lines.append('target_optimize=%d' % (not self.no_target_optimize))
        if self.target_version:
            lines.append('target_version=%s' % self.target_version)
        if self.user_access_control:
            lines.append('user_access_control=%s' % self.user_access_control)
        title = self.title or self.distribution.get_fullname()
        lines.append('title=%s' % escape(title))
        import time
        import distutils
        build_info = 'Built %s with distutils-%s' % (time.ctime(time.time()), distutils.__version__)
        lines.append('build_info=%s' % build_info)
        return string.join(lines, '\n')

    def create_exe(self, arcname, fullname, bitmap = None):
        import struct
        self.mkpath(self.dist_dir)
        cfgdata = self.get_inidata()
        installer_name = self.get_installer_filename(fullname)
        self.announce('creating %s' % installer_name)
        if bitmap:
            bitmapdata = open(bitmap, 'rb').read()
            bitmaplen = len(bitmapdata)
        else:
            bitmaplen = 0
        file = open(installer_name, 'wb')
        file.write(self.get_exe_bytes())
        if bitmap:
            file.write(bitmapdata)
        try:
            unicode
        except NameError:
            pass
        else:
            if isinstance(cfgdata, unicode):
                cfgdata = cfgdata.encode('mbcs')

        cfgdata = cfgdata + '\x00'
        if self.pre_install_script:
            script_data = open(self.pre_install_script, 'r').read()
            cfgdata = cfgdata + script_data + '\n\x00'
        else:
            cfgdata = cfgdata + '\x00'
        file.write(cfgdata)
        header = struct.pack('<iii', 305419899, len(cfgdata), bitmaplen)
        file.write(header)
        file.write(open(arcname, 'rb').read())

    def get_installer_filename(self, fullname):
        if self.target_version:
            installer_name = os.path.join(self.dist_dir, '%s.%s-py%s.exe' % (fullname, self.plat_name, self.target_version))
        else:
            installer_name = os.path.join(self.dist_dir, '%s.%s.exe' % (fullname, self.plat_name))
        return installer_name

    def get_exe_bytes(self):
        from distutils.msvccompiler import get_build_version
        cur_version = get_python_version()
        if self.target_version and self.target_version != cur_version:
            if self.target_version > cur_version:
                bv = get_build_version()
            elif self.target_version < '2.4':
                bv = 6.0
            else:
                bv = 7.1
        else:
            bv = get_build_version()
        directory = os.path.dirname(__file__)
        if self.plat_name != 'win32' and self.plat_name[:3] == 'win':
            sfix = self.plat_name[3:]
        else:
            sfix = ''
        filename = os.path.join(directory, 'wininst-%.1f%s.exe' % (bv, sfix))
        f = open(filename, 'rb')
        try:
            return f.read()
        finally:
            f.close()
Example #32
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages
from distutils.util import get_platform

print(get_platform())

setup(
    name='pybindx',  # 包名称
    version='1.1.16',
    keywords='autogenerate, pybind11',  # 关键词描述
    description='a simple auto generate for pybind11, could worked with only head file',   # 简略描述
    author='Alex Xiong',  # 作者信息
    packages=find_packages(),
    install_requires=[
        "pygccxml",
    ]
)
Example #33
0
class build(Command):

    description = "build everything needed to install"

    user_options = [
        ('build-base=', 'b', "base directory for build library"),
        ('build-purelib=', None,
         "build directory for platform-neutral distributions"),
        ('build-platlib=', None,
         "build directory for platform-specific distributions"),
        ('build-lib=', None,
         "build directory for all distribution (defaults to either " +
         "build-purelib or build-platlib"),
        ('build-scripts=', None, "build directory for scripts"),
        ('build-temp=', 't', "temporary build directory"),
        ('plat-name=', 'p', "platform name to build for, if supported "
         "(default: %s)" % get_platform()),
        ('compiler=', 'c', "specify the compiler type"),
        ('debug', 'g',
         "compile extensions and libraries with debugging information"),
        ('force', 'f', "forcibly build everything (ignore file timestamps)"),
        ('executable=', 'e',
         "specify final destination interpreter path (build.py)"),
    ]

    boolean_options = ['debug', 'force']

    help_options = [
        ('help-compiler', None, "list available compilers", show_compilers),
    ]

    def initialize_options(self):
        self.build_base = 'build'
        # these are decided only after 'build_base' has its final value
        # (unless overridden by the user or client)
        self.build_purelib = None
        self.build_platlib = None
        self.build_lib = None
        self.build_temp = None
        self.build_scripts = None
        self.compiler = None
        self.plat_name = None
        self.debug = None
        self.force = 0
        self.executable = None

    def finalize_options(self):
        if self.plat_name is None:
            self.plat_name = get_platform()
        else:
            # plat-name only supported for windows (other platforms are
            # supported via ./configure flags, if at all).  Avoid misleading
            # other platforms.
            if os.name != 'nt':
                raise DistutilsOptionError(
                    "--plat-name only supported on Windows (try "
                    "using './configure --help' on your platform)")

        plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3])

        # Make it so Python 2.x and Python 2.x with --with-pydebug don't
        # share the same build directories. Doing so confuses the build
        # process for C modules
        if hasattr(sys, 'gettotalrefcount'):
            plat_specifier += '-pydebug'

        # 'build_purelib' and 'build_platlib' just default to 'lib' and
        # 'lib.<plat>' under the base build directory.  We only use one of
        # them for a given distribution, though --
        if self.build_purelib is None:
            self.build_purelib = os.path.join(self.build_base, 'lib')
        if self.build_platlib is None:
            self.build_platlib = os.path.join(self.build_base,
                                              'lib' + plat_specifier)

        # 'build_lib' is the actual directory that we will use for this
        # particular module distribution -- if user didn't supply it, pick
        # one of 'build_purelib' or 'build_platlib'.
        if self.build_lib is None:
            if self.distribution.ext_modules:
                self.build_lib = self.build_platlib
            else:
                self.build_lib = self.build_purelib

        # 'build_temp' -- temporary directory for compiler turds,
        # "build/temp.<plat>"
        if self.build_temp is None:
            self.build_temp = os.path.join(self.build_base,
                                           'temp' + plat_specifier)
        if self.build_scripts is None:
            self.build_scripts = os.path.join(self.build_base,
                                              'scripts-' + sys.version[0:3])

        if self.executable is None:
            self.executable = os.path.normpath(sys.executable)

    def run(self):
        # Run all relevant sub-commands.  This will be some subset of:
        #  - build_py      - pure Python modules
        #  - build_clib    - standalone C libraries
        #  - build_ext     - Python extensions
        #  - build_scripts - (Python) scripts
        for cmd_name in self.get_sub_commands():
            self.run_command(cmd_name)

    # -- Predicates for the sub-command list ---------------------------

    def has_pure_modules(self):
        return self.distribution.has_pure_modules()

    def has_c_libraries(self):
        return self.distribution.has_c_libraries()

    def has_ext_modules(self):
        return self.distribution.has_ext_modules()

    def has_scripts(self):
        return self.distribution.has_scripts()

    sub_commands = [
        ('build_py', has_pure_modules),
        ('build_clib', has_c_libraries),
        ('build_ext', has_ext_modules),
        ('build_scripts', has_scripts),
    ]
Example #34
0
class bdist_dumb(Command):
    description = 'create a "dumb" built distribution'
    user_options = [
        ('bdist-dir=', 'd',
         'temporary directory for creating the distribution'),
        ('plat-name=', 'p',
         'platform name to embed in generated filenames (default: %s)' %
         get_platform()),
        ('format=', 'f', 'archive format to create (tar, ztar, gztar, zip)'),
        ('keep-temp', 'k', 'keep the pseudo-installation tree around after ' +
         'creating the distribution archive'),
        ('dist-dir=', 'd', 'directory to put final built distributions in'),
        ('skip-build', None,
         'skip rebuilding everything (for testing/debugging)'),
        ('relative', None,
         'build the archive using relative paths(default: false)'),
        ('owner=', 'u',
         'Owner name used when creating a tar file [default: current user]'),
        ('group=', 'g',
         'Group name used when creating a tar file [default: current group]')
    ]
    boolean_options = ['keep-temp', 'skip-build', 'relative']
    default_format = {'posix': 'gztar', 'nt': 'zip', 'os2': 'zip'}

    def initialize_options(self):
        self.bdist_dir = None
        self.plat_name = None
        self.format = None
        self.keep_temp = 0
        self.dist_dir = None
        self.skip_build = None
        self.relative = 0
        self.owner = None
        self.group = None
        return

    def finalize_options(self):
        if self.bdist_dir is None:
            bdist_base = self.get_finalized_command('bdist').bdist_base
            self.bdist_dir = os.path.join(bdist_base, 'dumb')
        if self.format is None:
            try:
                self.format = self.default_format[os.name]
            except KeyError:
                raise DistutilsPlatformError, (
                    "don't know how to create dumb built distributions " +
                    'on platform %s') % os.name

        self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'),
                                   ('plat_name', 'plat_name'),
                                   ('skip_build', 'skip_build'))
        return

    def run(self):
        if not self.skip_build:
            self.run_command('build')
        install = self.reinitialize_command('install', reinit_subcommands=1)
        install.root = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0
        log.info('installing to %s' % self.bdist_dir)
        self.run_command('install')
        archive_basename = '%s.%s' % (self.distribution.get_fullname(),
                                      self.plat_name)
        if os.name == 'os2':
            archive_basename = archive_basename.replace(':', '-')
        pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
        if not self.relative:
            archive_root = self.bdist_dir
        elif self.distribution.has_ext_modules(
        ) and install.install_base != install.install_platbase:
            raise DistutilsPlatformError, "can't make a dumb built distribution where base and platbase are different (%s, %s)" % (
                repr(install.install_base), repr(install.install_platbase))
        else:
            archive_root = os.path.join(self.bdist_dir,
                                        ensure_relative(install.install_base))
        filename = self.make_archive(pseudoinstall_root,
                                     self.format,
                                     root_dir=archive_root,
                                     owner=self.owner,
                                     group=self.group)
        if self.distribution.has_ext_modules():
            pyversion = get_python_version()
        else:
            pyversion = 'any'
        self.distribution.dist_files.append(
            ('bdist_dumb', pyversion, filename))
        if not self.keep_temp:
            remove_tree(self.bdist_dir, dry_run=self.dry_run)
Example #35
0
    keywords=[
        'graph', 'network', 'mathematics', 'math', 'graph theory',
        'discrete mathematics'
    ],
    classifiers=[
        'Development Status :: 4 - Beta', 'Intended Audience :: Developers',
        'Intended Audience :: Science/Research',
        'Operating System :: OS Independent', 'Programming Language :: C',
        'Programming Language :: Python', 'Topic :: Scientific/Engineering',
        'Topic :: Scientific/Engineering :: Information Analysis',
        'Topic :: Scientific/Engineering :: Mathematics',
        'Topic :: Scientific/Engineering :: Physics',
        'Topic :: Scientific/Engineering :: Bio-Informatics',
        'Topic :: Software Development :: Libraries :: Python Modules'
    ],
    cmdclass={"build_ext": buildcfg.build_ext})

if "macosx" in get_platform() and "bdist_mpkg" in sys.argv:
    # OS X specific stuff to build the .mpkg installer
    options["data_files"] = [ \
            ('/usr/local/lib', [os.path.join('..', 'igraph', 'fatbuild', 'libigraph.0.dylib')])
    ]

if sys.version_info > (3, 0):
    if build_py is None:
        options["use_2to3"] = True
    else:
        options["cmdclass"]["build_py"] = build_py

setup(**options)
Example #36
0
    language='c++',
    include_dirs=[
        os.getenv('GAMMA_INCLUDE', abspath + '/gamma/c_api'),
    ],
    extra_compile_args=[
        '-std=c++11', '-mavx2', '-mf16c', '-msse4', '-mpopcnt', '-m64',
        '-Wno-sign-compare', '-fopenmp'
    ],
    extra_link_args=([
        '-Xpreprocessor', '-fopenmp', '-lomp', '-mlinker-version=450'
    ] if 'darwin' == sys.platform else ['-fopenmp']),
    swig_opts=[
        '-c++',
        '-Doverride=',
        '-I' + os.getenv('GAMMA_INCLUDE', abspath + '/gamma/c_api'),
    ] + ([] if 'macos' in get_platform() else ['-DSWIGWORDSIZE64']))

setup(
    name='vearch',
    version='3.2.5',
    description=
    'A library for efficient similarity search and storage of deep learning vectors.',
    long_description=long_description,
    url='https://github.com/vearch/vearch',
    author=
    'Jie Li,Chuanghua Gui,Xingda Wang,Chao Zhan,Zhenyun Ni,Qiang Liu,Pengfei Yin,Sen Gao,Yande Guo',
    author_email='*****@*****.**',
    license='Apache License, Version 2.0',
    keywords='real time index, vector nearest neighbors',
    cmdclass={
        'build': CustomBuild,
Example #37
0
 def finalize_options(self):
     # make wheels platform but not Python specific
     self.plat_name = self.plat_name or get_platform()
     self.universal = True
     super(BDistWheel, self).finalize_options()
Example #38
0
    """
    Copy binaries for platform from ../go into current directory
    """
    this_dir = Path(__file__).resolve().parent
    binary_path = this_dir / "../go/release" / plat_name_to_binary_path(
        plat_name)
    (this_dir / "build/bin").mkdir(parents=True, exist_ok=True)
    (this_dir / "replicate/bin").mkdir(parents=True, exist_ok=True)
    shutil.copy(binary_path / "replicate", this_dir / "build/bin/replicate")
    shutil.copy(binary_path / "replicate-shared",
                this_dir / "replicate/bin/replicate-shared")


# For stuff like `setup.py develop` and `setup.py install`, copy default binaries for
# this platform. When building wheels, these defaults will then be overridden.
copy_binaries(get_platform())

# wheel isn't always installed, so only override for when we're building packages
try:
    from wheel.bdist_wheel import bdist_wheel as _bdist_wheel

    # override bdist_wheel so we can copy binary into right place before wheel is created
    class bdist_wheel(_bdist_wheel):
        def run(self):
            copy_binaries(self.plat_name)
            _bdist_wheel.run(self)

except ImportError:
    bdist_wheel = None

Example #39
0
class bdist_dumb(Command):

    description = 'create a "dumb" built distribution'

    user_options = [
        ('bdist-dir=', 'd',
         "temporary directory for creating the distribution"),
        ('plat-name=', 'p', "platform name to embed in generated filenames "
         "(default: %s)" % get_platform()),
        ('format=', 'f', "archive format to create (tar, ztar, gztar, zip)"),
        ('keep-temp', 'k', "keep the pseudo-installation tree around after " +
         "creating the distribution archive"),
        ('dist-dir=', 'd', "directory to put final built distributions in"),
        ('skip-build', None,
         "skip rebuilding everything (for testing/debugging)"),
        ('relative', None, "build the archive using relative paths"
         "(default: false)"),
        ('owner=', 'u', "Owner name used when creating a tar file"
         " [default: current user]"),
        ('group=', 'g', "Group name used when creating a tar file"
         " [default: current group]"),
    ]

    boolean_options = ['keep-temp', 'skip-build', 'relative']

    default_format = {'posix': 'gztar', 'nt': 'zip', 'os2': 'zip'}

    def initialize_options(self):
        self.bdist_dir = None
        self.plat_name = None
        self.format = None
        self.keep_temp = 0
        self.dist_dir = None
        self.skip_build = 0
        self.relative = 0
        self.owner = None
        self.group = None

    def finalize_options(self):
        if self.bdist_dir is None:
            bdist_base = self.get_finalized_command('bdist').bdist_base
            self.bdist_dir = os.path.join(bdist_base, 'dumb')

        if self.format is None:
            try:
                self.format = self.default_format[os.name]
            except KeyError:
                raise DistutilsPlatformError, \
                      ("don't know how to create dumb built distributions " +
                       "on platform %s") % os.name

        self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'),
                                   ('plat_name', 'plat_name'))

    def run(self):
        if not self.skip_build:
            self.run_command('build')

        install = self.reinitialize_command('install', reinit_subcommands=1)
        install.root = self.bdist_dir
        install.skip_build = self.skip_build
        install.warn_dir = 0

        log.info("installing to %s" % self.bdist_dir)
        self.run_command('install')

        # And make an archive relative to the root of the
        # pseudo-installation tree.
        archive_basename = "%s.%s" % (self.distribution.get_fullname(),
                                      self.plat_name)

        # OS/2 objects to any ":" characters in a filename (such as when
        # a timestamp is used in a version) so change them to hyphens.
        if os.name == "os2":
            archive_basename = archive_basename.replace(":", "-")

        pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
        if not self.relative:
            archive_root = self.bdist_dir
        else:
            if (self.distribution.has_ext_modules()
                    and (install.install_base != install.install_platbase)):
                raise DistutilsPlatformError, \
                      ("can't make a dumb built distribution where "
                       "base and platbase are different (%s, %s)"
                       % (repr(install.install_base),
                          repr(install.install_platbase)))
            else:
                archive_root = os.path.join(
                    self.bdist_dir, ensure_relative(install.install_base))

        # Make the archive
        filename = self.make_archive(pseudoinstall_root,
                                     self.format,
                                     root_dir=archive_root,
                                     owner=self.owner,
                                     group=self.group)
        if self.distribution.has_ext_modules():
            pyversion = get_python_version()
        else:
            pyversion = 'any'
        self.distribution.dist_files.append(
            ('bdist_dumb', pyversion, filename))

        if not self.keep_temp:
            remove_tree(self.bdist_dir, dry_run=self.dry_run)
Example #40
0
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import print_function

import sys, os, collections

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
from distutils.util import get_platform
platform = '.%s-%s' % (get_platform(), sys.version[:3])
build_lib = os.path.abspath('../../../build/lib' + platform)
sys.path.insert(0, build_lib)
sys.path.insert(0, os.path.abspath('_extensions'))  # for sphinx extensions
print("-- path --")
print("\n".join(sys.path))

#need to import src.sas.sasview init to access version number and dates
#use abspath as above to locate then import
sasview_path = os.path.abspath('../../../src/sas')
sys.path.append(sasview_path)
import sas.sasview

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Example #41
0
version = imp.load_source('version', 'lib/exabgp/version.py').version
description_rst = open('PYPI.rst').read() % {'version': version}

setup(
    name='exabgp',
    version=version,
    description='BGP swiss army knife',
    long_description=description_rst,
    author='Thomas Mangin',
    author_email='*****@*****.**',
    url='https://github.com/Exa-Networks/exabgp',
    license="BSD",
    keywords='bgp routing api sdn flowspec',
    platforms=[
        get_platform(),
    ],
    package_dir={'': 'lib'},
    packages=packages('lib'),
    #	scripts=['sbin/exabgp',],
    download_url='https://github.com/Exa-Networks/exabgp/archive/%s.tar.gz' %
    version,
    data_files=files_definition,
    install_requires=['setuptools'],
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Environment :: Console',
        'Intended Audience :: System Administrators',
        'Intended Audience :: Telecommunications Industry',
        'License :: OSI Approved :: BSD License',
        'Operating System :: POSIX',
Example #42
0
    def test_get_platform(self):

        # windows XP, 32bits
        os.name = 'nt'
        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
                       '[MSC v.1310 32 bit (Intel)]')
        sys.platform = 'win32'
        self.assertEqual(get_platform(), 'win32')

        # windows XP, amd64
        os.name = 'nt'
        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
                       '[MSC v.1310 32 bit (Amd64)]')
        sys.platform = 'win32'
        self.assertEqual(get_platform(), 'win-amd64')

        # windows XP, itanium
        os.name = 'nt'
        sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
                       '[MSC v.1310 32 bit (Itanium)]')
        sys.platform = 'win32'
        self.assertEqual(get_platform(), 'win-ia64')

        # macbook
        os.name = 'posix'
        sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
                       '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
        sys.platform = 'darwin'
        self._set_uname(('Darwin', 'macziade', '8.11.1',
                         ('Darwin Kernel Version 8.11.1: '
                          'Wed Oct 10 18:23:28 PDT 2007; '
                          'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'

        get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
                                       '-fwrapv -O3 -Wall -Wstrict-prototypes')

        cursize = sys.maxsize
        sys.maxsize = (2**31) - 1
        try:
            self.assertEqual(get_platform(), 'macosx-10.3-i386')
        finally:
            sys.maxsize = cursize

        # macbook with fat binaries (fat, universal or fat64)
        get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
        get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')

        self.assertEqual(get_platform(), 'macosx-10.4-fat')

        os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.1'
        self.assertEqual(get_platform(), 'macosx-10.4-fat')

        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')

        self.assertEqual(get_platform(), 'macosx-10.4-intel')

        get_config_vars()['CFLAGS'] = (
            '-arch x86_64 -arch ppc -arch i386 -isysroot '
            '/Developer/SDKs/MacOSX10.4u.sdk  '
            '-fno-strict-aliasing -fno-common '
            '-dynamic -DNDEBUG -g -O3')
        self.assertEqual(get_platform(), 'macosx-10.4-fat3')

        get_config_vars()['CFLAGS'] = (
            '-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
            '/Developer/SDKs/MacOSX10.4u.sdk  '
            '-fno-strict-aliasing -fno-common '
            '-dynamic -DNDEBUG -g -O3')
        self.assertEqual(get_platform(), 'macosx-10.4-universal')

        get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot '
                                       '/Developer/SDKs/MacOSX10.4u.sdk  '
                                       '-fno-strict-aliasing -fno-common '
                                       '-dynamic -DNDEBUG -g -O3')

        self.assertEqual(get_platform(), 'macosx-10.4-fat64')

        for arch in ('ppc', 'i386', 'x86_64', 'ppc64'):
            get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
                                           '/Developer/SDKs/MacOSX10.4u.sdk  '
                                           '-fno-strict-aliasing -fno-common '
                                           '-dynamic -DNDEBUG -g -O3' %
                                           (arch, ))

            self.assertEqual(get_platform(), 'macosx-10.4-%s' % (arch, ))

        # linux debian sarge
        os.name = 'posix'
        sys.version = ('2.3.5 (#1, Jul  4 2007, 17:28:59) '
                       '\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]')
        sys.platform = 'linux2'
        self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7',
                         '#1 Mon Apr 30 17:25:38 CEST 2007', 'i686'))

        self.assertEqual(get_platform(), 'linux-i686')
Example #43
0
        'p': 'complex_double',
        'real32': 'complex_float',
        'real64': 'complex_double'
    }
}
hooks.F90_COMPILE_ARGS_GFORTRAN += ['-fpack-derived']
hooks.F90_COMPILE_ARGS_IFORT += ['-align norecords']
if sys.platform == 'darwin':
    hooks.F90_COMPILE_OPT_GFORTRAN = ['-O2']

name = 'pysimulators'
long_description = open('README.rst').read()
keywords = 'scientific computing'
platforms = 'MacOS X,Linux,Solaris,Unix,Windows'
define_macros = [('GFORTRAN', None), ('PRECISION_REAL', 8)]
mod_dir = 'build/temp.' + get_platform() + '-%s.%s' % sys.version_info[:2]

flib = ('fmod', {
    'sources': [
        'src/module_precision.f90', 'src/module_tamasis.f90',
        'src/module_string.f90', 'src/module_fitstools.f90',
        'src/module_geometry.f90.src', 'src/module_math.f90.src',
        'src/module_math_old.f90', 'src/module_pointingmatrix.f90',
        'src/module_operators.f90.src', 'src/module_sort.f90',
        'src/module_wcs.f90'
    ],
    'depends': [],
    'macros':
    define_macros,
    'include_dirs': [np.get_include()]
})
Example #44
0
import sys
import os

try:
    # Use Cython if available:
    from Cython.Build import cythonize
except ImportError:
    # Otherwise, use the shipped .c file:
    def cythonize(extensions):
        return extensions


# Windows:  win32/win-amd64
# Linux:    linux-x86_64/...
# Mac:      darwin*
IS_WIN = get_platform().startswith('win')


# We parse command line options using our own mechanim. We could use
# build_ext.user_options instead, but then these parameters can be passed
# only to the 'build_ext' command, not to 'build', 'develop', or
# 'install'.
def command_line_options():
    usage = 'setup.py <command> [options]'
    parser = ArgumentParser(description=__doc__, usage=usage)
    parser.add_argument('--madxdir',
                        dest='madxdir',
                        default=os.environ.get('MADXDIR'),
                        help='MAD-X installation prefix')
    option(parser, 'static', 'do {NOT}use static linkage')
    option(parser, 'shared', 'MAD-X was {NOT}built with BUILD_SHARED_LIBS')
Example #45
0
 def setup_path(self):
     # copied from distutils/command/build.py
     self.plat_name = get_platform()
     plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3])
     self.build_lib = os.path.join("build", "lib" + plat_specifier)
     sys.path.insert(0, self.build_lib)