Skip to content

Conversation

noiioiu
Copy link

@noiioiu noiioiu commented Jun 9, 2025

SnapPy is a program and python module for studying the topology and geometry of 3-manifolds.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Jun 9, 2025
@nix-owners nix-owners bot requested a review from natsukium June 9, 2025 04:28
@noiioiu noiioiu force-pushed the SnapPy branch 2 times, most recently from e29fc6f to 44785a0 Compare June 9, 2025 04:32
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. labels Jun 9, 2025
@noiioiu noiioiu force-pushed the SnapPy branch 2 times, most recently from e32e681 to 6ca033f Compare June 9, 2025 11:29
@noiioiu noiioiu requested review from dotlambda and a user June 9, 2025 11:29

postInstall = ''
cp -r src/tkinter_gl/tk $out/${python.sitePackages}/tkinter_gl/
patchelf --set-rpath ${lib.makeLibraryPath [ libGL ]} \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be fixed upstream.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source is here, but there are no releases and I haven't tried compiling it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a package for tkgl and added it as a dependency of tkinter-gl instead of patching the compiled ones, the tests still run.

@noiioiu noiioiu requested a review from dotlambda June 21, 2025 01:39
@ghost ghost removed their request for review June 21, 2025 16:38
@noiioiu
Copy link
Author

noiioiu commented Jun 22, 2025

aarch64-linux build failed

What was the error?

@noiioiu
Copy link
Author

noiioiu commented Jun 22, 2025

error: Cannot build '/nix/store/1cba3fckayf1gnzrwxm0n4aq70p0kmqr-python3.12-cypari-2.5.5.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/148d6lzr52xnn18hkvqwxdrk3b1dg8ql-python3.12-cypari-2.5.5
         /nix/store/f1zm2bk5s9hmlaksmas74j7qp2h34lw7-python3.12-cypari-2.5.5-dist
       Last 25 log lines:
       > copying cypari/memory.py -> build/lib.linux-aarch64-cpython-312/cypari
       > copying cypari/py2tests.py -> build/lib.linux-aarch64-cpython-312/cypari
       > copying cypari/test.py -> build/lib.linux-aarch64-cpython-312/cypari
       > copying cypari/version.py -> build/lib.linux-aarch64-cpython-312/cypari
       > copying cypari/py3tests.py -> build/lib.linux-aarch64-cpython-312/cypari
       > copying cypari/tests.py -> build/lib.linux-aarch64-cpython-312/cypari
       > running build_ext
       > Building gmp ...
       > Extracting gmp source code ...
       > Configuring gmp with ./configure --build=x86_64-none-none --prefix=/build/source/libcache/gmp --with-pic
       > checking build system type... x86_64-none-none
       > checking host system type... x86_64-none-none
       > checking for a BSD-compatible install... /nix/store/6sb7gak61cwcg3p5grnhhyndi5hz935y-coreutils-9.7/bin/install -c
       > checking whether build environment is sane... yes
       > checking for a thread-safe mkdir -p... /nix/store/6sb7gak61cwcg3p5grnhhyndi5hz935y-coreutils-9.7/bin/mkdir -p
       > checking for gawk... gawk
       > checking whether make sets $(MAKE)... yes
       > checking whether make supports nested variables... yes
       > checking whether to enable maintainer-specific portions of Makefiles... no
       > checking ABI=64
       > checking compiler gcc -O2 -pedantic -fomit-frame-pointer -m64 ... no
       > configure: error: could not find a working compiler, see config.log for details
       > ***Failed to build PARI library***
       >
       > ERROR Backend subprocess exited when trying to invoke build_wheel
       For full logs, run:
         nix log /nix/store/1cba3fckayf1gnzrwxm0n4aq70p0kmqr-python3.12-cypari-2.5.5.drv

Ok, it looks like the source of the bug is here. The script will need to be patched.

@noiioiu noiioiu requested a review from a user June 22, 2025 03:46
@github-actions github-actions bot removed the 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. label Jun 22, 2025
@ghost ghost removed their request for review July 2, 2025 17:02
@noiioiu noiioiu force-pushed the SnapPy branch 3 times, most recently from 6c33279 to 8966abc Compare July 7, 2025 03:47
@noiioiu
Copy link
Author

noiioiu commented Jul 7, 2025

Still can't build, I think it's enough to mark darwin as broken for now. I don’t have the energy to review anymore.

Cypari is now marked as broken on darwin.

@ghost ghost removed their request for review July 11, 2025 20:55
@noiioiu noiioiu force-pushed the SnapPy branch 2 times, most recently from 5b64066 to fb798fc Compare July 25, 2025 12:57
@alejo7797
Copy link
Contributor

Thank you for taking the time to package SnapPy and its dependencies!
May I suggest adding a small pkgs/by-name/sn/snappy-topology/package.nix wrapper?

The attribute name is not too important, but unfortunately pkgs.snappy is taken.
I think snappy-topology is okay; I couldn't find any recommendations upstream.

@noiioiu
Copy link
Author

noiioiu commented Aug 18, 2025

Thank you for taking the time to package SnapPy and its dependencies! May I suggest adding a small pkgs/by-name/sn/snappy-topology/package.nix wrapper?

The attribute name is not too important, but unfortunately pkgs.snappy is taken. I think snappy-topology is okay; I couldn't find any recommendations upstream.

OK it has been added.

Copy link
Contributor

@alejo7797 alejo7797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few suggestions for changes which I hope are helpful.

snappy-15-knots,
snappy-manifolds,
spherogram,
sphinx,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sphinx,
sphinxHook,

A suggestion: I wonder if it might be good to build the docs using Nixpkgs' sphinxHook?
There's a few other changes to the derivation needed to make this work, shown below.

Please ignore my suggestions if I'm missing some important reason for not doing this!

pname = "snappy";
version = "3.2";
pyproject = true;

Copy link
Contributor

@alejo7797 alejo7797 Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outputs = [
"out"
"doc"
];

Re: sphinxHook

Copy link
Author

@noiioiu noiioiu Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can cause problems with nix-shell. Or does this fix it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that avoids issues? I tried running nix-shell -I nixpkgs=. -p "python3.withPackages (ps: [ps.snappy])", then SnapPy, and clicking on the "SnapPy Help" button opened the documentation in my browser correctly.

Admittedly, I'm not sure if we'll enjoy the advantages of separating the documentation into its own output with that in place. The idea is to reduce the closure size of packages that just want to use the snappy libraries, but I think the doc output always gets pulled in the way things are now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, it seems to work. Maybe the SnapPy gui should be in a separate output then? But I'm not really sure how to do that.

postPatch = ''
substituteInPlace setup.py \
--replace-fail "/usr/include/GL" "${libGL.dev}/include/GL" \
--replace-fail "'python/doc'" "'$out/${python.sitePackages}/snappy/doc'"
Copy link
Contributor

@alejo7797 alejo7797 Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--replace-fail "'python/doc'" "'$out/${python.sitePackages}/snappy/doc'"
substituteInPlace python/app_menus.py \
--replace-fail "os.path.join(os.path.dirname(snappy_dir), 'doc')" \
"os.path.join('${placeholder "doc"}', 'share', 'doc', '$name', 'html')"

Re: sphinxHook. For the help pages to be found within SnapPy.

Comment on lines 64 to 75
sphinx
sphinx-rtd-theme
];
Copy link
Contributor

@alejo7797 alejo7797 Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sphinx
sphinx-rtd-theme
];
];
nativeBuildInputs = [
sphinxHook
sphinx-rtd-theme
];
sphinxRoot = "doc_src";

Re: sphinxHook. Actually implementing it.


buildInputs = [
libGL
libX11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
libX11

Repeat from above: SnapPy builds fine without this for me?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed it, it seems it is not necessary.

Comment on lines 91 to 96

env.NIX_CFLAGS_COMPILE = toString [
"-I${libGL.dev}/include"
"-I${libX11.dev}/include"
];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
env.NIX_CFLAGS_COMPILE = toString [
"-I${libGL.dev}/include"
"-I${libX11.dev}/include"
];

I don't think this needs to be specified manually. Correct me if I'm wrong.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to build without these, I don't remember why I thought they were necessary.

];

postInstall = ''
${python.interpreter} setup.py build_docs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${python.interpreter} setup.py build_docs

Re: sphinxHook. Not needed with that in use.

@noiioiu noiioiu force-pushed the SnapPy branch 2 times, most recently from f392323 to d23d681 Compare August 19, 2025 18:36
Copy link
Contributor

@alejo7797 alejo7797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on #415184 (comment):

Yeah I'm not sure how to build SnapPy without the GUI but these changes might sort of solve the problem. The idea being that if you want to run the SnapPy GUI and have the documentation work you install pkgs.snappy-topology, and if you just want to have the pkgs.python3Packages.snappy to import into, e.g. Sage, then you don't end up with the documentation in your shell closure.

Not sure if this way of going about things is okay.
Maybe someone with more experience can say.

spherogram,
sphinxHook,
sphinx-rtd-theme,
tkinter-gl,

This comment was marked as resolved.

Comment on lines +60 to +62
substituteInPlace python/app_menus.py \
--replace-fail "os.path.join(os.path.dirname(snappy_dir), 'doc')" \
"os.path.join('${placeholder "doc"}', 'share', 'doc', '$name', 'html')"

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would cause python3Packages.snappy to install a broken version of the gui?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah :/ The only thing that doesn't work, though, is opening the HTML documentation from the SnapPy GUI (which makes sense if withDocs = false). Since the docs are also on snappy.computop.org maybe not including the docs by default is okay? It looks like this is essentially what happens in Nixpkgs for other Python packages using sphinxHook to build their documentation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little broken is still broken, and installing broken software is much worse than including a few extra megabytes of html.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm going to have to agree with that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what should I do for now? Leave it as is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as it is now. Upstream expects the documentation to be somewhere on the system.

Copy link
Contributor

@alejo7797 alejo7797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I took a look at the tkgl derivation definition.
Using tcl.mkTclDerivation would be more idiomatic.
I have some other small suggestions for changes.

"--with-tclinclude=${lib.getDev tcl}/include"
"--with-tk=${lib.getLib tk}/lib"
"--with-tkinclude=${lib.getDev tk}/include"
"--libdir=${placeholder "out"}/lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"--libdir=${placeholder "out"}/lib"

This gets taken care of by stdenv.

Comment on lines 23 to 25
substituteInPlace Makefile.in \
--replace-fail "install: all install-binaries install-libraries install-doc" \
"install: all install-binaries"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
substituteInPlace Makefile.in \
--replace-fail "install: all install-binaries install-libraries install-doc" \
"install: all install-binaries"

I think it's cleaner to specify installTargets.

"--with-tkinclude=${lib.getDev tk}/include"
"--libdir=${placeholder "out"}/lib"
];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
installTargets = [
"install-binaries"
];

Copy link
Contributor

@alejo7797 alejo7797 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it turns out sphinxHook supports a postInstallSphinx step.
Using this simplifies getting SnapPy to find the documentation.

Comment on lines +60 to +62
substituteInPlace python/app_menus.py \
--replace-fail "os.path.join(os.path.dirname(snappy_dir), 'doc')" \
"os.path.join('${placeholder "doc"}', 'share', 'doc', '$name', 'html')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
substituteInPlace python/app_menus.py \
--replace-fail "os.path.join(os.path.dirname(snappy_dir), 'doc')" \
"os.path.join('${placeholder "doc"}', 'share', 'doc', '$name', 'html')"

Found a better way to handle this.

Comment on lines +77 to +78
sphinxRoot = "doc_src";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sphinxRoot = "doc_src";

Let's move this down after postInstall.

postInstall = ''
cp -r freedesktop/share $out/
'';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sphinxRoot = "doc_src";
postInstallSphinx = ''
ln -s ''${!outputDoc}/share/doc/$name/html $out/${python.sitePackages}/snappy/doc
'';

Sorry for my earlier suggestion, I feel that this way of handling the documentation will give less friction.
For example, this avoids a warning during the checkPhase.

@alejo7797
Copy link
Contributor

Nixpkgs bumped cython to version 3.1.2 and now cypari won't build.
I'm not sure what this should mean for this PR. I see these two options:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 12.first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants