1717warningColor = '\033 [93m'
1818endColor = '\033 [0m'
1919
20+ # TODO: Remove this check (deprecated, same as managePipEnvironment flag below).
2021try :
2122 from conans import __version__ as conan_version
2223 if int (conan_version [0 ]) >= 2 :
3940bskModuleOptionsBool = {
4041 "opNav" : False ,
4142 "vizInterface" : True ,
42- "buildProject" : True
43+ "buildProject" : True ,
44+
45+ # XXX: Set managePipEnvironment to True to keep the old behaviour of
46+ # managing the `pip` environment directly (upgrading, installing Python
47+ # packages, etc.). This behaviour is deprecated using the new pip-based
48+ # installation, and should only be required for users who are still calling
49+ # this file with `python conanfile.py ...`.
50+ # TODO: Remove all managePipEnvironment behaviour!
51+ "managePipEnvironment" : True
4352}
4453bskModuleOptionsString = {
45- "autoKey" : "" ,
46- "pathToExternalModules" : ""
54+ "autoKey" : "" , # TODO: Remove, used only for managePipEnvironment.
55+ "pathToExternalModules" : "" ,
56+ "pyLimitedAPI" : "" ,
4757}
4858bskModuleOptionsFlag = {
4959 "clean" : False ,
50- "allOptPkg" : False
60+ "allOptPkg" : False # TODO: Remove, used only for managePipEnvironment.
5161}
5262
5363# this statement is needed to enable Windows to print ANSI codes in the Terminal
@@ -72,15 +82,6 @@ class BasiliskConan(ConanFile):
7282 options = {"generator" : "ANY" }
7383 default_options = {"generator" : "" }
7484
75- # ensure latest pip is installed
76- if is_running_virtual_env () or platform .system () == "Windows" :
77- cmakeCmdString = 'python -m pip install --upgrade pip'
78- else :
79- cmakeCmdString = 'python3 -m pip install --upgrade pip'
80- print (statusColor + "Updating pip:" + endColor )
81- print (cmakeCmdString )
82- os .system (cmakeCmdString )
83-
8485 for opt , value in bskModuleOptionsBool .items ():
8586 options .update ({opt : [True , False ]})
8687 default_options .update ({opt : value })
@@ -119,10 +120,30 @@ class BasiliskConan(ConanFile):
119120 pass
120121
121122 def system_requirements (self ):
123+ if not self .options .managePipEnvironment :
124+ return # Don't need to manage any pip requirements
125+
126+ # TODO: Remove everything here, which only runs if we have set
127+ # managePipEnvironment (i.e. conanfile.py-based build).
128+
129+ # ensure latest pip is installed
130+ if is_running_virtual_env () or platform .system () == "Windows" :
131+ cmakeCmdString = 'python -m pip install --upgrade pip'
132+ else :
133+ cmakeCmdString = 'python3 -m pip install --upgrade pip'
134+ print (statusColor + "Updating pip:" + endColor )
135+ print (cmakeCmdString )
136+ os .system (cmakeCmdString )
137+
122138 reqFile = open ('requirements.txt' , 'r' )
123139 required = reqFile .read ().replace ("`" , "" ).split ('\n ' )
124140 reqFile .close ()
125141 pkgList = [x .lower () for x in required ]
142+ pkgList += [
143+ # XXX: Add build system requirements which were removed from requirements.txt.
144+ "conan>=1.40.1, <2.00.0" ,
145+ "parse>=1.18.0" ,
146+ ]
126147
127148 checkStr = "Required"
128149 if self .options .allOptPkg :
@@ -268,10 +289,24 @@ def build(self):
268289 cmake .definitions ["BUILD_VIZINTERFACE" ] = self .options .vizInterface
269290 cmake .definitions ["EXTERNAL_MODULES_PATH" ] = self .options .pathToExternalModules
270291 cmake .definitions ["PYTHON_VERSION" ] = f"{ sys .version_info .major } .{ sys .version_info .minor } "
292+
293+ if self .options .pyLimitedAPI != "" :
294+ cmake .definitions ["PY_LIMITED_API" ] = self .options .pyLimitedAPI
295+
296+ # Set the build rpath, since we don't install the targets, so that the
297+ # shared libraries can find each other using relative paths.
298+ cmake .definitions ["CMAKE_BUILD_RPATH_USE_ORIGIN" ] = True
299+
300+ # TODO: Set the minimum buildable MacOS version.
301+ # (This might be necessary but I'm not sure yet, leaving it here for future reference.)
302+ # cmake.definitions["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.13"
303+
271304 cmake .parallel = True
272305 print (statusColor + "Configuring cmake..." + endColor )
273306 cmake .configure ()
274- self .add_basilisk_to_sys_path ()
307+ if self .options .managePipEnvironment :
308+ # TODO: Remove this, it's only needed when conanfile.py is handling pip installations.
309+ self .add_basilisk_to_sys_path ()
275310 if self .options .buildProject :
276311 print (statusColor + "\n Compiling Basilisk..." + endColor )
277312 start = datetime .now ()
@@ -294,7 +329,7 @@ def build(self):
294329
295330 def add_basilisk_to_sys_path (self ):
296331 print ("Adding Basilisk module to python\n " )
297- add_basilisk_module_command = [sys .executable , "-m" , "pip" , "install" , "-e" , "." ]
332+ add_basilisk_module_command = [sys .executable , "-m" , "pip" , "install" , "--no-build-isolation" , "- e" , "." ]
298333 if not is_running_virtual_env () and self .options .autoKey != 's' :
299334 add_basilisk_module_command .append ("--user" )
300335
0 commit comments