Opened 5 years ago

Closed 5 years ago

#20437 closed defect (fixed)

Misinstallation of Python in Cygwin

Reported by: embray Owned by:
Priority: major Milestone: sage-7.2
Component: porting: Cygwin Keywords:
Cc: tscrim, gouezel, jpflori Merged in:
Authors: Erik Bray Reviewers: Sebastien Gouezel
Report Upstream: Reported upstream. No feedback yet. Work issues:
Branch: 71062f0 (Commits, GitHub, GitLab) Commit: 71062f01ef52e723f780044ffd08b4f46520bd75
Dependencies: Stopgaps:

Status badges

Description (last modified by embray)

I've encountered yet another problem in my quest to get sage building on Cygwin. I'm surprised this hasn't come up before though which makes me wonder if I'm doing something wrong.

The DLL loader library, libpython2.7.dll.a, gets installed to $(SAGE_LOCAL)/lib/python2.7/config/ which is not normally on the ld search path (similar on Python 3 I think).

This means that when building extension modules -lpython2.7 is actually linking against my system Python (in this case the Python that came with cygwin--also Python 2.7.10). This is of course wrong, but isn't a problem for the majority of modules, including sage itself (at least it wasn't a problem for compiling). It was actually PIL(low) where this fell apart because it used some PyUnicode_ functions that were not found in my system libpython because it was compiled with --enable-unicode=ucs2, whereas Sage builds Python with --enable-unicode=ucs4.

When installing Python, Sage should be making a symlink to $(SAGE_LOCAL)/lib/python2.7/config/libpython2.7.dll.a in $(SAGE_LOCAL)/lib.

I'm leaning toward calling this an upstream bug--I don't understand why this isn't done automatically by Python's Makefile. The relevant portion begins here. It seems that if a DLL is built it does not install a symlink to the loader library in lib/. I've brought this up here: https://mail.python.org/pipermail/python-dev/2016-April/144315.html

For reference, Cygwin's own system package for Python installs this symlink manually... It seems odd not to do it by default.

Change History (17)

comment:1 Changed 5 years ago by embray

After applying the following patch, I rebuilt python2, and was subsequently able to build pillow:

  • build/pkgs/python2/spkg-install

    diff --git a/build/pkgs/python2/spkg-install b/build/pkgs/python2/spkg-install
    index db35674..b479ba3 100755
    a b fi 
    129129if [ "$UNAME" = "Darwin" ] && \
    130130    [ `uname -r | cut '-d.' -f1` -gt 9 ]; then
    131131    rm -f "$SAGE_LOCAL/lib/python2.7/config/libpython2.7.a"
     132elif [ "$UNAME" = "CYGWIN" ]; then
     133    # See http://trac.sagemath.org/ticket/20437
     134    ln -sf "python2.7/config/libpython2.7.dll.a" "$SAGE_LOCAL/lib/libpython2.7.dll.a"
    132135fi
    133136
    134137# Make sure extension modules were built correctly.

Should probably do the same for Python 3.

comment:2 Changed 5 years ago by embray

  • Branch set to u/embray/cygwin-python-install
  • Commit set to e45b2169db7f90927ee46b93729637a50ee67c50
  • Status changed from new to needs_review

Added a patch for python2 and python2. Basically the same as the above diff, but slightly enhanced to not use a hard-coded pythonX.Y version.


New commits:

e45b216Create symlinks in $SAGE_LOCAL/lib to $SAGE_LOCAL/lib/pythonX.Y/config/libpythonX.Y.dll.a. Also get Python version from python instead of hard-coding. Note: This is required on Cygwin in order for extension modules to link to the correct DLL import library for the python in sage. Cygwin itself does this in its system python package.

comment:3 Changed 5 years ago by tscrim

  • Cc tscrim gouezel jpflori added

comment:4 Changed 5 years ago by vdelecroix

Hi Eric,

only sided notes (as I am not a Cygwin guy):

  • in the ticket, you should always fill the "Authors" field (with your full name). The reason is that patchbots completely ignore tickets where it is not set.
  • in a commit it is standard to have one short line description, a linebreak and then an optional description. That way the history is much more readable (e.g. with git log --oneline).

comment:5 Changed 5 years ago by embray

Sounds reasonable.

comment:6 Changed 5 years ago by embray

  • Authors set to Erik Bray

Incidentally, is this documented somewhere? I don't see anything about this use of the "Authors" field under http://doc.sagemath.org/html/en/developer/trac.html#section-trac-fields or here: https://wiki.sagemath.org/buildbot. It would be nice if there were a single, easy to point to checklist for tickets--sort of a choose your own adventure story.

comment:7 Changed 5 years ago by git

  • Commit changed from e45b2169db7f90927ee46b93729637a50ee67c50 to 66ceeb2435bb4108ed3c4ecf3d0b81fa706fb1fd

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

66ceeb2On Cygwin: Create symlinks in $SAGE_LOCAL/lib to $SAGE_LOCAL/lib/pythonX.Y/config/libpythonX.Y.dll.a.

comment:8 Changed 5 years ago by embray

Build passed--any comments?

comment:9 follow-up: Changed 5 years ago by jdemeyer

  • Status changed from needs_review to needs_work

One detail: you should quote $SAGE_LOCAL/bin/python as "$SAGE_LOCAL/bin/python" in case of funny characters in $SAGE_LOCAL.

Did you report this upstream? The "report upstream" field says "Not yet reported upstream; Will do shortly."

comment:10 in reply to: ↑ 9 Changed 5 years ago by embray

Replying to jdemeyer:

One detail: you should quote $SAGE_LOCAL/bin/python as "$SAGE_LOCAL/bin/python" in case of funny characters in $SAGE_LOCAL.

Sure.

Did you report this upstream? The "report upstream" field says "Not yet reported upstream; Will do shortly."

I'll do that now.

comment:11 Changed 5 years ago by git

  • Commit changed from 66ceeb2435bb4108ed3c4ecf3d0b81fa706fb1fd to 71062f01ef52e723f780044ffd08b4f46520bd75

Branch pushed to git repo; I updated commit sha1. New commits:

71062f0Adding quotes around python call in case of funny business in SAGE_LOCAL.

comment:12 Changed 5 years ago by embray

  • Description modified (diff)
  • Report Upstream changed from Not yet reported upstream; Will do shortly. to Reported upstream. No feedback yet.
  • Status changed from needs_work to needs_review

comment:13 Changed 5 years ago by gouezel

Works for me. You can set if to positive review in a few days, if there is no answer from upstream.

comment:14 Changed 5 years ago by embray

No response from python-dev yet. I only asked on the mailing list though--might get more response if I opened a bug report instead. I was just being polite and not assuming it was definitely a bug :)

It's only Monday though, and early yet in the Americas so I'll wait a little longer.

comment:15 Changed 5 years ago by embray

I opened a bug report about this in Python, and included a patch: http://bugs.python.org/issue27374 as this is more likely to at least be acknowledged than my original mailing list post.

I wouldn't be surprised if this isn't acted on, or even if it is it won't be of any immediately help. So it would be nice to go ahead and get this merged, given a positive review.

comment:16 Changed 5 years ago by gouezel

  • Reviewers set to Sebastien Gouezel
  • Status changed from needs_review to positive_review

comment:17 Changed 5 years ago by vbraun

  • Branch changed from u/embray/cygwin-python-install to 71062f01ef52e723f780044ffd08b4f46520bd75
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.