Guest User

Untitled

a guest
Oct 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. from distutils.ccompiler import new_compiler
  2. from sysconfig import get_paths
  3. import os
  4.  
  5. project_name = "slimey_project"
  6. source = ['source1.c']
  7. include_dirs = ['include']
  8. build_dir = os.path.join(os.path.dirname(__file__), 'build')
  9.  
  10. class StaticLib(Command):
  11. description = 'build static lib'
  12. user_options = [] # do not remove, needs to be stubbed out!
  13. python_info = get_paths()
  14.  
  15. def initialize_options(self):
  16. pass
  17.  
  18. def finalize_options(self):
  19. pass
  20.  
  21. def run(self):
  22. # Create compiler with default options
  23. c = new_compiler()
  24.  
  25. # Optionally add include directories etc.
  26. for d in include_dirs:
  27. c.add_include_dir(d)
  28.  
  29. c.add_include_dir(self.python_info['include'])
  30. # Compile into .o files
  31. objects = c.compile(sources)
  32.  
  33. # Create static or shared library
  34. c.create_static_lib(objects, project_name, output_dir=build_dir)
Add Comment
Please, Sign In to add comment