@@ -54,49 +54,64 @@ def build_extension(self, ext: Extension):
5454 "-DNLOPT_GUILE=OFF" ,
5555 "-DNLOPT_MATLAB=OFF" ,
5656 "-DNLOPT_OCTAVE=OFF" ,
57- ext .source_dir .as_posix ()
57+ ext .source_dir .as_posix (),
5858 ]
5959
6060 if platform .system () == "Windows" :
61- cmd .insert (2 , f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{ self .config .upper ()} ={ _ed } " )
61+ cmd .insert (
62+ 2 , f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{ self .config .upper ()} ={ _ed } "
63+ )
6264
6365 execute_command (
6466 cmd = cmd ,
6567 cwd = build_dir ,
6668 env = {
6769 ** os .environ .copy (),
68- "CXXFLAGS" : f'{ os .environ .get ("CXXFLAGS" , "" )} -DVERSION_INFO="{ self .distribution .get_version ()} "'
69- })
70+ "CXXFLAGS" : f'{ os .environ .get ("CXXFLAGS" , "" )} -DVERSION_INFO="{ self .distribution .get_version ()} "' ,
71+ },
72+ )
7073
7174 # build the DLL
72- execute_command ([
73- 'cmake' ,
74- '--build' ,
75- '.' ,
76- '--config' ,
77- self .config ,
78- "--" ,
79- "-m" if platform .system () == "Windows" else "-j2"
80- ], cwd = build_dir )
75+ execute_command (
76+ [
77+ "cmake" ,
78+ "--build" ,
79+ "." ,
80+ "--config" ,
81+ self .config ,
82+ "--" ,
83+ "-m" if platform .system () == "Windows" else "-j2" ,
84+ ],
85+ cwd = build_dir ,
86+ )
8187
8288 # Copy over the important bits
8389 nlopt_py = build_dir / "extern" / "nlopt" / "src" / "swig" / "python" / "nlopt.py"
8490
85- logging .info (f"Ext Dir - { ext_dir } \n " + '\n ' .join (f' - { file .as_posix ()} ' for file in ext_dir .rglob ('*' )))
91+ logging .info (
92+ f"Ext Dir - { ext_dir } \n "
93+ + "\n " .join (f" - { file .as_posix ()} " for file in ext_dir .rglob ("*" ))
94+ )
8695 for folder in [ext_dir , nlopt_py .parent ]:
87- logging .info (f'Files in { folder .as_posix ()} \n ' + '\n ' .join (f' - { f .name } ' for f in folder .iterdir ()))
88-
89- logging .info (f"Attempting to copy nlopt.py file from { nlopt_py .parent .as_posix ()} to { ext_dir .as_posix ()} " )
96+ logging .info (
97+ f"Files in { folder .as_posix ()} \n "
98+ + "\n " .join (f" - { f .name } " for f in folder .iterdir ())
99+ )
100+
101+ logging .info (
102+ f"Attempting to copy nlopt.py file from { nlopt_py .parent .as_posix ()} to { ext_dir .as_posix ()} "
103+ )
90104 if not nlopt_py .exists ():
91105 raise RuntimeError ("swig python file was not generated" )
92106
93107 shutil .copy2 (nlopt_py , ext_dir / "nlopt.py" )
94- with open (ext_dir / "__init__.py" , 'w' ) as f :
95- f .write (f"""
96- from .nlopt import *
108+ with open (ext_dir / "__init__.py" , "w" ) as f :
109+ f .write (
110+ f""" from .nlopt import *
97111
98112__version__ = '{ ext .version } '
99- """ .strip () + "\n " )
113+ """ .lstrip ()
114+ )
100115
101116
102117def create_directory (path : Path ):
0 commit comments