def generate(): assert os.path.isdir(REQ_BASE_PATH) prefix_code = "\n".join([ requirements_definitions(REQ_BASE_PATH, REQ_FILENAMES), get_code(PREFIX_SCRIPT, generate_bootstrap.INSTALL_PIP_MARK), ]) generate_bootstrap.generate_bootstrap( out_filename=BOOT_FILEPATH, add_extend_parser=os.path.join(SOURCES_PATH, "extend_parser.py"), add_adjust_options=os.path.join(SOURCES_PATH, "adjust_options.py"), add_after_install=os.path.join(SOURCES_PATH, "after_install.py"), cut_mark="# --- CUT here ---", prefix= prefix_code, # Optional code that will be inserted before extend_parser() code part. suffix= None, # Optional code that will be inserted after after_install() code part. )
def requirements_definitions(): content = [] for filename in ("normal_installation.txt", "developer_installation.txt"): content.append("\n# requirements from %s" % filename) requirements_list = parse_requirements(filename) req_type = os.path.splitext(filename)[0].upper() content.append( "%s = %s" % (req_type, pprint.pformat(requirements_list)) ) return "\n".join(content) if __name__ == '__main__': prefix_code = "\n".join([ requirements_definitions(), generate_bootstrap.get_code(PREFIX_SCRIPT, CUT_MARK), ]) # print(additional_code) generate_bootstrap.generate_bootstrap( out_filename=BOOTSTRAP_SCRIPT, add_extend_parser=EXTEND_PARSER_SCRIPT, add_adjust_options=ADJUST_OPTIONS_SCRIPT, add_after_install=AFTER_INSTALL_SCRIPT, cut_mark=CUT_MARK, prefix=prefix_code, suffix=None, )
#!/usr/bin/env python # coding: utf-8 import os from bootstrap_env.generate_bootstrap import generate_bootstrap EXAMPLE_PATH = os.path.abspath(os.path.dirname(__file__)) if __name__ == '__main__': generate_bootstrap( out_filename=os.path.join(EXAMPLE_PATH, "..", "..", "boot_example_env.py"), add_extend_parser=os.path.join(EXAMPLE_PATH, "extend_parser.py"), add_adjust_options=os.path.join(EXAMPLE_PATH, "adjust_options.py"), add_after_install=os.path.join(EXAMPLE_PATH, "after_install.py"), cut_mark="# --- CUT here ---", prefix= None, # Optional code that will be inserted before extend_parser() code part. suffix= None, # Optional code that will be inserted after after_install() code part. )
from bootstrap_env.utils.pip_utils import requirements_definitions REQ_FILENAMES=( "normal_installation.txt", "git_readonly_installation.txt", "developer_installation.txt", ) BASE_PATH=os.path.abspath(os.path.join(os.path.dirname(__file__))) PREFIX_SCRIPT=os.path.abspath(os.path.join(BASE_PATH, "source_prefix_code.py")) REQ_BASE_PATH=os.path.abspath(os.path.join(BASE_PATH, "..", "requirements")) print("requirement files path: %r" % REQ_BASE_PATH) if __name__ == '__main__': prefix_code = "\n".join([ requirements_definitions(REQ_BASE_PATH, REQ_FILENAMES), get_code(PREFIX_SCRIPT, INSTALL_PIP_MARK), ]) generate_bootstrap( out_filename=os.path.join("..", "boot_dragonpy.py"), add_extend_parser="source_extend_parser.py", add_adjust_options="source_adjust_options.py", add_after_install="source_after_install.py", cut_mark="# --- CUT here ---", prefix=prefix_code, # Optional code that will be inserted before extend_parser() code part. suffix=None, # Optional code that will be inserted after after_install() code part. )
def requirements_definitions(): content = [] for filename in ("normal_installation.txt", "developer_installation.txt"): content.append("\n# requirements from %s" % filename) requirements_list = parse_requirements(filename) req_type = os.path.splitext(filename)[0].upper() content.append("%s = %s" % (req_type, pprint.pformat(requirements_list))) return "\n".join(content) if __name__ == '__main__': prefix_code = "\n".join([ requirements_definitions(), generate_bootstrap.get_code(PREFIX_SCRIPT, CUT_MARK), ]) # print(additional_code) generate_bootstrap.generate_bootstrap( out_filename=BOOTSTRAP_SCRIPT, add_extend_parser=EXTEND_PARSER_SCRIPT, add_adjust_options=ADJUST_OPTIONS_SCRIPT, add_after_install=AFTER_INSTALL_SCRIPT, cut_mark=CUT_MARK, prefix=prefix_code, suffix=None, )
REQ_FILENAMES = ( "normal_installation.txt", "git_readonly_installation.txt", "developer_installation.txt", ) BASE_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__))) PREFIX_SCRIPT = os.path.abspath( os.path.join(BASE_PATH, "source_prefix_code.py")) REQ_BASE_PATH = os.path.abspath(os.path.join(BASE_PATH, "..", "requirements")) print("requirement files path: %r" % REQ_BASE_PATH) if __name__ == '__main__': prefix_code = "\n".join([ requirements_definitions(REQ_BASE_PATH, REQ_FILENAMES), get_code(PREFIX_SCRIPT, INSTALL_PIP_MARK), ]) generate_bootstrap( out_filename=os.path.join("..", "boot_dragonpy.py"), add_extend_parser="source_extend_parser.py", add_adjust_options="source_adjust_options.py", add_after_install="source_after_install.py", cut_mark="# --- CUT here ---", prefix= prefix_code, # Optional code that will be inserted before extend_parser() code part. suffix= None, # Optional code that will be inserted after after_install() code part. )
#!/usr/bin/env python # coding: utf-8 import os from bootstrap_env.generate_bootstrap import generate_bootstrap BASE_PATH = os.path.abspath(os.path.dirname(__file__)) SOURCE_PATH = os.path.join(BASE_PATH, "boot_sources") if __name__ == "__main__": generate_bootstrap( out_filename=os.path.join(BASE_PATH, "..", "boot_drqueue_env.py"), add_extend_parser=os.path.join(SOURCE_PATH, "extend_parser.py"), # add_adjust_options=os.path.join(SOURCE_PATH, "adjust_options.py"), add_after_install=os.path.join(SOURCE_PATH, "after_install.py"), cut_mark="# --- CUT here ---", prefix=None, # Optional code that will be inserted before extend_parser() code part. suffix=None, # Optional code that will be inserted after after_install() code part. )