Skip to content

kikit: use latest shapely#268277

Closed
imincik wants to merge 1 commit intoNixOS:masterfrom
imincik:kikit-use-latest-shapely
Closed

kikit: use latest shapely#268277
imincik wants to merge 1 commit intoNixOS:masterfrom
imincik:kikit-use-latest-shapely

Conversation

@imincik
Copy link
Contributor

@imincik imincik commented Nov 18, 2023

Description of changes

Please consider to use latest shapely version (currently 2.0.2) instead of
obsolete, custom built version 1.8.4.

I am aware of upstream plans to move away from shapely (https://github.com/
yaqwsx/KiKit/issues/574) and doesn't want to support newer shapely versions,
all kikit tests are passing with the new one.

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/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (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.

@ofborg ofborg bot requested review from jfly and matusf November 18, 2023 12:22
@ofborg ofborg 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. labels Nov 18, 2023
@jfly
Copy link
Contributor

jfly commented Nov 18, 2023

@imincik, thanks for the contribution!

I'm not sure how much to trust kikit's unit tests here. Shapely 2.0 is a big release that documents a number of breaking changes. I unfortunately don't know enough about kikit to know how to exercise any of its interactions with shapely. Are you a kikit user? Are you able to confirm that things still work after this change?

Perhaps most importantly, what's the purpose of this change? Is the old version of shapely causing a maintenance burden I'm not familiar with? Without more context, it doesn't seem worth the risk to me, especially as we expect all this to disappear someday when upstream drops shapely entirely.

@imincik
Copy link
Contributor Author

imincik commented Nov 18, 2023

I am not a kikit user, but I am one of the shapely package maintainers.

I don't think that keeping some random, not maintained copy of dependency (shapely 1.8.4 is not even the latest 1.8.x version) inside of a package is a good practice.

If you are really sure that we can't trust kikit's tests, maybe the better solution is to package shapely 1.8.5 as part of shapely package. Then you can just use it and it will be maintained together with the latest version. I can do that for you if you agree. In this way it can be used by others as well.

@imincik
Copy link
Contributor Author

imincik commented Nov 18, 2023

I just tried to run

./result/bin/kikit panelize \
    --layout 'grid; rows: 2; cols: 2; space: 2mm' \
    --tabs 'fixed; width: 3mm; vcount: 2' \
    --cuts 'mousebites; drill: 0.5mm; spacing: 1mm; offset: 0.2mm; prolong: 0.5mm' \
    --framing 'frame; width: 5mm; space: 3mm; mintotalheight: 100mm; mintotalwidth: 100mm' \
    --tooling '3hole; hoffset: 2.5mm; voffset: 2.5mm; size: 1.5mm' \
    --fiducials '3fid; hoffset: 5mm; voffset: 2.5mm; coppersize: 2mm; opening: 1mm;' \
    --text 'simple; text: yaqwsxs panel with minimal dimensions; anchor: mt; voffset: 2.5mm; hjustify: center; vjustify: center;' \
    --post 'millradius: 1mm' \
   kikit/code/docs/resources/conn.kicad_pcb panel.kicad_pcb

and it didn't complain.

I suggest to implement nix package tests using commands like this. If we are not sure about upstream tests quality, then nix package test make a sense even more.

@jfly
Copy link
Contributor

jfly commented Nov 20, 2023

I just tried to run [...] and it didn't complain.

That's promising! (And I agree, we should do some investigation into how comprehensive upstream tests are, and if they're not, we should either contribute tests upstream, or add tests to our derivation.)

That said, I'm afraid I still get can't comfortable with upgrading to shapely 2.0+ without understanding the reason for this commit. I can't tell if this upper bound was added out of an abundance of caution, or because something legitimately broke. Furthermore, I wouldn't really want to bother upstream with questions like this, as they clearly aren't interested in spending any time on shapely.

maybe the better solution is to package shapely 1.8.5 as part of shapely package

I prefer this. In fact, I'm not even sure why we packaged 1.8.4 instead of 1.8.5. Perhaps because 1.8.5 was never packaged by nixpkgs (it looks like we jumped from 1.8.4 to 2.0.0 here). Perhaps @matusf remembers?

@matusf
Copy link
Member

matusf commented Nov 20, 2023

Hi, sorry for the late response. I don't feel confident about upgrading a major version of a dependency, especially when the upstream project has constraints on the version. I also don't think we can rely solely on the unit tests, particularly in a dynamic language like Python. This suggestion should instead be offered to the developers of Kikit (as @jfly mentioned, we've already done that, and they plan to stop using Shapely). Therefore, I suggest we stick with the 1.x.x version.

Regarding the tests, since I'm not a Kikit user, I don't feel confident in creating thorough tests for Kikit. I also believe they should be maintained by the upstream project rather than here. For instance, a new version of Kikit might break the tests, but that could be the desired behavior. It would be challenging to differentiate intentional changes in behavior from potential bugs.

Maybe @matusf remembers?

Yes, as you mentioned, version 1.8.5 was never packaged by nixpkgs. We selected the latest version in history that satisfied the constraints.

Perhaps a better solution is to include Shapely 1.8.5 as part of the Shapely package?

Yes, if we decide to upgrade the version of Shapely, I'd prefer to move from 1.8.4 to the 1.8.5 (latest before v2).

@imincik
Copy link
Contributor Author

imincik commented Nov 22, 2023

I understand what you are saying.

I was just about to create frozen shapely_1_8 package for you, but unfortunately, I realised that it is going to have a problems with latest geos which is about to be merged soon.

I just tried to build kikit's copy of Shapely with latest GEOS PR:

$ gh pr checkout 268130

$ nix-build -I nixpkgs=. --expr '(import <nixpkgs> {}).pkgs.python3.pkgs.callPackage ./pkgs/by-name/ki/kikit/shapely {}'

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[MULTIPOINT (1 1 1, 2 2)-MULTIPOINT Z (1 1 1, 2 2 0)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[MULTIPOINT (1 1, 2 2 2)-MULTIPOINT Z (1 1 0, 2 2 2)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[LINESTRING (1 1 1, 2 2)-LINESTRING Z (1 1 1, 2 2 0)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[POLYGON ((0 0 0, 1 0 0, 1 1, 0 1 0, 0 0 0))-POLYGON Z ((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 0))] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[LINESTRING (1 1, 2 2 2)-LINESTRING (1 1, 2 2)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[POLYGON ((0 0, 1 0 1, 1 1, 0 1, 0 0))-POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
FAILED tests/test_parallel_offset.py::OperationsTestCase::test_parallel_offset_linestring - AssertionError: <shapely.geometry.linestring.LineString object at 0x7fff729...
FAILED tests/test_voronoi_diagram.py::test_edges - assert False
======= 8 failed, 475 passed, 1 skipped, 2 xfailed, 13 warnings in 1.19s =======
/nix/store/wr08yanv2bjrphhi5aai12hf2qz5kvic-stdenv-linux/setup: line 1559: pop_var_context: head of shell_variables not a function context
error: builder for '/nix/store/m0fgbibc3jvsv22ac8inc98vfdq5v3ar-python3.11-Shapely-1.8.4.drv' failed with exit code 1;
       last 10 log lines:
       > FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[MULTIPOINT (1 1 1, 2 2)-MULTIPOINT Z (1 1 1, 2 2 0)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
       > FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[MULTIPOINT (1 1, 2 2 2)-MULTIPOINT Z (1 1 0, 2 2 2)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
       > FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[LINESTRING (1 1 1, 2 2)-LINESTRING Z (1 1 1, 2 2 0)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
       > FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[POLYGON ((0 0 0, 1 0 0, 1 1, 0 1 0, 0 0 0))-POLYGON Z ((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 0))] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
       > FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[LINESTRING (1 1, 2 2 2)-LINESTRING (1 1, 2 2)] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
       > FAILED tests/test_create_inconsistent_dimensionality.py::test_create_from_wkt[POLYGON ((0 0, 1 0 1, 1 1, 0 1, 0 0))-POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))] - shapely.errors.WKTReadingError: Could not create geometry because of errors...
       > FAILED tests/test_parallel_offset.py::OperationsTestCase::test_parallel_offset_linestring - AssertionError: <shapely.geometry.linestring.LineString object at 0x7fff729...
       > FAILED tests/test_voronoi_diagram.py::test_edges - assert False
       > ======= 8 failed, 475 passed, 1 skipped, 2 xfailed, 13 warnings in 1.19s =======
       > /nix/store/wr08yanv2bjrphhi5aai12hf2qz5kvic-stdenv-linux/setup: line 1559: pop_var_context: head of shell_variables not a function context

It means that if we want to keep kikit on functional shapely version we need to keep shapely 1.8.x along with GEOS 3.11.x .

@jfly
Copy link
Contributor

jfly commented Nov 22, 2023

Ah, darn. Now I'm starting to see how keeping this old version of shapely can evolve into a maintenence headache for other stuff in nixpkgs.

Let me know if you'd like some help introducing a pinned geos as well. I also think that if this turns into a third thing we need to pin just to keep kikit happy, I could see us pushing back upstream and saying this package is at risk of getting dropped/being marked broken in nixpkgs. Maybe that'll encourage them to upgrade geometry engines... 🤞

@imincik imincik mentioned this pull request Dec 6, 2023
13 tasks
@imincik
Copy link
Contributor Author

imincik commented Dec 6, 2023

@jfly @matusf , I packaged GEOS 3.11 and shapely 1.8 and changed kikit to use it in #268130 . Please review.

@imincik
Copy link
Contributor Author

imincik commented Dec 6, 2023

Shapely is solved as part of #268130 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants