jiptool / jip

Java dependency management for Jython
http://pypi.python.org/pypi/jip/
Other
59 stars 15 forks source link

AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' #67

Closed fergalmonaghan closed 1 year ago

fergalmonaghan commented 1 year ago

The long-deprecated getchildren function has been removed since python 3.9: https://docs.python.org/3.8/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element.getchildren

When I upgrade from python 3.7 to python 3.10 and change nothing else, and then run this command:

jip install org.apache.spark:spark-avro_2.12:3.3.1

I now hit this new issue:

(venv) fmonagha@GWY-FMONAGHAN-M journey-event-deserializer-static-assets % jip install org.apache.spark:spark-avro_2.12:3.1.1
jip [Checking] pom file https://repo1.maven.org/maven2/org/apache/spark/spark-avro_2.12/3.1.1/spark-avro_2.12-3.1.1.pom
jip [Checking] pom file https://repo1.maven.org/maven2/org/apache/spark/spark-parent_2.12/3.1.1/spark-parent_2.12-3.1.1.pom
Traceback (most recent call last):
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/bin/jip", line 8, in <module>
    sys.exit(main())
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/main.py", line 62, in main
    commands[cmd](**args)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 46, in wrapper
    func(*args, **kwargs)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 175, in install
    _install([artifact], options=options)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 145, in _install
    download_list = _resolve_artifacts(artifacts, exclusions)
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/commands.py", line 129, in _resolve_artifacts
    more_dependencies = pom_obj.get_dependencies()
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 197, in get_dependencies
    dep_mgmt = self.get_dependency_management()
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 155, in get_dependency_management
    dependency_management_version_dict.update(parent.get_dependency_management())
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 155, in get_dependency_management
    dependency_management_version_dict.update(parent.get_dependency_management())
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 157, in get_dependency_management
    properties = self.get_properties()
  File "/Users/fmonagha/altorepos/journey-event-deserializer-static-assets/venv/lib/python3.10/site-packages/jip/maven.py", line 249, in get_properties
    prop_eles = properties_ele.getchildren()
AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren'

Running this find+replace command first to upgrade line 249 of jip/maven.py before rerunning jip install resolves the issue:

sed -i '' -e 's/properties_ele.getchildren()/list(properties_ele)/g' venv/lib/python*/site-packages/jip/maven.py

sunng87 commented 1 year ago

Thank you! Could you please send a pull request to fix this?

fergalmonaghan commented 1 year ago

Hi @sunng87! I did clone the repo, created a branch, and fixed the issue locally, but then could not find a way to push my branch back up? At that point I presumed that only certain people would be allowed to make changes. Sorry if I am missing something, would you mind pointing me in the right direction to creating a pull request?

fergalmonaghan commented 1 year ago

I will try this approach where I have to fork the repo first: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

fergalmonaghan commented 1 year ago

Ok I have created the Pull Request now: https://github.com/jiptool/jip/pull/68 Thanks for the prompt! :)

fergalmonaghan commented 1 year ago

How do we get a new version of jip released with this fix in it? pip install jip still pulls down 0.9.15 with the issue in it

sunng87 commented 1 year ago

0.9.16 is on pypi.

It has been years since I released this package to pypi. Just let me know if there is issue with the new package.