pathtools icon indicating copy to clipboard operation
pathtools copied to clipboard

Doesn't build with Python 3.12

Open AdamWill opened this issue 1 year ago • 3 comments

pathtools uses imp to get its internal version into setup.py (which seems like a kinda crazy approach to me, but hey). imp was retired in Python 3.12. There's a formula to replace the bit of it pathtools uses:

import importlib.util
import importlib.machinery

def load_source(modname, filename):
    loader = importlib.machinery.SourceFileLoader(modname, filename)
    spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
    module = importlib.util.module_from_spec(spec)
    # The module is always executed and not cached in sys.modules.
    # Uncomment the following line to cache the module.
    # sys.modules[module.__name__] = module
    loader.exec_module(module)
    return module

which seems like a lot of boilerplate just to get a version number, but hey, you can do that if you like. If it was my project I'd just use some different approach to the version number issue (my own projects have a script for doing version bumps which does this, but I've seen lots of different approaches).

For downstream (we ran into this in Fedora) I've just used a dumb non-upstreamable patch to replace the use of imp to set the version in setup.py with a marker string which we replace with the correct version in the package spec file (since we know what the version is, there).

AdamWill avatar Aug 26 '23 01:08 AdamWill

Hi @AdamWill ,

We received this concern and we are looking into it. We'll get back to you when we have an update.

JoanaMarieL avatar Oct 13 '23 01:10 JoanaMarieL

Looks like someone has submitted PR #14 to fix this

alejandro-angulo avatar Dec 21 '23 03:12 alejandro-angulo

Ping @JoanaMarieL ?

ecederstrand avatar May 08 '24 10:05 ecederstrand