Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLD: exclude Cython generated .c and .cpp files from build artifacts #4905

Merged

Conversation

neutrinoceros
Copy link
Member

PR Summary

This makes wheels and sdists much lighter.
Close #4701

PR Checklist

  • New features are documented, with docstrings and narrative docs
  • Adds a test for any bugs fixed. Adds tests for new features.

@neutrinoceros neutrinoceros added build related to the build process enhancement Making something better labels May 17, 2024
@neutrinoceros neutrinoceros force-pushed the build/exclude_generated_code branch 2 times, most recently from d951003 to 69dffdc Compare May 17, 2024 08:46
@neutrinoceros neutrinoceros marked this pull request as ready for review May 17, 2024 09:05
matthewturk
matthewturk previously approved these changes May 17, 2024
Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

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

Nice! This looks like the right set of files to me, too.

MANIFEST.in Outdated
Comment on lines 14 to 56
recursive-exclude yt *.cpp *.c
include yt/utilities/lib/fixed_interpolator.cpp
include yt/utilities/lib/pixelization_constants.cpp
include yt/utilities/lib/origami_tags.c
include yt/utilities/lib/tsearch.c
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason not to include all files found with

$ git ls-files | grep -E '\.[hpp|cpp|c]$'
doc/source/analyzing/_static/axes.c
doc/source/analyzing/_static/axes.h
yt/frontends/artio/artio_headers/artio.c
yt/frontends/artio/artio_headers/artio.h
yt/frontends/artio/artio_headers/artio_endian.c
yt/frontends/artio/artio_headers/artio_endian.h
yt/frontends/artio/artio_headers/artio_file.c
yt/frontends/artio/artio_headers/artio_grid.c
yt/frontends/artio/artio_headers/artio_internal.h
yt/frontends/artio/artio_headers/artio_mpi.c
yt/frontends/artio/artio_headers/artio_mpi.h
yt/frontends/artio/artio_headers/artio_parameter.c
yt/frontends/artio/artio_headers/artio_particle.c
yt/frontends/artio/artio_headers/artio_posix.c
yt/frontends/artio/artio_headers/artio_selector.c
yt/frontends/artio/artio_headers/artio_sfc.c
yt/frontends/artio/artio_headers/cosmology.c
yt/frontends/artio/artio_headers/cosmology.h
yt/geometry/vectorized_ops.h
yt/utilities/lib/cykdtree/windows/stdint.h
yt/utilities/lib/endian_swap.h
yt/utilities/lib/marching_cubes.h
yt/utilities/lib/mesh_triangulation.h
yt/utilities/lib/origami_tags.c
yt/utilities/lib/origami_tags.h
yt/utilities/lib/platform_dep.h
yt/utilities/lib/tsearch.c
yt/utilities/lib/tsearch.h

Copy link
Member

Choose a reason for hiding this comment

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

I think we should avoid excluding anything that we bundle, and instead focus on just excluding the Cython generated sources. Certainly for sdist these are all necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Headers are already included by previous instructions (and should be safe since they're never generated as far as I know). I only included the bare minimum set of files that made python -m build run without errors, and overlooked the rest. Now I'm actually not sure why this seems to work, I guess we are not properly testing that sdists we produce are functional.

Copy link
Member

@cphyc cphyc May 17, 2024

Choose a reason for hiding this comment

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

In the wheel, I don't think we need the .c and .cpp files since the .so files are included. However, in the source, we definitely need them (have you tried compiling from the mere .tar.gz file?).

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't. I'm thinking we should enable some for of testing in the wheel building workflow first.
Let me draft this for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok now we got some form of check rolling, and I addressed this remark (but the grep invoke appeared to be slightly broken so I commited a fixed version of it together with the resulting list)

@neutrinoceros neutrinoceros marked this pull request as draft May 17, 2024 13:57
@neutrinoceros neutrinoceros mentioned this pull request May 17, 2024
2 tasks
MANIFEST.in Outdated Show resolved Hide resolved
@neutrinoceros neutrinoceros changed the title BLD: exclude Cython generated .c and .cpp files from build artifacts BLD: exclude Cython generated .c and .cpp files from build artifacts (⏰ wait for #4909) May 21, 2024
@neutrinoceros neutrinoceros changed the title BLD: exclude Cython generated .c and .cpp files from build artifacts (⏰ wait for #4909) BLD: exclude Cython generated .c and .cpp files from build artifacts May 23, 2024
@neutrinoceros neutrinoceros marked this pull request as ready for review May 23, 2024 19:09
@@ -8,9 +8,54 @@ include yt/utilities/mesh_types.yaml
exclude yt/utilities/lib/cykdtree/c_kdtree.cpp
prune tests
prune answer-store
recursive-include yt *.py *.pyx *.pxi *.pxd *.h *.hpp README* *.txt LICENSE* *.cu
recursive-include yt *.py *.pyx *.pxi *.pxd README* *.txt LICENSE* *.cu
recursive-include doc *.rst *.txt *.py *.ipynb *.png *.jpg *.css *.html
recursive-include doc *.h *.c *.sh *.svgz *.pdf *.svg *.pyx
Copy link
Member

Choose a reason for hiding this comment

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

Now that we are at it, there are no .svgz nor .pdf in the doc folder, unless they are generated on our CI?

Suggested change
recursive-include doc *.h *.c *.sh *.svgz *.pdf *.svg *.pyx
recursive-include doc *.h *.c *.sh *.svg *.pyx

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the latex cheatsheet is a generated pdf. I don't know of generated .svgz files but I'd err on the side of caution and label this as out of scope here.

Copy link
Member

Choose a reason for hiding this comment

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

Fine, this honestly doesn't matter much and is not worth debating as far as I'm concerned :)

@@ -8,9 +8,54 @@ include yt/utilities/mesh_types.yaml
exclude yt/utilities/lib/cykdtree/c_kdtree.cpp
Copy link
Member

Choose a reason for hiding this comment

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

This bit is included below (see line 40).

Suggested change
exclude yt/utilities/lib/cykdtree/c_kdtree.cpp

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yeah, good catch. I have no idea why but this file is actually empty so it probably doesn't hurt to include it back.
@Xarthisius wrote the exclude line in #3403, so let's give him a chance to comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

from that PR's description:

excludes that I added are mostly cosmetic

Copy link
Member

Choose a reason for hiding this comment

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

OK, whatever you decide I'm happy with. It's not as if adding an empty cpp file would significantly increase the archive size.

@neutrinoceros neutrinoceros added this to the 4.4.0 milestone May 29, 2024
@neutrinoceros neutrinoceros merged commit 6b4ccf5 into yt-project:main May 29, 2024
19 checks passed
@neutrinoceros neutrinoceros deleted the build/exclude_generated_code branch May 29, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build related to the build process enhancement Making something better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package Cython-generated *.cpp and *.c files
4 participants