Message ID | 20231026092701.12345-27-adam.duskett@amarulasolutions.com |
---|---|
State | Accepted |
Headers | show |
Series | package/python3: bump version to 3.12.0 | expand |
On 26/10/2023 11:26, Adam Duskett wrote: > In preperation of Python 3.12.0, add a patch to python-pathtools that removes > the reliance on the imp module following the instructions found here: > https://docs.python.org/3.12/whatsnew/3.12.html#removed > > Also tested with Python 3.9.2 on Debian 11. > > Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> Wow, this hasn't had a commit in 7 years... Applied to master, thanks. Regards, Arnout > --- > .../python-pathtools/0001-replace-imp.patch | 55 +++++++++++++++++++ > 1 file changed, 55 insertions(+) > create mode 100644 package/python-pathtools/0001-replace-imp.patch > > diff --git a/package/python-pathtools/0001-replace-imp.patch b/package/python-pathtools/0001-replace-imp.patch > new file mode 100644 > index 0000000000..a5bc240cea > --- /dev/null > +++ b/package/python-pathtools/0001-replace-imp.patch > @@ -0,0 +1,55 @@ > +From e2372bbecdf46a100b09126f2951431c1929637b Mon Sep 17 00:00:00 2001 > +From: Adam Duskett <adam.duskett@amarulasolutions.com> > +Date: Tue, 24 Oct 2023 08:59:21 +0200 > +Subject: [PATCH] Replace imp > + > +The imp module has been removed in python 3.12.0. > + > +This change has also been tested with Python 3.9.2 on Debian 11. > + > +From: https://docs.python.org/3.12/whatsnew/3.12.html#removed, follow the > +instructions to add the load_source method back into setup.py. > + > +Upstream: https://github.com/gorakhargosh/pathtools/pull/14 > + > +Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> > +--- > + setup.py | 19 ++++++++++++++++--- > + 1 file changed, 16 insertions(+), 3 deletions(-) > + > +diff --git a/setup.py b/setup.py > +index 4718885..1be0315 100644 > +--- a/setup.py > ++++ b/setup.py > +@@ -22,12 +22,25 @@ > + # THE SOFTWARE. > + > + import os > +-import imp > ++import importlib.util > ++import importlib.machinery > + from setuptools import setup > + > + PKG_DIR = 'pathtools' > +-version = imp.load_source('version', > +- os.path.join(PKG_DIR, 'version.py')) > ++ > ++# From: https://docs.python.org/3.12/whatsnew/3.12.html#removed > ++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 > ++ > ++version = load_source('version', > ++ os.path.join(PKG_DIR, 'version.py')) > + > + def read_file(filename): > + """ > +-- > +2.41.0 > +
diff --git a/package/python-pathtools/0001-replace-imp.patch b/package/python-pathtools/0001-replace-imp.patch new file mode 100644 index 0000000000..a5bc240cea --- /dev/null +++ b/package/python-pathtools/0001-replace-imp.patch @@ -0,0 +1,55 @@ +From e2372bbecdf46a100b09126f2951431c1929637b Mon Sep 17 00:00:00 2001 +From: Adam Duskett <adam.duskett@amarulasolutions.com> +Date: Tue, 24 Oct 2023 08:59:21 +0200 +Subject: [PATCH] Replace imp + +The imp module has been removed in python 3.12.0. + +This change has also been tested with Python 3.9.2 on Debian 11. + +From: https://docs.python.org/3.12/whatsnew/3.12.html#removed, follow the +instructions to add the load_source method back into setup.py. + +Upstream: https://github.com/gorakhargosh/pathtools/pull/14 + +Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> +--- + setup.py | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +diff --git a/setup.py b/setup.py +index 4718885..1be0315 100644 +--- a/setup.py ++++ b/setup.py +@@ -22,12 +22,25 @@ + # THE SOFTWARE. + + import os +-import imp ++import importlib.util ++import importlib.machinery + from setuptools import setup + + PKG_DIR = 'pathtools' +-version = imp.load_source('version', +- os.path.join(PKG_DIR, 'version.py')) ++ ++# From: https://docs.python.org/3.12/whatsnew/3.12.html#removed ++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 ++ ++version = load_source('version', ++ os.path.join(PKG_DIR, 'version.py')) + + def read_file(filename): + """ +-- +2.41.0 +
In preperation of Python 3.12.0, add a patch to python-pathtools that removes the reliance on the imp module following the instructions found here: https://docs.python.org/3.12/whatsnew/3.12.html#removed Also tested with Python 3.9.2 on Debian 11. Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> --- .../python-pathtools/0001-replace-imp.patch | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 package/python-pathtools/0001-replace-imp.patch