Skip to content

Drop C extension and move to pyproject.toml#1373

Draft
larsoner wants to merge 19 commits into
enthought:mainfrom
larsoner:95-pyproject
Draft

Drop C extension and move to pyproject.toml#1373
larsoner wants to merge 19 commits into
enthought:mainfrom
larsoner:95-pyproject

Conversation

@larsoner

Copy link
Copy Markdown
Collaborator

Needs #1364 to be merged then a rebase

  1. Move to pyproject.toml + setuptools_scm for versioning (modernize project)
  2. Get rid of NumPy C extension (speed gains not worth maintainability and installation issues)

I compared the contents before and after this switch and they match!

larsoner and others added 19 commits July 9, 2026 16:55
Regenerate tvtk/src/array_ext.c with Cython 3.2.8. This supersedes the
manual edit in enthoughtgh-1370 by picking up upstream Cython's own fix for the
incorrect Py_DECREF after a failed PyList_SetItem in the generated
__Pyx_CyFunction_get_is_coroutine helper (enthoughtgh-1369), rather than hand-
editing generated code.

Also add the `freethreading_compatible=True` directive to array_ext.pyx
so the module declares Py_MOD_GIL_NOT_USED and does not force the GIL
back on under a free-threaded interpreter. The module has no shared
mutable state; verified on free-threaded CPython 3.14t that import keeps
the GIL disabled and 128k concurrent set_id_type_array calls across 32
threads produce correct results.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate all static metadata from setup.py into a PEP 621 [project] table
in pyproject.toml (dynamic version, dependencies, entry points, SPDX
BSD-3-Clause license). Bump the minimum Python to 3.10. setup.py now
carries only the build-time TVTK class-ZIP generation and the doc
commands; pytest config moves from setup.cfg (removed) to
[tool.pytest.ini_options].

Drop the tvtk.array_ext Cython extension: set_id_type_array is now an
alias of the existing pure-NumPy set_id_type_array_py in array_handler.py.
Benchmarks showed the C loop was only ~2-3.5x faster on typical meshes for
a once-per-dataset operation, so removing it drops the compiler
requirement, yields a universal py3-none-any wheel, and works on
free-threaded builds. This also makes enthoughtgh-1369 / enthoughtgh-1370 moot.

Import tvtk lazily inside setup.py's build hooks (not at module scope) so
that metadata/sdist builds under the PEP 517 setuptools.build_meta backend
do not require tvtk to be importable; only the wheel's class-generation
step does.

Verified sdist/wheel contents against the 95 branch: the only differences
are the removed extension sources/.so and intended metadata modernization
(SPDX license, dropped "Programming Language :: C" classifier,
py3-none-any wheel tag, no legacy not-zip-safe marker).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace the hardcoded mayavi.__version__ with setuptools_scm, which derives
the version from git tags (e.g. "4.8.3" -> "4.8.4.dev22+g..."). At runtime
mayavi/__init__.py reads the version from the installed package metadata via
importlib.metadata, falling back to "0.0.0" when it cannot be resolved --
the same approach MNE-Python has used for years. No version_file or
fallback_version is used, so sdist/wheel contents are unchanged (the version
lives only in the package metadata).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant