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

Stop using pkg_resources. #778

Merged
merged 1 commit into from
Feb 9, 2022
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- Work with more matplotlib palettes ([#760](../../pull/760))

### Changes
- Use importlib rather than pkg_resources internally ([#747](../../pull/747))
- Use importlib rather than pkg_resources internally ([#747](../../pull/747), [#778](../../pull/778))

### Bug Fixes
- Fix expanding a style palette with a single named color ([#754](../../pull/754))
Expand Down
11 changes: 8 additions & 3 deletions girder/girder_large_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from girder_jobs.constants import JobStatus
from girder_jobs.models.job import Job
from pkg_resources import DistributionNotFound, get_distribution

import girder
import large_image
Expand All @@ -44,8 +43,14 @@
from .rest.tiles import TilesItemResource

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions girder/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'girder>=3.0.4',
'girder-jobs>=3.0.3',
'large_image>=1.0.0',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'tasks': [
Expand Down
14 changes: 13 additions & 1 deletion girder_annotation/girder_large_image_annotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@
from .models.annotation import Annotation
from .rest.annotation import AnnotationResource

# Validators
try:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass


# Validators

@setting_utilities.validator({
constants.PluginSettings.LARGE_IMAGE_ANNOTATION_HISTORY,
Expand Down
1 change: 1 addition & 0 deletions girder_annotation/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'jsonschema>=2.5.1',
'girder-large-image',
'ujson>=1.35',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'tasks': [
Expand Down
12 changes: 8 additions & 4 deletions large_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
# limitations under the License.
#############################################################################

from pkg_resources import DistributionNotFound, get_distribution

from . import tilesource # noqa
from .tilesource import canRead, getTileSource, open # noqa

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass
11 changes: 8 additions & 3 deletions sources/bioformats/large_image_source_bioformats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import types

import numpy
from pkg_resources import DistributionNotFound, get_distribution

import large_image.tilesource.base
from large_image import config
Expand All @@ -39,8 +38,14 @@
from large_image.tilesource import FileTileSource, nearPowerOfTwo

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions sources/bioformats/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'large-image',
'python-bioformats>=1.5.2',
'scikit-image',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'girder': 'girder-large-image',
Expand Down
12 changes: 8 additions & 4 deletions sources/dummy/large_image_source_dummy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
# limitations under the License.
##############################################################################

from pkg_resources import DistributionNotFound, get_distribution

from large_image.constants import SourcePriority
from large_image.tilesource import TileSource

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions sources/dummy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def prerelease_local_scheme(version):
],
install_requires=[
'large-image',
'importlib-metadata ; python_version < "3.8"',
],
keywords='large_image, tile source',
packages=find_packages(exclude=['test', 'test.*']),
Expand Down
12 changes: 8 additions & 4 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
# if on those older versions of python if it is imported before gdal, there can
# be a database version conflect; importing after gdal avoids this.
import pyproj # noqa I001
from pkg_resources import DistributionNotFound, get_distribution

import large_image
from large_image.cache_util import CacheProperties, LruCacheMetaclass, methodcache
Expand All @@ -40,12 +39,17 @@
from large_image.tilesource.utilities import getPaletteColors

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass


TileInputUnits['projection'] = 'projection'
TileInputUnits['proj'] = 'projection'
TileInputUnits['wgs84'] = 'proj4:EPSG:4326'
Expand Down
1 change: 1 addition & 0 deletions sources/gdal/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'large-image',
'gdal',
'pyproj>=2.2.0',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'girder': 'girder-large-image',
Expand Down
11 changes: 8 additions & 3 deletions sources/mapnik/large_image_source_mapnik/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@
import PIL.Image
from large_image_source_gdal import GDALFileTileSource, InitPrefix
from osgeo import gdal, gdalconst
from pkg_resources import DistributionNotFound, get_distribution

from large_image.cache_util import LruCacheMetaclass, methodcache
from large_image.constants import TILE_FORMAT_PIL, SourcePriority
from large_image.exceptions import TileSourceError

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions sources/mapnik/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'large-image',
'large-image-source-gdal',
'mapnik',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'girder': 'girder-large-image',
Expand Down
11 changes: 8 additions & 3 deletions sources/multi/large_image_source_multi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import jsonschema
import numpy
import yaml
from pkg_resources import DistributionNotFound, get_distribution

import large_image
from large_image.cache_util import LruCacheMetaclass, methodcache
Expand All @@ -21,8 +20,14 @@
from large_image.tilesource.utilities import _makeSameChannelDepth

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions sources/multi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def prerelease_local_scheme(version):
'large-image>=1.0.0',
'pyyaml',
'scipy',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'girder': 'girder-large-image>=1.0.0',
Expand Down
11 changes: 8 additions & 3 deletions sources/nd2/large_image_source_nd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import cachetools
import numpy
from pkg_resources import DistributionNotFound, get_distribution

from large_image.cache_util import LruCacheMetaclass, methodcache
from large_image.constants import TILE_FORMAT_NUMPY, SourcePriority
Expand All @@ -33,8 +32,14 @@
nd2reader = None

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
11 changes: 8 additions & 3 deletions sources/ometiff/large_image_source_ometiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@
IOTiffException,
TiffException,
TiledTiffDirectory)
from pkg_resources import DistributionNotFound, get_distribution

from large_image.cache_util import LruCacheMetaclass, methodcache
from large_image.constants import TILE_FORMAT_NUMPY, TILE_FORMAT_PIL, SourcePriority
from large_image.exceptions import TileSourceError, TileSourceFileNotFoundError

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
3 changes: 2 additions & 1 deletion sources/ometiff/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def prerelease_local_scheme(version):
],
install_requires=[
'large-image',
'large-image-source-tiff>=1.0.0',
'large-image-source-tiff',
'importlib-metadata ; python_version < "3.8"'
],
extras_require={
'girder': 'girder-large-image',
Expand Down
11 changes: 8 additions & 3 deletions sources/openjpeg/large_image_source_openjpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@

import glymur
import PIL.Image
from pkg_resources import DistributionNotFound, get_distribution

from large_image.cache_util import LruCacheMetaclass, methodcache
from large_image.constants import TILE_FORMAT_NUMPY, SourcePriority
from large_image.exceptions import TileSourceError, TileSourceFileNotFoundError
from large_image.tilesource import FileTileSource, etreeToDict

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions sources/openjpeg/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'large-image',
'glymur>=0.8.18 ; python_version >= "3.7"',
'glymur>=0.8.18,<0.9.4 ; python_version < "3.7"',
'importlib-metadata ; python_version < "3.8"'
],
extras_require={
'girder': 'girder-large-image',
Expand Down
11 changes: 8 additions & 3 deletions sources/openslide/large_image_source_openslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import openslide
import PIL
import tifftools
from pkg_resources import DistributionNotFound, get_distribution

from large_image.cache_util import LruCacheMetaclass, methodcache
from large_image.constants import TILE_FORMAT_PIL, SourcePriority
Expand All @@ -34,8 +33,14 @@


try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _importlib_version
except ImportError:
from importlib_metadata import PackageNotFoundError
from importlib_metadata import version as _importlib_version
try:
__version__ = _importlib_version(__name__)
except PackageNotFoundError:
# package is not installed
pass

Expand Down
1 change: 1 addition & 0 deletions sources/openslide/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def prerelease_local_scheme(version):
'large-image',
'openslide-python>=1.1.0',
'tifftools>=1.2.0',
'importlib-metadata ; python_version < "3.8"',
],
extras_require={
'girder': 'girder-large-image',
Expand Down
Loading