Skip to content

Migrate radproc from Python 2 to Python 3 with support to ArcGIS Pro #13

@jkreklow

Description

@jkreklow

Overview:
Migrate the entire codebase of radproc from Python 2 to modern Python 3 (>=3.8 recommended). This will ensure ongoing support, compatibility with widely used libraries (numpy, pandas, etc), and improved maintainability.

Migration Tasks

  • Update setup.py to support Python 3 only (add python_requires, modernize classifiers)
  • Remove all from __future__ import division, print_function statements (now default in Python 3)
  • Review and update all iteration methods (e.g. .iteritems(), .itervalues(), .iterkeys().items(), .values(), .keys())
  • Replace any basestring/unicode with str and check string/byte conversions ("u''" → no longer needed)
  • Verify and update file I/O for bytes/str issues, especially in binary/gzip/tar/HDF5 reads
  • Ensure all usage of print functions are Python 3 compatible print()
  • Update any exceptions for new syntax (except Exception as e: vs except Exception, e:)
  • Remove/update any other obsolete Python 2 idioms
  • Confirm all dependencies support Python 3 and update requirements.txt if needed
  • Migrate GIS workflow from ArcMap arcpy syntax to ArcGIS Pro arcpy
  • Run all unit/integration tests under Python 3.8+ and fix incompatibilities
  • Update documentation (README, docstrings, etc.) to reflect Python 3 as required

Examples of Code Updates:

Update classifiers and python_requires in setup.py:

# Replace Python 2 classifiers: 
# 'Programming Language ::  Python :: 2',
# 'Programming Language :: Python :: 2.7',
# With Python 3 classifiers, and add python_requires:
setup(
    ...
    python_requires='>=3.8',
    classifiers=[
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.8',
        'Programming Language :: Python :: 3.9',
        'Programming Language :: Python :: 3.10',
        ...
    ],
    ... 
)

Remove future imports:

# Remove these imports:
from __future__ import division, print_function

Update dictionary iteration:

# Python 2 style:
# for k, v in d. iteritems():
# Python 3 style:
for k, v in d.items():

Print function:

# Python 2:
# print "Hello"
# Python 3:
print("Hello")

String/byte distinction:

# Python 3 requires explicit encoding/decoding: 
with open(filename, 'rb') as f:
    content = f.read().decode('utf-8')

Type checks:

# Python 2:
# isinstance(s, basestring)
# Python 3:
isinstance(s, str)

Optional improvements:

  • Add type hints and use f-strings for formatting
  • Use pathlib.Path for file operations instead of string paths

Acceptance criteria:

  • All core features pass under modern Python 3 (3.8+)
  • CI pipeline for Python 3 is green (if available)
  • Python 2 compatibility is dropped and no longer advertised

References:


Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions