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

pypa/build on Linux - extension / binary modules in purelib #542

Closed
tcuongd opened this issue Sep 3, 2021 · 10 comments
Closed

pypa/build on Linux - extension / binary modules in purelib #542

tcuongd opened this issue Sep 3, 2021 · 10 comments

Comments

@tcuongd
Copy link

tcuongd commented Sep 3, 2021

Hello! I'm building a package on Linux with extension modules, using setuptools + wheel, and pypa/build to run the build command. I've added a custom distribution class to force platform-specific wheels:

class BinaryDistribution(Distribution):
    """Distribution which always forces a binary package with platform name"""
    def has_ext_modules(self):
        return True

    def is_pure(self):
        return False

setup(..., distclass=BinaryDistribution)

This successfully generates a Linux-specific wheel. Now I want to "repair" the wheel in order to publish it to PyPi. I'm using pypa/auditwheel for this, but it gives this error:

RuntimeError: Invalid binary wheel, found the following shared library/libraries in purelib folder:
  	prophet_model.bin
  	diagnose
  	print
  	stanc
  	stansummary
  	diagnose.o
  	print.o
  	stansummary.o
  	bernoulli
  	main.o
The wheel has to be platlib compliant in order to be repaired by auditwheel.

I had initially thought it could be an issue with auditwheel (posted a question here: pypa/auditwheel#333 (comment)) but I noticed that auditwheel is simple checking the metadata of the wheel here. I'm wondering if there's actually an issue in the wheel creation that's causing the extension modules to land in purelib. Would really appreciate any tips / where to start looking to solve this!

@tcuongd tcuongd changed the title pypa/build on Linux extension modules in purelib pypa/build on Linux - extension / binary modules in purelib Sep 3, 2021
@henryiii
Copy link
Contributor

henryiii commented Sep 3, 2021

Linux with extension modules

If you have extension modules, setuptools will always make this platform specific. I'm guessing you are trying to add them manually instead of using setuptools? If that's the case, I'd generally override the extension build mechanism rather than distclass, such as in https://github.com/pybind/python_example/blob/master/setup.py

@FFY00
Copy link
Member

FFY00 commented Sep 3, 2021

This shouldn't be an issue with pypa/build as we simply provision the environment and invoke the backend, we take no part in the wheel building itself.

Could you provide more details on what you are doing, and perhaps a reproducible too? It seems to you are missing patching in someplace.

@FFY00
Copy link
Member

FFY00 commented Sep 3, 2021

I would transfer this to the setuptools repo, but I can't. @jaraco could you? Thanks 😊

@henryiii
Copy link
Contributor

henryiii commented Sep 3, 2021

Should this go to packaging-problems, perhaps?

@FFY00
Copy link
Member

FFY00 commented Sep 3, 2021

Well, I guess it is close enough, but this really is about customizing the setuptools build.

@henryiii
Copy link
Contributor

henryiii commented Sep 3, 2021

I don't think this is a bug in setuptools, but rather a question on how to do something slightly tricky in packaging (and it touches several projects, auditwheel + setuptools at least).

@FFY00
Copy link
Member

FFY00 commented Sep 3, 2021

I guess, but the root issue really is setuptools, auditwheel is just complaining about a bad wheel. Feel free to move it to packaging-problems, it is not that clear where this belongs.

@henryiii
Copy link
Contributor

henryiii commented Sep 3, 2021

Let's start there. I think we should first assume it's a user issue, and if it turns out to be a setuptools bug, it can move there. Same thing with issues about build, most of them start in packaging-problems and never need to move, as they are user issues with setup.py/setup.cfg. Once in a while, they are bugs in build, and then we move them here.

@henryiii henryiii transferred this issue from pypa/build Sep 3, 2021
@layday
Copy link
Member

layday commented Sep 3, 2021

The problem is that you're declaring the root to be "platlib" but the stuff you're packaging setuptools/wheel believes to be pure, so it places them in xyz.data/purelib in the wheel. Then when auditwheel inspects the wheel it finds them there and errors out. I assume this is for facebook/prophet - you don't need a custom distclass here - you just need to subclass build_ext instead of build_py.

@layday
Copy link
Member

layday commented Nov 15, 2021

Looks like you got it sorted so I'll go ahead and close this one.

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

No branches or pull requests

4 participants