MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / install

Method install

pipcl.py:1078–1143  ·  view source on GitHub ↗

Called by `handle_argv()` to handle `install` command..

(self, record_path=None, root=None)

Source from the content-addressed store, hash-verified

1076
1077
1078 def install(self, record_path=None, root=None):
1079 '''
1080 Called by `handle_argv()` to handle `install` command..
1081 '''
1082 log2( f'{record_path=} {root=}')
1083
1084 # Do a build and get list of files to install.
1085 #
1086 items = list()
1087 if self.fn_build:
1088 items = self._call_fn_build( dict())
1089
1090 root2 = install_dir(root)
1091 log2( f'{root2=}')
1092
1093 log1( f'Installing into: {root2!r}')
1094 dist_info_dir = self._dist_info_dir()
1095
1096 if not record_path:
1097 record_path = f'{root2}/{dist_info_dir}/RECORD'
1098 record = _Record()
1099
1100 def add_file(from_, to_abs, to_rel):
1101 os.makedirs( os.path.dirname( to_abs), exist_ok=True)
1102 if isinstance(from_, bytes):
1103 log2(f'Copying content into {to_abs}.')
1104 with open(to_abs, 'wb') as f:
1105 f.write(from_)
1106 record.add_content(from_, to_rel)
1107 else:
1108 log0(f'{from_=}')
1109 log2(f'Copying from {os.path.relpath(from_, self.root)} to {to_abs}')
1110 shutil.copy2( from_, to_abs)
1111 record.add_file(from_, to_rel)
1112
1113 def add_str(content, to_abs, to_rel):
1114 log2( f'Writing to: {to_abs}')
1115 os.makedirs( os.path.dirname( to_abs), exist_ok=True)
1116 with open( to_abs, 'w') as f:
1117 f.write( content)
1118 record.add_content(content, to_rel)
1119
1120 for item in items:
1121 from_, (to_abs, to_rel) = self._fromto(item)
1122 log0(f'{from_=} {to_abs=} {to_rel=}')
1123 to_abs2 = f'{root2}/{to_rel}'
1124 add_file( from_, to_abs2, to_rel)
1125
1126 add_str( self._metainfo(), f'{root2}/{dist_info_dir}/METADATA', f'{dist_info_dir}/METADATA')
1127
1128 if self.license:
1129 add_str( self.license, f'{root2}/{dist_info_dir}/COPYING', f'{dist_info_dir}/COPYING')
1130
1131 entry_points_text = self._entry_points_text()
1132 if entry_points_text:
1133 add_str(
1134 entry_points_text,
1135 f'{root2}/{dist_info_dir}/entry_points.txt',

Callers 1

handle_argvMethod · 0.95

Calls 12

_call_fn_buildMethod · 0.95
_dist_info_dirMethod · 0.95
_fromtoMethod · 0.95
_metainfoMethod · 0.95
_entry_points_textMethod · 0.95
log2Function · 0.85
install_dirFunction · 0.85
log1Function · 0.85
_RecordClass · 0.85
log0Function · 0.85
writeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected