18
18
# Whether to create libarrow symlinks on posix systems.
19
19
CREATE_LIBARROW_SYMLINKS = os .environ .get ("MONGO_CREATE_LIBARROW_SYMLINKS" , "1" )
20
20
21
+ LIBBSON_VERSION = os .environ .get ("LIBBSON_VERSION" , "1.0.0" )
22
+
21
23
# Set a default value for MACOSX_DEPLOYMENT_TARGET.
22
24
os .environ .setdefault ("MACOSX_DEPLOYMENT_TARGET" , "10.15" )
23
25
@@ -40,19 +42,20 @@ def get_min_libbson_version():
40
42
41
43
42
44
def append_libbson_flags (module ):
43
- pc_path = "libbson-1.0"
45
+ BSON_MAJOR_VERSION = int (LIBBSON_VERSION [0 ])
46
+ pc_path = "libbson-1.0" if BSON_MAJOR_VERSION == 1 else "bson2"
44
47
install_dir = os .environ .get ("LIBBSON_INSTALL_DIR" )
45
48
if install_dir :
46
49
install_dir = os .path .abspath (install_dir )
47
50
48
51
# Handle the copy-able library file if applicable.
49
52
if COPY_LIBBSON :
50
53
if platform == "darwin" :
51
- lib_file = "libbson-1.0.0.dylib"
54
+ lib_file = "libbson-1.0.0.dylib" if BSON_MAJOR_VERSION == 1 else "bson2.dylib"
52
55
elif platform == "linux" :
53
- lib_file = "libbson-1.0.so.0"
56
+ lib_file = "libbson-1.0.so.0" if BSON_MAJOR_VERSION == 1 else "bson2.so.0"
54
57
else : # windows
55
- lib_file = "bson-1.0.dll"
58
+ lib_file = "bson-1.0.dll" if BSON_MAJOR_VERSION == 1 else "bson2.dll"
56
59
lib_dir = "bin" if IS_WIN else "lib*"
57
60
lib_dir = glob .glob (os .path .join (install_dir , lib_dir ))
58
61
if lib_dir :
@@ -81,16 +84,18 @@ def append_libbson_flags(module):
81
84
if IS_WIN :
82
85
# Note: we replace any forward slashes with backslashes so the path
83
86
# can be parsed by bash.
84
- lib_path = os .path .join (lib_dir , "bson-1.0.lib" ).replace (os .sep , "/" )
87
+ bson_lib = "bson-1.0.lib" if BSON_MAJOR_VERSION == 1 else "bson2.lib"
88
+ lib_path = os .path .join (lib_dir , bson_lib ).replace (os .sep , "/" )
85
89
if os .path .exists (lib_path ):
86
90
module .extra_link_args = [lib_path ]
87
- include_dir = os .path .join (install_dir , "include" , "libbson-1.0" ).replace (
91
+ include_path = "libbson-1.0" if BSON_MAJOR_VERSION == 1 else "bson2"
92
+ include_dir = os .path .join (install_dir , "include" , include_path ).replace (
88
93
os .sep , "/"
89
94
)
90
95
module .include_dirs .append (include_dir )
91
96
else :
92
97
raise ValueError (f"Could not find the compiled libbson in { install_dir } " )
93
- pc_path = os .path .join (install_dir , lib_dir , "pkgconfig" , "libbson-1.0 .pc" )
98
+ pc_path = os .path .join (install_dir , lib_dir , "pkgconfig" , f" { pc_path } .pc" )
94
99
95
100
elif IS_WIN :
96
101
raise ValueError ("We require a LIBBSON_INSTALL_DIR with a compiled library on Windows" )
0 commit comments