artifactory icon indicating copy to clipboard operation
artifactory copied to clipboard

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

Open briantist opened this issue 1 year ago • 30 comments

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.

briantist avatar Aug 13 '23 00:08 briantist

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

allburov avatar Aug 14 '23 10:08 allburov

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

brot avatar Sep 04 '23 15:09 brot

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 avatar Oct 03 '23 19:10 barneygale

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

ktdreyer avatar Dec 08 '23 18:12 ktdreyer

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 avatar Dec 08 '23 18:12 barneygale

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

barneygale avatar Dec 08 '23 19:12 barneygale

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 avatar Dec 23 '23 03:12 barneygale

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

barneygale avatar Dec 27 '23 17:12 barneygale

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

FHTMitchell avatar Jan 24 '24 17:01 FHTMitchell

Hey everyone - any progress here?

dkmiller avatar Feb 05 '24 18:02 dkmiller

Hey guys,

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

zhan9san avatar Feb 06 '24 07:02 zhan9san

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.

barneygale avatar Feb 24 '24 21:02 barneygale

I hope this will be remediated soon.

lukezhangtyler avatar Mar 08 '24 18:03 lukezhangtyler

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

okainov avatar Mar 19 '24 12:03 okainov

We are looking for a volunteer!

allburov avatar Mar 20 '24 05:03 allburov

+1 this is blocking migrating to python 3.12

andrewsiemer avatar Apr 10 '24 01:04 andrewsiemer

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

hacklint avatar May 03 '24 09:05 hacklint

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.

barneygale avatar Jun 07 '24 23:06 barneygale

@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

mshafer-NI avatar Jul 03 '24 22:07 mshafer-NI