From 86ad19dd52d8474d6b342698913d0b9d909c4648 Mon Sep 17 00:00:00 2001 From: laggykiller <61652821+laggykiller@users.noreply.github.com> Date: Sat, 24 Feb 2024 12:03:13 +0800 Subject: [PATCH] Cleaning setup.py --- pyproject.toml | 5 +- setup.py | 131 ++++++++++++++++++++++++------------------------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0f74212..5ddb75a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,4 +27,7 @@ requires = [ "setuptools>=45", "wheel", ] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = ["sqlcipher3"] \ No newline at end of file diff --git a/setup.py b/setup.py index ac4771c..3a08a06 100644 --- a/setup.py +++ b/setup.py @@ -114,74 +114,71 @@ def quote_argument(arg): q = '\\"' if sys.platform == "win32" and sys.version_info < (3, 7) else '"' return q + arg + q -define_macros = [ - ("MODULE_NAME", quote_argument("sqlcipher3.dbapi2")), - ("ENABLE_FTS3", "1"), - ("ENABLE_FTS3_PARENTHESIS", "1"), - ("ENABLE_FTS4", "1"), - ("ENABLE_FTS5", "1"), - ("ENABLE_JSON1", "1"), - ("ENABLE_LOAD_EXTENSION", "1"), - ("ENABLE_RTREE", "1"), - ("ENABLE_STAT4", "1"), - ("ENABLE_UPDATE_DELETE_LIMIT", "1"), - ("SOUNDEX", "1"), - ("USE_URI", "1"), - # Required for SQLCipher. - ("SQLITE_HAS_CODEC", "1"), - ("HAS_CODEC", "1"), - ("SQLITE_TEMP_STORE", "2"), - # Increase the maximum number of "host parameters". - ("SQLITE_MAX_VARIABLE_NUMBER", "250000"), - # Additional nice-to-have. - ("SQLITE_DEFAULT_PAGE_SIZE", "4096"), - ("SQLITE_DEFAULT_CACHE_SIZE", "-8000"), - ("inline", "__inline"), -] - -# Configure the compiler -arch = get_arch() -if arch == "universal2": - conan_info_x64 = install_openssl("x86_64") - add_deps(conan_info_x64, library_dirs, include_dirs) - conan_info_arm = install_openssl("armv8") - add_deps(conan_info_arm, library_dirs, include_dirs) - zlib_required = check_zlib_required(conan_info_x64) -else: - conan_info = install_openssl(arch) - add_deps(conan_info, library_dirs, include_dirs) - zlib_required = check_zlib_required(conan_info) - -# Configure the linker -extra_link_args = [] -if sys.platform == "win32": - # https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md#linking-native-applications - extra_link_args.append("WS2_32.LIB") - extra_link_args.append("GDI32.LIB") - extra_link_args.append("ADVAPI32.LIB") - extra_link_args.append("CRYPT32.LIB") - extra_link_args.append("USER32.LIB") - if zlib_required: - extra_link_args.append("zlib.lib") - extra_link_args.append("libcrypto.lib") -else: - # Include math library, required for fts5, and crypto. - extra_link_args.extend(["-lm", "-lcrypto"]) - -module = Extension( - name="sqlcipher3._sqlite3", - sources=sources, - define_macros=define_macros, - library_dirs=library_dirs, - include_dirs=include_dirs, - extra_link_args=extra_link_args, - language="c", -) - if __name__ == "__main__": + define_macros = [ + ("MODULE_NAME", quote_argument("sqlcipher3.dbapi2")), + ("ENABLE_FTS3", "1"), + ("ENABLE_FTS3_PARENTHESIS", "1"), + ("ENABLE_FTS4", "1"), + ("ENABLE_FTS5", "1"), + ("ENABLE_JSON1", "1"), + ("ENABLE_LOAD_EXTENSION", "1"), + ("ENABLE_RTREE", "1"), + ("ENABLE_STAT4", "1"), + ("ENABLE_UPDATE_DELETE_LIMIT", "1"), + ("SOUNDEX", "1"), + ("USE_URI", "1"), + # Required for SQLCipher. + ("SQLITE_HAS_CODEC", "1"), + ("HAS_CODEC", "1"), + ("SQLITE_TEMP_STORE", "2"), + # Increase the maximum number of "host parameters". + ("SQLITE_MAX_VARIABLE_NUMBER", "250000"), + # Additional nice-to-have. + ("SQLITE_DEFAULT_PAGE_SIZE", "4096"), + ("SQLITE_DEFAULT_CACHE_SIZE", "-8000"), + ("inline", "__inline"), + ] + + # Configure the compiler + arch = get_arch() + if arch == "universal2": + conan_info_x64 = install_openssl("x86_64") + add_deps(conan_info_x64, library_dirs, include_dirs) + conan_info_arm = install_openssl("armv8") + add_deps(conan_info_arm, library_dirs, include_dirs) + zlib_required = check_zlib_required(conan_info_x64) + else: + conan_info = install_openssl(arch) + add_deps(conan_info, library_dirs, include_dirs) + zlib_required = check_zlib_required(conan_info) + + # Configure the linker + extra_link_args = [] + if sys.platform == "win32": + # https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md#linking-native-applications + extra_link_args.append("WS2_32.LIB") + extra_link_args.append("GDI32.LIB") + extra_link_args.append("ADVAPI32.LIB") + extra_link_args.append("CRYPT32.LIB") + extra_link_args.append("USER32.LIB") + if zlib_required: + extra_link_args.append("zlib.lib") + extra_link_args.append("libcrypto.lib") + else: + # Include math library, required for fts5, and crypto. + extra_link_args.extend(["-lm", "-lcrypto"]) + + module = Extension( + name="sqlcipher3._sqlite3", + sources=sources, + define_macros=define_macros, + library_dirs=library_dirs, + include_dirs=include_dirs, + extra_link_args=extra_link_args, + language="c", + ) + setup( - platforms="ALL", - package_dir={"sqlcipher3": "sqlcipher3"}, - packages=["sqlcipher3"], ext_modules=[module], )