collective / buildout.python

Buildout all the Pythons
109 stars 47 forks source link

Add zlib. #77

Closed fschulze closed 6 years ago

fschulze commented 6 years ago

Add zlib to the build, so Python 2.4 compiles on Linux and compilation of Python on High Sierra works properly.

Can anyone confirm that this is required for macOS High Sierra? Maybe it's just on my box. Homebrew doesn't link zlib into /usr/local anymore, because macOS provides it's own zlib, but that one isn't picked up by configure.

As one can see, it fixes compilation of Python 2.4 on Linux (see https://travis-ci.org/collective/buildout.python/builds/333668504) and compare to this PRs results.

mjpieters commented 6 years ago

Hrm, Python 2.4 builds just fine on my High Sierra system, without this patch. The resulting zlib.so links to /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0) according to otool -L.

hannosch commented 6 years ago

I haven't tried building Python 2.x other than 2.7 in a long time. So I trust what @mjpieters says :)

fschulze commented 6 years ago

I wonder what is going on with Linux then, why does Python 2.4 not build _zlib, but 2.5+ does? Maybe it's the same issue as on macOS. Notice also that this only happened after I removed the parts folder and recompiled on High Sierra after upgrading from Sierra.

mjpieters commented 6 years ago

I'll try to do a full rebuild when home. I think I already did that when I upgraded but will do that again.

mjpieters commented 6 years ago

I blew away the parts directory and started a new build. It is still running but Python 2.4 building completed, and zlib was built:

/Users/mjpieters/Development/Library/buildout.python/parts/opt/lib/python2.4/lib-dynload/zlib.so:
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

I don't think my local.cfg is of any consequence, but for the 2.4 build the relevant parts are:

[buildout]
extends = buildout.cfg

[install-links]
prefix = ~

[sharedenv]
environment =
    LDFLAGS=-L/usr/local/opt/openssl/lib
    CPPFLAGS=-I/usr/local/opt/openssl/include

[python-2.4-build:default]
environment = ${sharedenv:environment}
mjpieters commented 6 years ago

Could the Xcode version be of consequence?

$ xcode-select -p
/Applications/Xcode_9.0.0_fb.app/Contents/Developer

That's the internal Facebook packaging for Xcode 9.0.0.

tisto commented 6 years ago

I can confirm that master branch currently fails on Linux (Ubuntu 16.04) and that @fschulze's branch works like a charm:

/home/timo/workspace/plone/buildout.python/parts/opt/bin/python2.4 /home/timo/workspace/plone/buildout.python/src/ez_setup-1.x.py
/home/timo/workspace/plone/buildout.python/parts/opt/bin/easy_install-2.4 pip==1.1
/home/timo/workspace/plone/buildout.python/bin/virtualenv-2.4 --system-site-packages /home/timo/workspace/plone/buildout.python/python-2.4
/home/timo/workspace/plone/buildout.python/python-2.4/bin/pip install --pypi-url=https://pypi.python.org/simple collective.dist'
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
Extracting in /tmp/tmpeva8Ug
Traceback (most recent call last):
  File "/home/timo/workspace/plone/buildout.python/src/ez_setup-1.x.py", line 382, in ?
    sys.exit(main())
  File "/home/timo/workspace/plone/buildout.python/src/ez_setup-1.x.py", line 379, in main
    return _install(tarball, _build_install_args(options))
  File "/home/timo/workspace/plone/buildout.python/src/ez_setup-1.x.py", line 55, in _install
    tar = tarfile.open(tarball)
  File "/home/timo/workspace/plone/buildout.python/parts/opt/lib/python2.4/tarfile.py", line 924, in open
    raise ReadError, "file could not be opened successfully"
tarfile.ReadError: file could not be opened successfully
/bin/sh: 3: /home/timo/workspace/plone/buildout.python/parts/opt/bin/easy_install-2.4: not found
Traceback (most recent call last):
  File "/home/timo/workspace/plone/buildout.python/parts/virtualenv172/virtualenv.py", line 19, in ?
    import zlib
ImportError: No module named zlib
/bin/sh: 5: /home/timo/workspace/plone/buildout.python/python-2.4/bin/pip: not found
python-2.4: Non zero exit code (127) while running command.
While:
  Installing python-2.4.
Error: Non zero exit code (127) while running command.

BTW: we could try to test buildout.python on Travis, at least on Ubuntu...

mjpieters commented 6 years ago

BTW: we could try to test buildout.python on Travis, at least on Ubuntu...

We already do, see https://travis-ci.org/collective/buildout.python and https://github.com/collective/buildout.python/blob/master/.travis.yml

mauritsvanrees commented 6 years ago

And Travis for Python 2.4 passes. The only failure is for PyPy on Mac, which was already broken in previous builds. I will merge. Thanks!

mjpieters commented 6 years ago

I did state that the OS X parts were not needed, and the Travis builds do confirm this. Can we please remove the Darwin changes in the patch? I feel they open us up for more maintenance burden than is required.

mauritsvanrees commented 6 years ago

Then why did the Travis tests pass for this PR? Strange. Maybe they ran too long ago, and something happened on master that interferes with this PR?

Also, I don't see how to disable this patch on darwin only. Can we somehow make zlib-parts empty on darwin?

BTW, on my Mac 10.13.3, with this PR merged, Python2.4 builds fine.

mjpieters commented 6 years ago

BTW, on my Mac 10.13.3, with this PR merged, Python2.4 builds fine.

Yes, and it builds fine without the PR too, that's my point. :-) See this Travis 2.4 OS X build, which succeeded before the PR was merged. That's on 10.12, but I can build the same binary on my 10.13 laptop with no issues.

Also, I don't see how to disable this patch on darwin only.

Just leave the darwin zlib parts empty, rather than pull in the default part?

mauritsvanrees commented 6 years ago

But then it does not have a recipe, and buidout fails. Ah, but I can use a dummy recipe that basically does nothing. Let's see what PR #79 does.

fschulze commented 6 years ago

Finally solved this. I had the same issue with Pillow and found this: https://stackoverflow.com/questions/32909426/zlib-error-when-installing-pillow-on-mac#33003406 (note who answered it 😛 ) The fix was to run xcode-select --install