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

Docker: Can't create ortools wheel package #616

Closed
Mizux opened this issue Mar 8, 2018 · 2 comments
Closed

Docker: Can't create ortools wheel package #616

Mizux opened this issue Mar 8, 2018 · 2 comments
Assignees
Labels
Bug Docker Lang: Python Python wrapper issue
Milestone

Comments

@Mizux
Copy link
Collaborator

Mizux commented Mar 8, 2018

On manylinux script (https://github.com/google/or-tools/blob/master/tools/docker/build-manylinux1.sh#L67) :

creating build/bdist.linux-x86_64/wheel/ortools-6.7.4954.dist-info/WHEEL
creating '/root/src/temp-python2.7/ortools/dist/ortools-6.7.4954-cp27-cp27m-linux_x86_64.whl' and adding '.' to it
...
Repairing ortools-6.7.4954-cp27-cp27m-linux_x86_64.whl
Traceback (most recent call last):
  File "/usr/local/bin/auditwheel", line 11, in <module>
    sys.exit(main())
  File "/opt/_internal/cpython-3.6.4/lib/python3.6/site-packages/auditwheel/main.py", line 49, in main
    rval = args.func(args, p)
  File "/opt/_internal/cpython-3.6.4/lib/python3.6/site-packages/auditwheel/main_repair.py", line 60, in execute
    wheel_abi = analyze_wheel_abi(args.WHEEL_FILE)
  File "/opt/_internal/cpython-3.6.4/lib/python3.6/site-packages/auditwheel/wheel_abi.py", line 73, in analyze_wheel_abi
    get_wheel_elfdata(wheel_fn)
  File "/opt/_internal/cpython-3.6.4/lib/python3.6/site-packages/auditwheel/wheel_abi.py", line 42, in get_wheel_elfdata
    so_path_split[-1])
RuntimeError: Invalid binary wheel, found shared library "_pywrapknapsack_solver.so" in purelib folder.
The wheel has to be platlib compliant in order to be repaired by auditwheel.
Makefile:140: recipe for target 'manylinux1-pypi' failed
make: *** [manylinux1-pypi] Error 1

I think, the issue come from setup.py now is shipped with its ".so" cf #551 so it is not a "pure lib" (has never been one BTW).
So setup.py should contains the same line than for the CMake based one cf https://github.com/google/or-tools/blob/master/cmake/python.cmake#L86

from setuptools import dist

class BinaryDistribution(dist.Distribution):
  def is_pure(self):
    return False
  def has_ext_modules(self):
    return True

setup(
...
distclass=BinaryDistribution,

On my way to test a patch

@Mizux Mizux added this to the v6.7 milestone Mar 8, 2018
@Mizux Mizux added Bug Lang: Python Python wrapper issue Docker labels Mar 8, 2018
@Mizux
Copy link
Collaborator Author

Mizux commented Mar 8, 2018

Step to reproduce:

make python
cd temp-python2.7/ortools
python -m pip install wheel
python setup.py bdist_wheel

cd dist
python3.6 -m pip install auditwheel
python3.6 -m auditwheel show *.whl

Trace of the last line:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/google/home/corentinl/.local/lib/python3.6/site-packages/auditwheel/__main__.py", line 5, in <module>
    sys.exit(main())
  File "/usr/local/google/home/corentinl/.local/lib/python3.6/site-packages/auditwheel/main.py", line 49, in main
    rval = args.func(args, p)
  File "/usr/local/google/home/corentinl/.local/lib/python3.6/site-packages/auditwheel/main_show.py", line 28, in execute
    winfo = analyze_wheel_abi(args.WHEEL_FILE)
  File "/usr/local/google/home/corentinl/.local/lib/python3.6/site-packages/auditwheel/wheel_abi.py", line 73, in analyze_wheel_abi
    get_wheel_elfdata(wheel_fn)
  File "/usr/local/google/home/corentinl/.local/lib/python3.6/site-packages/auditwheel/wheel_abi.py", line 42, in get_wheel_elfdata
    so_path_split[-1])
RuntimeError: Invalid binary wheel, found shared library "libortools.so" in purelib folder.
The wheel has to be platlib compliant in order to be repaired by auditwheel.

note: auditwheel is only available on Python 3
https://github.com/pypa/auditwheel/blob/master/auditwheel/wheel_abi.py#L40

@Mizux
Copy link
Collaborator Author

Mizux commented Mar 8, 2018

Since merge of pypa/auditwheel#35 auditwheel (i.e. 1.5) check that wheel package ...purelib/ path must not contains shared libraries aka *.so
note: It doesn't use the distclass Distribution.is_pure().

Actually the problem is during the python setup.py bdist_wheel

...
creating build/bdist.linux-x86_64/wheel/ortools-6.7.4954.dist-info/WHEEL
creating '/usr/local/google/home/corentinl/work/or-tools/temp-python2.7/ortools/dist/ortools-6.7.4954-cp27-cp27mu-linux_x86_64.whl' and adding '.' to it
adding 'ortools-6.7.4954.data/purelib/ortools/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/libortools.so'
adding 'ortools-6.7.4954.data/purelib/ortools/algorithms/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/algorithms/_pywrapknapsack_solver.so'
adding 'ortools-6.7.4954.data/purelib/ortools/algorithms/pywrapknapsack_solver.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/_pywrapcp.so'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/assignment_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/model_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/pywrapcp.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/routing_enums_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/routing_parameters_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/search_limit_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/constraint_solver/solver_parameters_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/data/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/data/_pywraprcpsp.so'
adding 'ortools-6.7.4954.data/purelib/ortools/data/pywraprcpsp.py'
adding 'ortools-6.7.4954.data/purelib/ortools/data/rcpsp_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/graph/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/graph/_pywrapgraph.so'
adding 'ortools-6.7.4954.data/purelib/ortools/graph/pywrapgraph.py'
adding 'ortools-6.7.4954.data/purelib/ortools/linear_solver/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/linear_solver/_pywraplp.so'
adding 'ortools-6.7.4954.data/purelib/ortools/linear_solver/linear_solver_natural_api.py'
adding 'ortools-6.7.4954.data/purelib/ortools/linear_solver/linear_solver_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/linear_solver/pywraplp.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/_pywrapsat.so'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/cp_model_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/pywrapsat.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/sat_parameters_pb2.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/python/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/python/cp_model.py'
adding 'ortools-6.7.4954.data/purelib/ortools/sat/python/visualization.py'
adding 'ortools-6.7.4954.data/purelib/ortools/util/__init__.py'
adding 'ortools-6.7.4954.data/purelib/ortools/util/optional_boolean_pb2.py'
adding 'ortools-6.7.4954.dist-info/DESCRIPTION.rst'
adding 'ortools-6.7.4954.dist-info/metadata.json'
adding 'ortools-6.7.4954.dist-info/top_level.txt'
adding 'ortools-6.7.4954.dist-info/WHEEL'
adding 'ortools-6.7.4954.dist-info/METADATA'
adding 'ortools-6.7.4954.dist-info/RECORD

cf the purelib path everywhere even if package-version.dist-info/WHEEL contains Root-Is-Purelib: false.
note: you can also check using unzip -l dist/*.whl

This due to a bug in distutils.command.install.finalize_options()
Which checks if ext_modules is empty instead of looking at is_pure() or has_ext_modules() from Distribution object...

The solution is to overload install

from setuptools.command.install import install
class InstallPlatlib(install):
    def finalize_options(self):
        install.finalize_options(self)
        if self.distribution.has_ext_modules():
            self.install_lib = self.install_platlib

setup(
  ...
  cmdclass={'install': InstallPlatlib},

ps: thanks to bigartm/bigartm#840

Mizux added a commit that referenced this issue Mar 8, 2018
Mizux added a commit that referenced this issue Mar 8, 2018
@Mizux Mizux closed this as completed Mar 9, 2018
chinmayshah99 added a commit to chinmayshah99/PyDP that referenced this issue May 10, 2020
chinmayshah99 added a commit to OpenMined/PyDP that referenced this issue May 11, 2020
* [#111] Set Up Auto Build and Push to PyPI

At some point it should be linked to real PyPI server
instead of the test one.

Also have to uncomment the `on tag` to rebuild and push only when
a new release  is tagged/made.

* [#111] Fixed a Typo

* [#111] Trying to Fix Path Issue

* [#111] Cleanup

* added pypi publish workflow

* fixed typo

* yet another typo

* removed osx

* moving it to test pypi temp

* Update pypipublish_linux.yml

* added many linux

* reformating

* added many linux yet again

* Update pypipublish_linux.yml

* Update pypipublish_linux.yml

* Update pypipublish_linux.yml

* Update pypipublish_linux.yml

* Update pypipublish_linux.yml

* Add CENTOS 6 compliant  bazel build to workflow

* added zip installation

bazelbuild/bazel#3018 (comment)

* moved bazel to 0.9.0

* fixed typo

* added alternate path for devtools-3

* Update pypipublish_linux.yml

* latest version bazel + fixed dependencies

* fixed pypi upload using ubuntu

* Fixed bug in setup.py wrt shared lib in purelib folder

Fixed it as mentioned in google/or-tools#616 (comment)

* the package seems to manylinux1 rather than 2010

* trying out without whl repair

* Update pypipublish_linux.yml

* fixed typo

* some testing

* rst rendering

* removed wheel version by mistake

* Update pypipublish_linux.yml

* removed auto python3.6 installation

* file version rename

* Update pypipublish_linux.yml

* Update pypipublish_linux.yml

* Update pypipublish_linux.yml

* yet another test

* moved python setup earlier

* Update setup.py

* release ready

* Delete .travis.yml

not needed.

Co-authored-by: novavic <suraiya.uvic@gmail.com>
Co-authored-by: Benardi <benardinunes@gmail.com>
mavenlin added a commit to sail-sg/envpool that referenced this issue Nov 12, 2021
mavenlin added a commit to sail-sg/envpool that referenced this issue Nov 12, 2021
mavenlin added a commit to sail-sg/envpool that referenced this issue Nov 12, 2021
Trinkle23897 pushed a commit to sail-sg/envpool that referenced this issue Nov 12, 2021
The current wheel with a shared library fails to be repaired by auditwheel.

Solution adopted from google/or-tools#616
noobsandnerds added a commit to noobsandnerds/envpool that referenced this issue Aug 7, 2024
The current wheel with a shared library fails to be repaired by auditwheel.

Solution adopted from google/or-tools#616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Docker Lang: Python Python wrapper issue
Projects
None yet
Development

No branches or pull requests

2 participants