Skip to content

Conversation

@tpgillam
Copy link
Collaborator

@tpgillam tpgillam commented Apr 13, 2025

Aims to:

(See also https://github.com/tpgillam/pymoo/pull/1 for the equivalent PR into my own fork, for which actions have been run).

I'll add a few comments in-line on the PR. A lot more context and commentary is in #676, especially about the proposed migration to the "src layout": #691 (comment)

Probably the most signficant / controversial proposals here are:

  1. the switch to src layout
  2. adoption of uv for dependency & environment management, and as a build frontend

edit: after a bit of debugging, I've got the wheel building working with the non-src-layout, which happily makes this PR a lot smaller. Latest wheel building GitHub action run here: https://github.com/tpgillam/pymoo/actions/runs/14481925309?pr=1

edit 2: the new github action uses uv internally to aid with building, but locally the previous workflow for building would still work (manually creating environment with appropriate build tools and invoking python setup.py directly).

@tpgillam tpgillam changed the title experiments in wheel building Build wheels with cibuildwheel action Apr 16, 2025
@tpgillam tpgillam marked this pull request as ready for review April 16, 2025 00:04
prune .
recursive-include pymoo *.py *.pyx *.pxd
recursive-include pymoo/cython/vendor *.cpp *.h *.py
include LICENSE Makefile pyproject.toml
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

LICENSE and pyproject.toml are included by default

**/*.png
**/*.gif
**/*.cpp
pymoo/cython/*.cpp
Copy link
Collaborator Author

@tpgillam tpgillam Apr 16, 2025

Choose a reason for hiding this comment

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

There is a cpp file under pymoo/cython/vendor that was also git-ignored prior to this change. We only want to ignore the cython-generated files.

@tpgillam
Copy link
Collaborator Author

@blankjul this PR is now reasonably sized, I think. A review would be most appreciated when you have the time, please.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just removing the executable bit on this file (it doesn't need to be executable, and no other source files here had it set)

python-version: '3.10'
- name: Install Dependencies
run: |
pip install --no-cache-dir --upgrade setuptools>=77.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently the build step in this workflow won't respect the bound in pyproject.toml, so a compatible version has to be installed by hand. This could be streamlined in a future PR.

@blankjul blankjul merged commit dc03503 into anyoptimization:main Apr 16, 2025
@blankjul
Copy link
Collaborator

Merged it to see how it runs in github actions

# ---------------------------------------------------------------------------------------------------------


parser = argparse.ArgumentParser()
Copy link
Collaborator

Choose a reason for hiding this comment

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

With the new setup is there a way to reproduce the compilation with the parameters below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, I'm afraid I dropped it all when simplifying for my understanding! I had hoped to discuss before this was merged to better understand the original motivation.

Ideally it would be fantastic to get to the point that we ship binary wheels for all platforms that pymoo aims to support, and then we can remove the user-facing runtime fallback entirely. We'd keep the pure-python implementations of eg. fast-non-dominated sort for the test suite only.

This direction would imply that we'd always want to be able to fully build and compile the package, and that if there was a failure then that's a bug (either in our build setup, or in the environment of the person building it). It also has the nice side-effect of removing pymoo-specific customisation of setup.py, which makes it a little more approachable for new contributors (since it's more "vanilla").

(There's a separate issue of not running cythonize when building an sdist, which I experimented with in this PR but wasn't able to get working reliably. I don't think it's urgent, but I'll aim to get back to that in the future.)

traceback.print_exc()
print("=" * 75)
print()
print("WARNING: For the compiled libraries numpy is required. Please make sure they are installed")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was a fallback to use non-compiled files if compilation failed. Does that still work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

pypi wheels have missing / incorrectly linked shared object files would it be possible to have python-3.13 wheels ?

2 participants