juju / charm-tools

Tools for charm authors and maintainers
Other
42 stars 64 forks source link

AttributeError: 'Path' object has no attribute 'abspath' #674

Closed nobuto-m closed 1 month ago

nobuto-m commented 1 month ago

Checklist

What version am I running?

I ran the following command: snap info charm and got the following ouput:

$ snap list charm
Name   Version  Rev  Tracking    Publisher   Notes
charm  3.0.7    745  3.x/stable  canonical✓  classic

I am using: Ubuntu 24.04 LTS. But this is observed in a charm CI on jammy https://review.opendev.org/c/openstack/charm-ceph-fs/+/925135 https://openstack-ci-reports.ubuntu.com/artifacts/3e6/925135/1/check/charm-build/3e69935/

Issue/Feature

charm-tools @ git+https://github.com/juju/charm-tools.git@e0592a6fee165b839545b7458a34434a58e5d13b

2024-07-29 22:54:33.682560 | jammy-medium | :: build-reactive installed: attrs==23.2.0,blessings==1.7,certifi==2024.7.4,cffi==1.16.0,charm-tools @ git+https://github.com/juju/charm-tools.git@e0592a6fee165b839545b7458a34434a58e5d13b,charset-normalizer==3.3.2,Cheetah3==3.2.6.post1,colander==1.8.3,cryptography==3.3.2,dict2colander==0.2,distlib==0.3.8,filelock==3.15.4,idna==3.7,importlib-metadata==8.2.0,importlib-resources==6.4.0,iso8601==2.1.0,jaraco.classes==3.4.0,jeepney==0.8.0,jsonschema==4.17.3,jujubundlelib==0.5.7,keyring==23.13.1,more-itertools==10.3.0,otherstuf==1.1.0,parse==1.20.2,path==17.0.0,path.py==12.5.0,pathspec==0.10.3,pkgutil-resolve-name==1.3.10,platformdirs==4.2.2,pycparser==2.22,pyrsistent==0.20.0,PyYAML==6.0.1,requests==2.32.3,requirements-parser==0.5.0,ruamel.yaml==0.17.40,ruamel.yaml.clib==0.2.8,SecretStorage==3.3.3,simplejson==3.19.2,six==1.16.0,stuf==0.9.16,translationstring==1.4,types-setuptools==71.1.0.20240726,urllib3==2.2.2,vergit==1.0.2,virtualenv==20.26.3,zipp==3.19.2

path==17.0.0,path.py==12.5.0,pathspec==0.10.3,

2024-07-29 22:54:33.682797 | jammy-medium | :: build-reactive run-test-pre: PYTHONHASHSEED='0'
2024-07-29 22:54:33.683554 | jammy-medium | :: build-reactive run-test: commands[0] | charm-build --log-level DEBUG --use-lock-file-branches -o /root/parts/charm/build/build/builds src
2024-07-29 22:54:34.218094 | jammy-medium | :: Traceback (most recent call last):
2024-07-29 22:54:34.219070 | jammy-medium | ::   File "/root/parts/charm/build/.tox/build-reactive/bin/charm-build", line 8, in <module>
2024-07-29 22:54:34.219123 | jammy-medium | ::     sys.exit(main())
2024-07-29 22:54:34.219138 | jammy-medium | ::   File "/root/parts/charm/build/.tox/build-reactive/lib/python3.8/site-packages/charmtools/build/builder.py", line 1238, in main
2024-07-29 22:54:34.220219 | jammy-medium | ::     build.normalize_build_dir()
2024-07-29 22:54:34.220274 | jammy-medium | ::   File "/root/parts/charm/build/.tox/build-reactive/lib/python3.8/site-packages/charmtools/build/builder.py", line 881, in normalize_build_dir
2024-07-29 22:54:34.220285 | jammy-medium | ::     self.build_dir = self.build_dir.abspath()
2024-07-29 22:54:34.220296 | jammy-medium | :: AttributeError: 'Path' object has no attribute 'abspath'

https://github.com/juju/charm-tools/blob/e0592a6fee165b839545b7458a34434a58e5d13b/charmtools/build/builder.py#L881

Looks like the abspath has gone at path==17.0.0. https://path.readthedocs.io/en/latest/history.html#v17-0-0

27 Jul 2024 ... Removed deprecated methods getcwd, abspath, ext, listdir, isdir, isfile, and text.

I expect/expected the following

tox -vv -e build in openstack charms just works.

What I got

The output above as an error.

nobuto-m commented 1 month ago

I've learned that migrating to charmcraft-2.x can also be the "fix". e.g. https://review.opendev.org/c/openstack/charm-keystone-saml-mellon/+/925413

Thanks for pinning it anyways, that would work well as a stop-gap solution without an urgent migration. https://github.com/juju/charm-tools/commit/0c02af33e7fd5a0434bcff17cdd793ef03b32a11