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

Python CMake Installation Workaround #966

Closed
wants to merge 1 commit into from

Conversation

cjmayo
Copy link
Contributor

@cjmayo cjmayo commented Sep 29, 2024

  • EXCLUDE_FROM_ALL means doing a separate install for the manifold3d target? No problem with that - except it doesn't install the Python module for me. (although if you have set MANIFOLD_PYBIND you want to install it?)

  • Installing py.typed directly into site-packages is ambiguous. a manifold3d directory needed? __init__.py, new library name???

I don't have any answers, just illustrating with a workaround.

@elalish
Copy link
Owner

elalish commented Sep 29, 2024

I have no idea, but if you mark it ready for review at least we'll see if the CI likes it. @starseeker @pca006132 any opinions here?

@starseeker
Copy link
Contributor

Um. Not offhand - is this something the new hierarchy broke?

@elalish elalish marked this pull request as ready for review September 30, 2024 04:33
@elalish
Copy link
Owner

elalish commented Sep 30, 2024

Github doesn't handle Draft PRs very well - I think you'll need to pull master and push to get the CI unstuck.

@pca006132
Copy link
Collaborator

We should probably remove condition to run CI only on non-draft PRs... It seems that I added it two years ago for some unknown reason.

@pca006132
Copy link
Collaborator

  1. Which command did you use to install manifold3d?
  2. According to https://peps.python.org/pep-0561/#packaging-type-information, it seems that we should install it alongside to manifold3d.pyi?

@cjmayo
Copy link
Contributor Author

cjmayo commented Sep 30, 2024

I made it draft because this really isn't the solution!

The relevant change is 31d6da0.

  1. Which command did you use to install manifold3d?

I am using a Gentoo ebuild and it's cmake wrapper. I've been trying to recreate with Ubuntu but can't even get it to build the Python module yet.

  1. According to https://peps.python.org/pep-0561/#packaging-type-information, it seems that we should install it alongside to manifold3d.pyi?

Yes, I guess it should install something like:

manifold3d/
   __init__.py
    _manifold3d.cpython-312-x86_64-linux-gnu.so
    _manifold3d.pyi
    py.typed

but that really is a guess!

@pca006132
Copy link
Collaborator

  1. Can you give me a build log? I mean the cmake --install command you use to install manifold. Maybe gentoo can configure that to install some specific target?

  2. It seems that this is the current result, installed with nix:

    $ ls result/lib/python3.12/site-packages/
    manifold3d-2.5.1.dist-info  manifold3d.cpython-312-x86_64-linux-gnu.so  manifold3d.pyi  py.typed
    

    If this is not what you got, can you show me the result you got?

@pca006132
Copy link
Collaborator

@cjmayo I guess you can try

src_install() {
  cmake_src_install
  cmake_build --install . --component bindings
}

@cjmayo
Copy link
Contributor Author

cjmayo commented Oct 1, 2024

@cjmayo I guess you can try

src_install() {
  cmake_src_install
  cmake_build --install . --component bindings
}

Thanks for the component pointer. cmake_build is a wrapper around make and ninja though so can only pass targets.

This works:

src_install() {
	cmake_src_install
	DESTDIR="${D}" cmake --install "${BUILD_DIR}" --component bindings
}

Although there is a comment in dev-qt/qt-creator/qt-creator-14.0.1.ebuild:

	if use plugin-dev; then #928423
		# cmake --install --component integrates poorly with the cmake
		# eclass and the install targets are otherwise missing, so strip
		# out EXCLUDE_FROM_ALL until figure out a better solution
		find . \( -name CMakeLists.txt -o -name '*.cmake' \) -exec sed -i -zE \
			's/COMPONENT[[:space:]]+Devel[[:space:]]+EXCLUDE_FROM_ALL//g' {} + || die
	fi

so not sure if they would get accepted.

What was the reason for EXCLUDE_FROM_ALL? For myself I've set MANIFOLD_PYBIND because I want to install it.

@cjmayo
Copy link
Contributor Author

cjmayo commented Oct 1, 2024

2. It seems that this is the current result, installed with nix:

   $ ls result/lib/python3.12/site-packages/
   manifold3d-2.5.1.dist-info  manifold3d.cpython-312-x86_64-linux-gnu.so  manifold3d.pyi  py.typed

Yes that is what I get and it will not be accepted because py.typed is installed directly in site-packages.

@pca006132
Copy link
Collaborator

  1. I guess it is fine to remove it. I added it so it will not be installed automatically for nixos (and it cannot be installed due to path issues), but maybe we should not build the python bindings for normal packages instead.
  2. I'm thinking if py.typed is needed at all in our case. I think it is for type checking normal python modules, but we have none here. Maybe we can just remove it.

@pca006132
Copy link
Collaborator

Closing in flavor of #973

@pca006132 pca006132 closed this Oct 2, 2024
@cjmayo
Copy link
Contributor Author

cjmayo commented Oct 2, 2024

That works thanks.

  1. Indeed, for Gentoo having a separate target to build and install the Python module would probably be ideal - it could then be built for multiple versions of Python at once while libmanifold was built once.

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.

4 participants