mdavidsaver / setuptools_dso

setuptools extension for building non-Python Dynamic Shared Objects
Other
9 stars 6 forks source link

A Future without distutils #24

Open mdavidsaver opened 1 year ago

mdavidsaver commented 1 year ago

Currently setuptools_dso is importing a number of pieces directly from distutils, which is now be deprecated/removed in cpython 3.12. And the vendored/patched distutils shipped with setuptools has been causing problems for others (https://github.com/pypa/setuptools/issues/3532). So it seems like it may be only a matter of time before some change to setuptools breaks this package.

My current thinking is to try to replace all distutils imports with setuptools imports.

mdavidsaver commented 1 year ago

The current state of things. I suspect the most likely place for problems will be src/setuptools_dso/compiler.py.

$ git grep distutils
documentation/usage.rst:A callable will be invoked during the `build_dso` phase with one argument of :py:class:`distutils.core.Command`.
documentation/usage.rst:and `distutils.core.Extension <https://docs.python.org/3/distutils/apiref.html#distutils.core.Extension>`_,
example/setup.py:    # 'cmd' is instance of distutils Command with attributes:
src/setuptools_dso/__init__.py:# import of setuptools implicitly monkey patches distutils...
src/setuptools_dso/__init__.py:from distutils import log
src/setuptools_dso/compiler.py:from distutils.ccompiler import (new_compiler as _new_compiler, gen_preprocess_options, CCompiler)
src/setuptools_dso/compiler.py:from distutils.dep_util import newer
src/setuptools_dso/compiler.py:from distutils.errors import DistutilsExecError, CompileError
src/setuptools_dso/compiler.py:from distutils.sysconfig import customize_compiler
src/setuptools_dso/compiler.py:from distutils import log
src/setuptools_dso/compiler.py:    """Replacement for default (no-op) distutils.msvccompiler.MSVCCompiler.preprocess()
src/setuptools_dso/compiler.py:    """Returns a instance of a sub-class of distutils.ccompiler.CCompiler
src/setuptools_dso/dsocmd.py:from distutils.dep_util import newer_group
src/setuptools_dso/dsocmd.py:from distutils import log
src/setuptools_dso/dsocmd.py:        # original setuptools/distutils don't call sub_commands for build_ext
src/setuptools_dso/dsocmd.py:#   distutils presents such a simple idea.  We just add 'build_dso' to build.sub_commands.
src/setuptools_dso/dsocmd.py:# _needs_builddso marks distutils/setuptools command to depend on build_dso.
src/setuptools_dso/dsocmd.py:from distutils.command.build import build
src/setuptools_dso/probe.py:from distutils.errors import DistutilsExecError, CompileError
src/setuptools_dso/probe.py:from distutils import log
src/setuptools_dso/probe.py:    """Directly copied from :py:class:`distutils.ccompiler.CCompiler.compiler_type`
src/setuptools_dso/test/test_probe.py:        from distutils import log
OCopping commented 4 months ago

Has there been any progress on this issue? I was attempting to build a project at Diamond Light Source against Python 3.12 and this is breaking pythonSoftIOC. It is not urgent as the project only requires Python 3.11, but would be nice for the future.

    from softioc import asyncio_dispatcher, softioc
  File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/softioc/__init__.py", line 5, in <module>
    from setuptools_dso.runtime import find_dso
  File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/setuptools_dso/__init__.py", line 9, in <module>
    from .dsocmd import DSO, Extension, install, build, build_dso, build_ext, bdist_egg
  File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/setuptools_dso/dsocmd.py", line 29, in <module>
    from distutils.dep_util import newer_group
  File "/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/site-packages/setuptools/_distutils/dep_util.py", line 9, in __getattr__
    warnings.warn(
DeprecationWarning: dep_util is Deprecated. Use functions from setuptools instead.
mdavidsaver commented 3 months ago

Has there been any progress on this issue?

No. It would be great if you have time to research the distutils -> setuptools equivalences.