diff --git a/pkgs/by-name/sn/snappy-topology/package.nix b/pkgs/by-name/sn/snappy-topology/package.nix new file mode 100644 index 000000000000..7b86cbc394f1 --- /dev/null +++ b/pkgs/by-name/sn/snappy-topology/package.nix @@ -0,0 +1 @@ +{ python3Packages }: python3Packages.toPythonApplication python3Packages.snappy diff --git a/pkgs/by-name/tk/tkgl/package.nix b/pkgs/by-name/tk/tkgl/package.nix new file mode 100644 index 000000000000..ba5497bf588e --- /dev/null +++ b/pkgs/by-name/tk/tkgl/package.nix @@ -0,0 +1,51 @@ +{ + lib, + stdenv, + tcl, + fetchFromGitHub, + autoreconfHook, + tk, + libGL, +}: + +tcl.mkTclDerivation { + pname = "tkgl"; + version = "1.2.1-unstable-2025-06-01"; + + src = fetchFromGitHub { + owner = "3-manifolds"; + repo = "TkGL"; + rev = "45bf16e6c28a070c70fc9a0eb8c47a0b6ff8a2e3"; + hash = "sha256-AA5LZGhMTWmTZqI/wtycUYLsUe9BwO3voGMS7vGlCM0="; + }; + + postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace configure.ac \ + --replace-fail "-arch x86_64 -arch arm64" "" + ''; + + configureFlags = [ + "--with-tk=${lib.getLib tk}/lib" + "--with-tkinclude=${lib.getDev tk}/include" + ]; + + installTargets = [ + "install-lib-binaries" + ]; + + nativeBuildInputs = [ + autoreconfHook + ]; + + buildInputs = [ + tk + libGL + ]; + + meta = { + description = "OpenGL drawing surface for Tk 8 and 9"; + homepage = "https://github.com/3-manifolds/TkGL"; + license = lib.licenses.tcltk; + maintainers = with lib.maintainers; [ noiioiu ]; + }; +} diff --git a/pkgs/development/python-modules/snappy/default.nix b/pkgs/development/python-modules/snappy/default.nix new file mode 100644 index 000000000000..b9927c1aeb8b --- /dev/null +++ b/pkgs/development/python-modules/snappy/default.nix @@ -0,0 +1,132 @@ +{ + lib, + stdenv, + fetchpatch, + python, + buildPythonPackage, + fetchFromGitHub, + setuptools, + cypari, + cython, + fxrays, + ipython, + libGL, + low-index, + packaging, + pickleshare, + plink, + pypng, + pyx, + snappy-15-knots, + snappy-manifolds, + spherogram, + sphinxHook, + sphinx-rtd-theme, + tkinter-gl, +}: + +buildPythonPackage rec { + pname = "snappy"; + version = "3.2"; + pyproject = true; + + outputs = [ + "out" + "doc" + ]; + + src = fetchFromGitHub { + owner = "3-manifolds"; + repo = "SnapPy"; + tag = "${version}_as_released"; + hash = "sha256-IwPxuyVDsL5yML+J06HTKlz52sYrPkohLJ0XDXDwTlo="; + }; + + patches = [ + (fetchpatch { + name = "no-copy-doc.patch"; + url = "https://github.com/3-manifolds/SnapPy/commit/c6aeeaaec7010a54e4ebdf2e8dad7b384c2ce8e5.patch"; + hash = "sha256-OV3Qr5wO5UHNzVFTPTujIpp5ptel6gvAlcMgrJ8C0KY="; + }) + (fetchpatch { + name = "fix-test-aarch64.patch"; + url = "https://github.com/3-manifolds/SnapPy/commit/a8d57db39bc8f486746dc61027779168d0bc316a.patch"; + hash = "sha256-RsuwaR+7UrVTKlPwQeHblTAN++La7b9BSMdFcJSiX5Q="; + }) + ]; + + postPatch = + lib.optionalString stdenv.hostPlatform.isLinux '' + substituteInPlace setup.py \ + --replace-fail "/usr/include/GL" "${libGL.dev}/include/GL" + substituteInPlace freedesktop/share/applications/snappy.desktop \ + --replace-fail "Exec=/usr/bin/env python3 -m snappy.app" "Exec=SnapPy" + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace setup.py \ + --replace-fail "poss_roots = [ ''' ]" "poss_roots = [ '$SDKROOT' ]" + ''; + + build-system = [ + setuptools + cython + ]; + + nativeBuildInputs = [ + sphinxHook + sphinx-rtd-theme + ]; + + buildInputs = [ + libGL + ]; + + dependencies = [ + cypari + fxrays + ipython + low-index + packaging + pickleshare + plink + pypng + pyx + snappy-manifolds + spherogram + tkinter-gl + ]; + + optional-dependencies.snappy-15-knots = [ snappy-15-knots ]; + + postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' + mkdir -p $out/share + cp -r freedesktop/share/{applications,icons} $out/share + ''; + + sphinxRoot = "doc_src"; + + postInstallSphinx = '' + ln -s ''${!outputDoc}/share/doc/$name/html $out/${python.sitePackages}/snappy/doc + ''; + + pythonImportsCheck = [ "snappy" ]; + + checkPhase = '' + runHook preCheck + ${python.interpreter} -m snappy.test --skip-gui + runHook postCheck + ''; + + meta = { + description = "Studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures"; + changelog = "https://snappy.computop.org/news.html"; + mainProgram = "SnapPy"; + homepage = "https://snappy.computop.org"; + license = lib.licenses.gpl2Plus; + maintainers = with lib.maintainers; [ + noiioiu + alejo7797 + ]; + platforms = lib.platforms.linux ++ lib.platforms.darwin; + }; +} diff --git a/pkgs/development/python-modules/tkinter-gl/default.nix b/pkgs/development/python-modules/tkinter-gl/default.nix index d10c824380ee..a39a6d940d4d 100644 --- a/pkgs/development/python-modules/tkinter-gl/default.nix +++ b/pkgs/development/python-modules/tkinter-gl/default.nix @@ -1,9 +1,11 @@ { lib, + python, buildPythonPackage, fetchFromGitHub, setuptools-scm, tkinter, + tkgl, }: buildPythonPackage rec { @@ -18,10 +20,28 @@ buildPythonPackage rec { hash = "sha256-ObI8EEQ7mAOAuV6f+Ld4HH0xkFzqiAZqHDvzjwPA/wM"; }; + postPatch = '' + # Remove compiled TkGL, we compile it ourselves + rm -r src/tkinter_gl/tk + # Platform-specific directories are only necessary when using compiled TkGL + substituteInPlace src/tkinter_gl/__init__.py \ + --replace-fail "pkg_dir = os.path.join(__path__[0], 'tk', sys.platform,)" \ + "pkg_dir = os.path.join(__path__[0], 'tk')" + ''; + build-system = [ setuptools-scm ]; dependencies = [ tkinter ]; + postInstall = + let + pkgDir = "$out/${python.sitePackages}/tkinter_gl/tk"; + in + '' + mkdir -p ${pkgDir} + ln -s ${tkgl}/lib/Tkgl* ${pkgDir} + ''; + pythonImportsCheck = [ "tkinter_gl" ]; meta = { diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 99063ca44ce4..a48822be03f3 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -17299,6 +17299,8 @@ self: super: with self; { snapcast = callPackage ../development/python-modules/snapcast { }; + snappy = callPackage ../development/python-modules/snappy { }; + snappy-15-knots = callPackage ../development/python-modules/snappy-15-knots { }; snappy-manifolds = callPackage ../development/python-modules/snappy-manifolds { };