@@ -119,66 +119,6 @@ def gen_packages_items():
119119 return packages
120120
121121
122- def add_mim_extension ():
123- """Add extra files that are required to support MIM into the package.
124-
125- These files will be added by creating a symlink to the originals if the
126- package is installed in `editable` mode (e.g. pip install -e .), or by
127- copying from the originals otherwise.
128- """
129-
130- # parse installment mode
131- if 'develop' in sys .argv :
132- # installed by `pip install -e .`
133- mode = 'symlink'
134- elif 'sdist' in sys .argv or 'bdist_wheel' in sys .argv :
135- # installed by `pip install .`
136- # or create source distribution by `python setup.py sdist`
137- mode = 'copy'
138- else :
139- return
140-
141- filenames = ['tools' , 'configs' , 'model-index.yml' ]
142- repo_path = osp .dirname (__file__ )
143- mim_path = osp .join (repo_path , 'mmpretrain' , '.mim' )
144- os .makedirs (mim_path , exist_ok = True )
145-
146- for filename in filenames :
147- if osp .exists (filename ):
148- src_path = osp .join (repo_path , filename )
149- tar_path = osp .join (mim_path , filename )
150-
151- if osp .isfile (tar_path ) or osp .islink (tar_path ):
152- os .remove (tar_path )
153- elif osp .isdir (tar_path ):
154- shutil .rmtree (tar_path )
155-
156- if mode == 'symlink' :
157- src_relpath = osp .relpath (src_path , osp .dirname (tar_path ))
158- try :
159- os .symlink (src_relpath , tar_path )
160- except OSError :
161- # Creating a symbolic link on windows may raise an
162- # `OSError: [WinError 1314]` due to privilege. If
163- # the error happens, the src file will be copied
164- mode = 'copy'
165- warnings .warn (
166- f'Failed to create a symbolic link for { src_relpath } , '
167- f'and it will be copied to { tar_path } ' )
168- else :
169- continue
170-
171- if mode == 'copy' :
172- if osp .isfile (src_path ):
173- shutil .copyfile (src_path , tar_path )
174- elif osp .isdir (src_path ):
175- shutil .copytree (src_path , tar_path )
176- else :
177- warnings .warn (f'Cannot copy file { src_path } .' )
178- else :
179- raise ValueError (f'Invalid mode { mode } ' )
180-
181-
182122if __name__ == '__main__' :
183123 setup (name = 'trailmet' ,
184124 version = get_version (),
0 commit comments