Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13 compatibility. #473

Merged

Conversation

richardxia
Copy link

Fixes #470.

Between Python 3.12 and Python 3.13, the internal structure of pathlib changed, causing the Artifactory URL parsing to fail. pathlib.PurePath previously had a private class attribute, _flavour, which has now been renamed to parser and made into a public and documented API.

This renames _flavour to parser in the ArtifactoryPath subclasses, but it leaves around a _flavour class attribute that is aliased to parser as a compatibility shim for older versions of Python.

One other breakage between Python 3.12 and 3.13 is that the artifactory package attempted to import posixpath via the pathlib package. posixpath was never meant to be a publicly accessible attribute of pathlib, as posixpath is its own top-level package in the standard library. The pathlib code was significantly restructured, causing the posixpath module to no longer be accessible under pathlib. We fix this in artifactory by directly importing the top-level posixpath package.

Finally, this adds Python 3.13 to the package metadata in setup.py and the tox and GitHub Actions configuration files so that it is officially declared as a supported Python version and tested in CI.

Between Python 3.12 and Python 3.13, the internal structure of pathlib
changed, causing the Artifactory URL parsing to fail. `pathlib.PurePath`
previously had a private class attribute, `_flavour`, which has now been
renamed to `parser` and made into a public and documented API.

This renames `_flavour` to `parser` in the ArtifactoryPath subclasses,
but it leaves around a `_flavour` class attribute that is aliased to
`parser` as a compatibility shim for older versions of Python.

One other breakage between Python 3.12 and 3.13 is that the artifactory
package attempted to import `posixpath` via the `pathlib` package.
`posixpath` was never meant to be a publicly accessible attribute of
`pathlib`, as `posixpath` is its own top-level package in the standard
library. The `pathlib` code was significantly restructured, causing the
`posixpath` module to no longer be accessible under `pathlib`. We fix
this in artifactory by directly importing the top-level `posixpath`
package.

Finally, this adds Python 3.13 to the package metadata in setup.py and
the tox and GitHub Actions configuration files so that it is officially
declared as a supported Python version and tested in CI.
Copy link
Member

@allburov allburov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thank you for PR!

Let's wait for the community feedback about the fix and we can merge it 🙏

pip install git+https://github.com/richardxia/artifactory@feature/python-3.13-pathlib-fixes

@offa
Copy link
Contributor

offa commented Feb 21, 2025

Thanks! This fixes the parsing issue. However, running a minimal script with a loop resulted in an AttributeError:

from artifactory import ArtifactoryPath

path = ArtifactoryPath("https://mysite/artifactory")

for p in path:
    print(path)

Raises AttributeError: 'super' object has no attribute '_make_child_relpath' in artifactory.py line 1926.

Update

Replacing the call to _make_child_relpath() with joinpath() (as done here) solves the issue.

@allburov allburov changed the base branch from master to python-3-13 February 21, 2025 08:24
@allburov allburov merged commit 9610bf0 into devopshq:python-3-13 Feb 21, 2025
6 checks passed
@allburov
Copy link
Member

@offa thank you for the fix! Could you create a PR to python-3-13 branch pls?

Let's have a dedicated branch, so we don't have to push in forks the hotfixes and we'll release it when it's stable for all!

@richardxia
Copy link
Author

Thank you for the quick review! Really appreciate it!

@richardxia richardxia deleted the feature/python-3.13-pathlib-fixes branch February 21, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Python 3.13 compatibility
3 participants