artifactory
artifactory copied to clipboard
Python 3.12 - AttributeError: module 'pathlib' has no attribute '_Flavour'
Python 3.12 is now released, but it does not work due to pathlib changes:
/opt/hostedtoolcache/Python/3.12.0-rc.1/x64/lib/python3.12/site-packages/artifactory.py:426: in
class _ArtifactoryFlavour(pathlib._Flavour): E AttributeError: module 'pathlib' has no attribute '_Flavour'
I figured I'd add 3.12 into the test matrix on my project which relies on this library, and that's how I found this issue:
- https://github.com/briantist/galactory/actions/runs/5844080610/job/15846784439?pr=80#step:5:40
Not any kind of pressing issue yet.
Thank you for the feedback! If anyone has idea how to fix this - feel free to create a PR
Python 3.12 will add support for subclassing pathlib.PurePath and Path
See also the cpython github issue: https://github.com/python/cpython/pull/31691
I'm hoping to add a pathlib.PathBase
class for Python 3.13. Once it's in the codebase, I'll publish a backport package on PyPI for Python <3.13. dohq-artifactory
could subclass PathBase
to implement ArtifactoryPath
.
CPython issue: https://github.com/python/cpython/issues/110109
@barneygale Thank you for your work in core for this. It will be great to simplify the dohq-artifactory codebase.
Do you suggest any other solution for py312 in the meantime? Should we try subclassing something from py312's pathlib
prior to pathlib.PathBase
being available?
I'm running Python 3.12 on my laptop (Fedora 39), and I've hacked artifactory.py
so that it doesn't crash. I can list directories and download and upload basic files. My changes are in my py312
branch, but I'm not sure they're acceptable for a PR here.
I'd recommend that you wait if you can - I'm expecting to publish a PyPI package with the base classes some time this month.
Preview: https://github.com/python/cpython/blob/33f9af159adce62008934a6d304511401d650a8d/Lib/pathlib/_abc.py#L535
Git project: https://github.com/barneygale/pathlib_abc
Currently it only supports Python 3.11+, but I should have it working for 3.8+ within a couple of weeks, at which point I'll publish a PyPI package.
First PyPI release: https://pypi.org/project/pathlib-abc/0.1.0/
I'm seeing the same issue in py3.11 now
Hey everyone - any progress here?
Hey guys,
Thanks for reporting this issue. I'd like to work on it.
IMO the best way to fix this is to add a dependency on pathlib-abc, and make ArtifactoryPath
inherit from PathBase
.
@zhan9san is that what you're pursuing? If not I might have a crack at it.
I hope this will be remediated soon.
@zhan9san @beliaev-maksim hi folks, any update on this issue? Given Python 3.12 is fully released and supported, it would be very appreciated that Artifactory library supports it, it's the only item blocking our migration to 3.12 now...
We are looking for a volunteer!
+1 this is blocking migrating to python 3.12
Any hope of this being resolved before release of python 3.13?
FWIW I've started a new pathlib-artifactory package building on the semi-official pathlib-abc package. It doesn't rely on hacking into the pathlib internals (unlike dohq-artifactory) so it should be on surer footing. But it's missing tons of features and it's certainly not a drop-in replacement for dohq-artifactory yet. Issues and PRs very welcome.
@allburov, @barneygale, I took a swing at using the pathlib-abc, but it's erroring on
from artifactory import ArtifactoryPath
.tox/py39/lib/python3.9/site-packages/artifactory.py:1490: in <module>
class ArtifactoryPath(pathlib.Path, PureArtifactoryPath):
/pyenv/versions/3.9.18/lib/python3.9/abc.py:106: in __new__
cls = super().__new__(mcls, name, bases, namespace, **kwargs)
E TypeError: multiple bases have instance lay-out conflict
You can see my progress here: https://github.com/mshafer-NI/devopshq-artifactory/pull/1