Skip to content

Commit

Permalink
Merge pull request #302 from johntruckenbrodt/drop_pkg_resources
Browse files Browse the repository at this point in the history
require python>=3.8, drop pkg_resources
  • Loading branch information
johntruckenbrodt authored Apr 22, 2024
2 parents cac0063 + 4dcf02a commit 850439d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python>=3.6,<3.11
- python>=3.8,<3.11
- progressbar2
- numpy
- spatialist>=0.12.1
Expand Down
2 changes: 1 addition & 1 deletion environment-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python>=3.6,<3.11
- python>=3.8,<3.11
- matplotlib
- numpy
- sphinx<7.0 # https://github.com/readthedocs/sphinx_rtd_theme/issues/1463
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
- defaults
dependencies:
- python>=3.6,<3.11 # https://github.com/kvesteri/sqlalchemy-utils/issues/716
- python>=3.8,<3.11 # https://github.com/kvesteri/sqlalchemy-utils/issues/716
- progressbar2
- numpy
- spatialist>=0.12.1
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
[project]
name = "pyroSAR"
description = "a framework for large-scale SAR satellite data processing"
requires-python = ">=3.6,<3.11"
requires-python = ">=3.8,<3.11"
license = { file = "LICENSE.txt" }
maintainers = [
{ name = "John Truckenbrodt", email = "[email protected]" }
Expand Down
22 changes: 7 additions & 15 deletions pyroSAR/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
from .drivers import *
import sys
from . import ancillary, drivers

if sys.version_info >= (3, 8):
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version(__name__)
except PackageNotFoundError:
# package is not installed
pass
else:
from pkg_resources import get_distribution, DistributionNotFound
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version(__name__)
except PackageNotFoundError:
# package is not installed
pass
13 changes: 7 additions & 6 deletions pyroSAR/examine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################################
# Examination of SAR processing software
# Copyright (c) 2019-2023, the pyroSAR Developers.
# Copyright (c) 2019-2024, the pyroSAR Developers.

# This file is part of the pyroSAR Project. It is subject to the
# license terms in the LICENSE.txt file found in the top-level
Expand All @@ -19,7 +19,7 @@
import subprocess
import warnings
import subprocess as sp
import pkg_resources
import importlib.resources

from pyroSAR._dev_config import ConfigHandler
from spatialist.ancillary import finder, run
Expand Down Expand Up @@ -71,14 +71,14 @@ def __init__(self):
# point it to the default file delivered with pyroSAR
if not hasattr(self, 'properties'):
# log.info('using default properties file..')
template = os.path.join('snap', 'data', 'snap.auxdata.properties')
self.properties = pkg_resources.resource_filename(__name__, template)
dir_data = importlib.resources.files('pyroSAR') / 'snap' / 'data'
self.properties = str(dir_data / 'snap.auxdata.properties')

# if the SNAP suffices attribute was not yet identified,
# point it to the default file delivered with pyroSAR
if not hasattr(self, 'suffices'):
template = os.path.join('snap', 'data', 'snap.suffices.properties')
fname_suffices = pkg_resources.resource_filename(__name__, template)
dir_data = importlib.resources.files('pyroSAR') / 'snap' / 'data'
fname_suffices = str(dir_data / 'snap.suffices.properties')
with open(fname_suffices, 'r') as infile:
content = infile.read().split('\n')
self.__suffices = {k: v for k, v in [x.split('=') for x in content]}
Expand Down Expand Up @@ -381,6 +381,7 @@ class ExamineGamma(object):
>>> print(config.version)
"""

def __init__(self):
home_sys = os.environ.get('GAMMA_HOME')
if home_sys is not None and not os.path.isdir(home_sys):
Expand Down

0 comments on commit 850439d

Please sign in to comment.