diff options
| author | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-13 15:21:19 +0200 | 
|---|---|---|
| committer | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-13 20:41:39 +0200 | 
| commit | ee4653731af43ee5d3a82e4025869538d3345f0a (patch) | |
| tree | b4f52c64701f3cdcdbdaf6f79aba492bfc4d51d7 | |
| parent | 595d19694e341184ddcdda4b9847c62a7692f552 (diff) | |
cleanup setup
removing some past experiments, not used
| -rw-r--r-- | setup.py | 189 | 
1 files changed, 46 insertions, 143 deletions
| @@ -130,151 +130,54 @@ class LibSQLCipherBuilder(build_ext):  class AmalgamationBuildExt(build_ext): -    amalgamation = True  # We want amalgamation on the default build for now -    static = False +     +    amalgamation = True      def build_extension(self, ext): -        if self.amalgamation: -            # build with fulltext search enabled -            ext.define_macros.append( -                ("SQLITE_ENABLE_FTS3", "1")) -            ext.define_macros.append( -                ("SQLITE_ENABLE_FTS5", "1")) -            ext.define_macros.append( -                ("SQLITE_ENABLE_RTREE", "1")) - -            # SQLCipher options -            ext.define_macros.append( -                ("SQLITE_ENABLE_LOAD_EXTENSION", "1")) -            ext.define_macros.append( -                ("SQLITE_HAS_CODEC", "1")) -            ext.define_macros.append( -                ("SQLITE_TEMP_STORE", "2")) -            ext.define_macros.append( -                ("HAVE_USLEEP", "1")) - -            ext.sources.append(os.path.join(AMALGAMATION_ROOT, "sqlite3.c")) -            ext.include_dirs.append(AMALGAMATION_ROOT) - -            if sys.platform == "win32": -                # Try to locate openssl -                openssl_conf = os.environ.get('OPENSSL_CONF') -                if not openssl_conf: -                    sys.exit('Fatal error: OpenSSL could not be detected!') -                openssl = os.path.dirname(os.path.dirname(openssl_conf)) - -                # Configure the compiler -                ext.include_dirs.append(os.path.join(openssl, "include")) -                ext.define_macros.append(("inline", "__inline")) - -                # Configure the linker -                if self.compiler.compiler_type == "msvc": -                    ext.extra_link_args.append("libeay32.lib") -                    ext.extra_link_args.append( -                        "/LIBPATH:" + os.path.join(openssl, "lib") -                    ) -                if self.compiler.compiler_type == "mingw32": -                    ext.extra_link_args.append("-lcrypto")      -            else: +        # build with fulltext search enabled +        ext.define_macros.append( +            ("SQLITE_ENABLE_FTS3", "1")) +        ext.define_macros.append( +            ("SQLITE_ENABLE_FTS5", "1")) +        ext.define_macros.append( +            ("SQLITE_ENABLE_RTREE", "1")) + +        # SQLCipher options +        ext.define_macros.append( +            ("SQLITE_ENABLE_LOAD_EXTENSION", "1")) +        ext.define_macros.append( +            ("SQLITE_HAS_CODEC", "1")) +        ext.define_macros.append( +            ("SQLITE_TEMP_STORE", "2")) +        ext.define_macros.append( +            ("HAVE_USLEEP", "1")) + +        ext.sources.append(os.path.join(AMALGAMATION_ROOT, "sqlite3.c")) +        ext.include_dirs.append(AMALGAMATION_ROOT) + +        if sys.platform == "win32": +            # Try to locate openssl +            openssl_conf = os.environ.get('OPENSSL_CONF') +            if not openssl_conf: +                sys.exit('Fatal error: OpenSSL could not be detected!') +            openssl = os.path.dirname(os.path.dirname(openssl_conf)) + +            # Configure the compiler +            ext.include_dirs.append(os.path.join(openssl, "include")) +            ext.define_macros.append(("inline", "__inline")) + +            # Configure the linker +            if self.compiler.compiler_type == "msvc": +                ext.extra_link_args.append("libeay32.lib") +                ext.extra_link_args.append( +                    "/LIBPATH:" + os.path.join(openssl, "lib") +                ) +            if self.compiler.compiler_type == "mingw32":                  ext.extra_link_args.append("-lcrypto") - -        if self.static: -            self._build_extension(ext) -        else: -            build_ext.build_extension(self, ext) - -    def _build_extension(self, ext): -        sources = ext.sources -        if sources is None or type(sources) not in (ListType, TupleType): -            raise DistutilsSetupError, \ -                ("in 'ext_modules' option (extension '%s'), " + -                 "'sources' must be present and must be " + -                 "a list of source filenames") % ext.name -        sources = list(sources) - -        ext_path = self.get_ext_fullpath(ext.name) -        depends = sources + ext.depends -        if not (self.force or newer_group(depends, ext_path, 'newer')): -            log.debug("skipping '%s' extension (up-to-date)", ext.name) -            return          else: -            log.info("building '%s' extension", ext.name) - -        # First, scan the sources for SWIG definition files (.i), run -        # SWIG on 'em to create .c files, and modify the sources list -        # accordingly. -        sources = self.swig_sources(sources, ext) - -        # Next, compile the source code to object files. - -        # XXX not honouring 'define_macros' or 'undef_macros' -- the -        # CCompiler API needs to change to accommodate this, and I -        # want to do one thing at a time! - -        # Two possible sources for extra compiler arguments: -        #   - 'extra_compile_args' in Extension object -        #   - CFLAGS environment variable (not particularly -        #     elegant, but people seem to expect it and I -        #     guess it's useful) -        # The environment variable should take precedence, and -        # any sensible compiler will give precedence to later -        # command line args.  Hence we combine them in order: -        extra_args = ext.extra_compile_args or [] - -        macros = ext.define_macros[:] -        for undef in ext.undef_macros: -            macros.append((undef,)) - -        objects = self.compiler.compile(sources, -                                        output_dir=self.build_temp, -                                        macros=macros, -                                        include_dirs=ext.include_dirs, -                                        debug=self.debug, -                                        extra_postargs=extra_args, -                                        depends=ext.depends) - -        # XXX -- this is a Vile HACK! -        # -        # The setup.py script for Python on Unix needs to be able to -        # get this list so it can perform all the clean up needed to -        # avoid keeping object files around when cleaning out a failed -        # build of an extension module.  Since Distutils does not -        # track dependencies, we have to get rid of intermediates to -        # ensure all the intermediates will be properly re-built. -        # -        self._built_objects = objects[:] - -        # Now link the object files together into a "shared object" -- -        # of course, first we have to figure out all the other things -        # that go into the mix. -        if ext.extra_objects: -            objects.extend(ext.extra_objects) -        extra_args = ext.extra_link_args or [] - -        # Detect target language, if not provided -        language = ext.language or self.compiler.detect_language(sources) - -        #self.compiler.link_shared_object( -            #objects, ext_path, -            #libraries=self.get_libraries(ext), -            #library_dirs=ext.library_dirs, -            #runtime_library_dirs=ext.runtime_library_dirs, -            #extra_postargs=extra_args, -            #export_symbols=self.get_export_symbols(ext), -            #debug=self.debug, -            #build_temp=self.build_temp, -            #target_lang=language) - -        # XXX may I have a static lib please? -        # hmm but then I cannot load that extension, or can I? -        output_dir = os.path.sep.join(ext_path.split(os.path.sep)[:-1]) - -        self.compiler.create_static_lib( -            objects, -            #XXX get library name ... splitting ext_path? -            "sqlite", -            output_dir=output_dir, -            target_lang=language) +            ext.extra_link_args.append("-lcrypto") + +        build_ext.build_extension(self, ext)      def __setattr__(self, k, v):          # Make sure we don't link against the SQLite @@ -309,7 +212,7 @@ def get_setup_args():          PYSQLITE_VERSION += "-%s" % PATCH_VERSION      # Need to bump minor version, patch handled badly. -    PYSQLCIPHER_VERSION = "2.6.9" +    PYSQLCIPHER_VERSION = "2.6.10"      setup_args = dict(          name="pysqlcipher", @@ -356,7 +259,7 @@ def get_setup_args():      if BUNDLED: -       build_ext = AmalgamationBuildExt  +       build_ext = AmalgamationBuildExt      else:         build_ext = LibSQLCipherBuilder | 
