Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Do not depend on setuptools>=52 #1235

Merged
merged 6 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
- name: Upgrade Setuptools
run: pip install setuptools --upgrade
- name: Build and install
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
Expand Down Expand Up @@ -77,8 +75,6 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
- name: Install PyTorch
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Upgrade Setuptools
run: pip install setuptools --upgrade
- name: Build and install
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
Expand Down Expand Up @@ -122,8 +118,6 @@ jobs:
if: ${{matrix.torchvision == '0.4.2'}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Upgrade Setuptools
run: pip install setuptools --upgrade
- name: Build and install
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
Expand Down Expand Up @@ -194,8 +188,6 @@ jobs:
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
- name: Upgrade Setuptools
run: pip install setuptools --upgrade
- name: Build and install
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
Expand Down Expand Up @@ -266,8 +258,6 @@ jobs:
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
- name: Upgrade Setuptools
run: pip install setuptools --upgrade
- name: Build and install
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
Expand Down Expand Up @@ -320,8 +310,6 @@ jobs:
if: ${{matrix.torchvision == '0.4.2'}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} --no-cache-dir
- name: Upgrade Setuptools
run: pip install setuptools --upgrade
- name: Build and install
run: |
rm -rf .eggs
Expand Down
5 changes: 3 additions & 2 deletions mmcv/utils/version_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import os
import subprocess
import warnings
from pkg_resources import parse_version

from packaging.version import parse


def digit_version(version_str: str, length: int = 4):
Expand All @@ -19,7 +20,7 @@ def digit_version(version_str: str, length: int = 4):
tuple[int]: The version info in digits (integers).
"""
assert 'parrots' not in version_str
version = parse_version(version_str)
version = parse(version_str)
assert version.release, f'failed to parse version {version_str}'
release = list(version.release)
release = release[:length]
Expand Down
8 changes: 3 additions & 5 deletions mmcv/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Copyright (c) OpenMMLab. All rights reserved.

from pkg_resources import parse_version

__version__ = '1.3.10'


Expand All @@ -17,7 +14,8 @@ def parse_version_info(version_str: str, length: int = 4) -> tuple:
(1, 3, 0, 0, 0, 0), and "2.0.0rc1" is parsed into
(2, 0, 0, 0, 'rc', 1) (when length is set to 4).
"""
version = parse_version(version_str)
from packaging.version import parse
version = parse(version_str)
assert version.release, f'failed to parse version {version_str}'
release = list(version.release)
release = release[:length]
Expand All @@ -32,6 +30,6 @@ def parse_version_info(version_str: str, length: int = 4) -> tuple:
return tuple(release)


version_info = parse_version_info(__version__)
version_info = tuple(int(x) for x in __version__.split('.')[:3])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do not use parse_version_info here though you wrote it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you execute this line during setup, "packaging" may not exist.


__all__ = ['__version__', 'version_info', 'parse_version_info']
2 changes: 1 addition & 1 deletion requirements/runtime.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
addict
numpy
packaging
Pillow
pyyaml
regex;sys_platform=='win32'
setuptools>=52
yapf
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ onnxruntime==1.4.0
pytest
PyTurboJPEG
scipy
setuptools>=52
tiffile
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import glob
import os
import re
from pkg_resources import DistributionNotFound, get_distribution, parse_version
from pkg_resources import DistributionNotFound, get_distribution
from setuptools import find_packages, setup

EXT_TYPE = ''
Expand Down Expand Up @@ -221,10 +221,12 @@ def get_extensions():
extra_compile_args = {'cxx': []}

is_rocm_pytorch = False
if parse_version(torch.__version__) >= parse_version('1.5'):
try:
from torch.utils.cpp_extension import ROCM_HOME
is_rocm_pytorch = True if ((torch.version.hip is not None) and
(ROCM_HOME is not None)) else False
except ImportError:
pass

this_dir = 'mmcv/ops/csrc/'
if is_rocm_pytorch:
Expand Down