From e9c305861c744591ec9126b9cb734138c031a13c Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 22 Jan 2023 22:04:42 -0700 Subject: [PATCH] Remove packaging dependency (#1019) * Remove packaging dependency * Remove additional references * Remove unused import --- environment.yml | 1 - requirements/min.old | 1 - requirements/required.old | 1 - requirements/required.txt | 1 - setup.cfg | 2 -- tests/trainers/conftest.py | 10 ++-------- torchgeo/datasets/openbuildings.py | 3 +-- 7 files changed, 3 insertions(+), 16 deletions(-) diff --git a/environment.yml b/environment.yml index 7406b4401..17b055c19 100644 --- a/environment.yml +++ b/environment.yml @@ -29,7 +29,6 @@ dependencies: - nbsphinx>=0.8.5 - omegaconf>=2.1 - opencv-python>=3.4.2.17 - - packaging>=17 - pandas>=0.23.2 - pillow>=6.2 - pydocstyle[toml]>=6.1 diff --git a/requirements/min.old b/requirements/min.old index 6d22b601b..921317cf7 100644 --- a/requirements/min.old +++ b/requirements/min.old @@ -8,7 +8,6 @@ kornia==0.6.5 matplotlib==3.3.0 numpy==1.17.2 omegaconf==2.1.0 -packaging==17.0 pillow==6.2.0 pyproj==2.2.0 pytorch-lightning==1.5.1 diff --git a/requirements/required.old b/requirements/required.old index 1e120e094..499e9269d 100644 --- a/requirements/required.old +++ b/requirements/required.old @@ -9,7 +9,6 @@ matplotlib==3.5.2 numpy==1.23.0;python_version>='3.8' numpy==1.21.6;python_version=='3.7' omegaconf==2.2.2 -packaging==21.3 pillow==9.2.0 pyproj==3.3.1;python_version>='3.8' pyproj==3.2.0;python_version=='3.7' diff --git a/requirements/required.txt b/requirements/required.txt index 548c948e8..d54af9d9a 100644 --- a/requirements/required.txt +++ b/requirements/required.txt @@ -8,7 +8,6 @@ kornia==0.6.9 matplotlib==3.6.3 numpy==1.24.1;python_version>='3.8' omegaconf==2.3.0 -packaging==23.0 pillow==9.4.0 pyproj==3.4.1;python_version>='3.8' pytorch-lightning[extra]==1.9.0 diff --git a/setup.cfg b/setup.cfg index ce7b2446b..4efb48760 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,8 +37,6 @@ install_requires = numpy>=1.17.2,<2 # omegaconf 2.1+ required for to_object method omegaconf>=2.1,<3 - # packaging 17+ required by pytorch-lightning - packaging>=17,<24 # pillow 6.2+ required by matplotlib pillow>=6.2,<10 # pyproj 2.2+ required for CRS object diff --git a/tests/trainers/conftest.py b/tests/trainers/conftest.py index ee0135380..8c1d0785b 100644 --- a/tests/trainers/conftest.py +++ b/tests/trainers/conftest.py @@ -4,25 +4,19 @@ import os from collections import OrderedDict from pathlib import Path -from typing import Dict, Optional +from typing import Dict import pytest import torch import torchvision from _pytest.fixtures import SubRequest -from packaging.version import parse from torch import Tensor from torch.nn.modules import Module @pytest.fixture(scope="package") def model() -> Module: - kwargs: Dict[str, Optional[bool]] = {} - if parse(torchvision.__version__) >= parse("0.13"): - kwargs = {"weights": None} - else: - kwargs = {"pretrained": False} - model: Module = torchvision.models.resnet18(**kwargs) + model: Module = torchvision.models.resnet18(weights=None) return model diff --git a/torchgeo/datasets/openbuildings.py b/torchgeo/datasets/openbuildings.py index f8e377a9c..94c10b073 100644 --- a/torchgeo/datasets/openbuildings.py +++ b/torchgeo/datasets/openbuildings.py @@ -16,7 +16,6 @@ import rasterio import shapely import shapely.wkt as wkt import torch -from packaging.version import parse from rasterio.crs import CRS from rtree.index import Index, Property @@ -387,7 +386,7 @@ class OpenBuildings(VectorDataset): x = json.loads(x.replace("'", '"')) import fiona - if parse(fiona.__version__) >= parse("1.9a1"): + if hasattr(fiona, "model"): import fiona.model geom = fiona.model.Geometry(**x)