devopshq / artifactory

dohq-artifactory: a Python client for Artifactory
https://devopshq.github.io/artifactory/
MIT License
269 stars 137 forks source link

Python 3.12 - AttributeError: module 'pathlib' has no attribute '_Flavour' #430

Open briantist opened 11 months ago

briantist commented 11 months ago

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:

Not any kind of pressing issue yet.

allburov commented 10 months ago

Thank you for the feedback! If anyone has idea how to fix this - feel free to create a PR

brot commented 10 months ago

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

barneygale commented 9 months ago

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

ktdreyer commented 7 months ago

@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.

barneygale commented 7 months ago

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.

barneygale commented 7 months ago

Preview: https://github.com/python/cpython/blob/33f9af159adce62008934a6d304511401d650a8d/Lib/pathlib/_abc.py#L535

barneygale commented 6 months ago

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.

barneygale commented 6 months ago

First PyPI release: https://pypi.org/project/pathlib-abc/0.1.0/

FHTMitchell commented 5 months ago

I'm seeing the same issue in py3.11 now

dkmiller commented 5 months ago

Hey everyone - any progress here?

zhan9san commented 5 months ago

Hey guys,

Thanks for reporting this issue. I'd like to work on it.

barneygale commented 4 months ago

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.

lukezhangtyler commented 4 months ago

I hope this will be remediated soon.

okainov commented 3 months ago

@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...

allburov commented 3 months ago

We are looking for a volunteer!

andrewsiemer commented 2 months ago

+1 this is blocking migrating to python 3.12

hacklint commented 2 months ago

Any hope of this being resolved before release of python 3.13?

barneygale commented 1 month ago

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.

mshafer-NI commented 4 days ago

@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