Skip to content

Commit

Permalink
Merge pull request #141 from animesh-007/pypi-fix
Browse files Browse the repository at this point in the history
added fix
  • Loading branch information
animesh-007 authored Jul 10, 2023
2 parents 34cb6eb + ee8528e commit dfed07d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Build MMPretrain
- name: Build TrAILMET
run: |
pip install wheel
python setup.py sdist bdist_wheel
Expand Down
60 changes: 0 additions & 60 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,66 +119,6 @@ def gen_packages_items():
return packages


def add_mim_extension():
"""Add extra files that are required to support MIM into the package.
These files will be added by creating a symlink to the originals if the
package is installed in `editable` mode (e.g. pip install -e .), or by
copying from the originals otherwise.
"""

# parse installment mode
if 'develop' in sys.argv:
# installed by `pip install -e .`
mode = 'symlink'
elif 'sdist' in sys.argv or 'bdist_wheel' in sys.argv:
# installed by `pip install .`
# or create source distribution by `python setup.py sdist`
mode = 'copy'
else:
return

filenames = ['tools', 'configs', 'model-index.yml']
repo_path = osp.dirname(__file__)
mim_path = osp.join(repo_path, 'mmpretrain', '.mim')
os.makedirs(mim_path, exist_ok=True)

for filename in filenames:
if osp.exists(filename):
src_path = osp.join(repo_path, filename)
tar_path = osp.join(mim_path, filename)

if osp.isfile(tar_path) or osp.islink(tar_path):
os.remove(tar_path)
elif osp.isdir(tar_path):
shutil.rmtree(tar_path)

if mode == 'symlink':
src_relpath = osp.relpath(src_path, osp.dirname(tar_path))
try:
os.symlink(src_relpath, tar_path)
except OSError:
# Creating a symbolic link on windows may raise an
# `OSError: [WinError 1314]` due to privilege. If
# the error happens, the src file will be copied
mode = 'copy'
warnings.warn(
f'Failed to create a symbolic link for {src_relpath}, '
f'and it will be copied to {tar_path}')
else:
continue

if mode == 'copy':
if osp.isfile(src_path):
shutil.copyfile(src_path, tar_path)
elif osp.isdir(src_path):
shutil.copytree(src_path, tar_path)
else:
warnings.warn(f'Cannot copy file {src_path}.')
else:
raise ValueError(f'Invalid mode {mode}')


if __name__ == '__main__':
setup(name='trailmet',
version=get_version(),
Expand Down
2 changes: 1 addition & 1 deletion trailmet/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
__version__ = '0.0.1rc'
__version__ = '0.0.1rc2'


def parse_version_info(version_str):
Expand Down

0 comments on commit dfed07d

Please sign in to comment.