bug in os.py

52 views
Skip to first unread message

Rajeev Singh

unread,
Apr 19, 2012, 7:49:11 AM4/19/12
to sage-...@googlegroups.com
Hi,

I get the following error while trying to install git from
sage-optional packages. The error seems to be in one of the python
library files (os.py) and is a syntax error -

File "/compute/imsc9/rajeev/bin/sage-4.8/local/lib/python/os.py", line 758
bs = b""
^
SyntaxError: invalid syntax

I think this is a bug?

Rajeev

Simon King

unread,
Apr 19, 2012, 1:29:21 PM4/19/12
to sage-...@googlegroups.com

I can not reproduce the problem. I was just installing the git spkg without any
problems, with sage-5.0.prealpha0. What exactly did you do when (and
before) the problem arose?

Cheers,
Simon

Volker Braun

unread,
Apr 19, 2012, 2:18:00 PM4/19/12
to sage-...@googlegroups.com
The b"" is a string with the Python 3 byte-prefix. In Python 2, version 2.6+ this is a noop for Python 3 compatibility. In Python versions older than 2.6, this is an error. 

Conclusion: You are running an old Python interpreter, in particular not the one that is part of Sage. Hence it breaks.

Rajeev Singh

unread,
Apr 19, 2012, 11:25:15 PM4/19/12
to sage-...@googlegroups.com
I don't think that should happen because I'm just giving the following
command on terminal -

sage -i git-1.7.9.4

I am using sage-4.8. I get the same error on two computers (one
running SuseLinux and another running Debian).

Rajeev

> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to
> sage-devel+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org

John H Palmieri

unread,
Apr 20, 2012, 12:23:20 AM4/20/12
to sage-...@googlegroups.com


On Thursday, April 19, 2012 8:25:15 PM UTC-7, Rajeev wrote:
I don't think that should happen because I'm just giving the following
command on terminal -

sage -i git-1.7.9.4

I am using sage-4.8. I get the same error on two computers (one
running SuseLinux and another running Debian).

I see the same error when running "sage -i git" on sage.math.washington.edu (using sage-5.0.beta13). There are also suspicious looking warnings like

  /scratch/palmieri/sage-5.0.beta13/local/lib/python/linecache.py:127: Warning: 'with' will become a reserved keyword in Python 2.6

So is the installation somehow using the system's Python (which is version 2.5.2) rather than Sage's? Anyway, if the spkg doesn't install correctly on sage.math, something is seriously wrong with the spkg.

By the way, I see a different error when running "sage -i git" on OS X Lion:

    AR libgit.a
/usr/bin/ranlib: file: libgit.a(gettext.o) has no symbols
    LINK git-daemon
    LINK git-fast-import
ld: warning: ignoring file /opt/local/lib/libz.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: ignoring file /sw/lib/libiconv.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: ignoring file /opt/local/lib/libcrypto.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
  "_SHA1_Init", referenced from:
      _store_object in fast-import.o
      _stream_blob in fast-import.o
      _sha1fd_throughput in libgit.a(csum-file.o)
      _write_sha1_file_prepare in libgit.a(sha1_file.o)
      _write_loose_object in libgit.a(sha1_file.o)
      _read_index_from in libgit.a(read-cache.o)
      _write_index in libgit.a(read-cache.o)
      ...

and then it goes on like that for a while.

--
John

leif

unread,
Apr 20, 2012, 12:23:47 AM4/20/12
to sage-devel
On 20 Apr., 05:25, Rajeev Singh <rajs2...@gmail.com> wrote:
> I don't think that should happen because I'm just giving the following
> command on terminal -
>
> sage -i git-1.7.9.4
>
> I am using sage-4.8. I get the same error on two computers (one
> running SuseLinux and another running Debian).

What does

$ sage --python --version

give?


-leif

John H Palmieri

unread,
Apr 20, 2012, 12:27:24 AM4/20/12
to sage-...@googlegroups.com
For me, as expected:

$ sage --python --version
Python 2.7.2

--
John

leif

unread,
Apr 20, 2012, 12:31:04 AM4/20/12
to sage-devel


On 20 Apr., 06:23, leif <not.rea...@online.de> wrote:
> On 20 Apr., 05:25, Rajeev Singh <rajs2...@gmail.com> wrote:
>
> > I don't think that should happen because I'm just giving the following
> > command on terminal -
>
> > sage -i git-1.7.9.4

P.S.: You should try the git-1.7.9.4.p1.spkg


-leif

leif

unread,
Apr 20, 2012, 12:35:07 AM4/20/12
to sage-devel
;-) That's certainly not Sage 4.8 ...


-leif

Keshav Kini

unread,
Apr 20, 2012, 12:36:52 AM4/20/12
to sage-...@googlegroups.com

Keshav Kini

unread,
Apr 20, 2012, 12:47:45 AM4/20/12
to sage-...@googlegroups.com
Hmm...

keshav@sage ~ $ mkdir bin
keshav@sage ~ $ cat - > bin/python
#!/bin/sh
echo "You are likely to be eaten by a grue"
keshav@sage ~ $ chmod a+x bin/python
keshav@sage ~ $ export PATH="/home/keshav/bin:$PATH"
keshav@sage ~ $ ./sage/sage -i ./git-1.7.9.4.p1.spkg | grep grue
keshav@sage ~ $

So as far as I can see the only way it could be calling the system python would be if something in git has a hashbang hard-coded to /usr/bin/python or something. But all these look in order...

keshav@sage ~ $ tar xf git-1.7.9.4.p1.spkg
keshav@sage ~ $ grep -r '^#!.*python' git-1.7.9.4.p1
git-1.7.9.4.p1/src/contrib/p4import/git-p4import.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/contrib/fast-import/git-p4:#!/usr/bin/env python
git-1.7.9.4.p1/src/contrib/fast-import/import-zips.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/contrib/gitview/gitview:#! /usr/bin/env python
git-1.7.9.4.p1/src/contrib/ciabot/ciabot.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/contrib/hg-to-git/hg-to-git.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/git_remote_helpers/__init__.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/git_remote_helpers/util.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/git_remote_helpers/git/git.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/git_remote_helpers/setup.py:#!/usr/bin/env python
git-1.7.9.4.p1/src/git-remote-testgit.py:#!/usr/bin/env python

Any ideas?

-Keshav

----
Join us in #sagemath on irc.freenode.net !

leif

unread,
Apr 20, 2012, 12:48:39 AM4/20/12
to sage-devel
FWIW:

...
Successfully installed git-1.7.9.4
Now cleaning up tmp files.
Making Sage/Python scripts relocatable...
Finished installing git-1.7.9.4.spkg

real 2m56.141s
user 3m57.170s
sys 0m31.020s
$ ./sage --version
Sage Version 4.8, Release Date: 2012-01-20
$ ./sage --python --version
Python 2.6.4

(Ubuntu 10.04.4 LTS)

Also works for me if I do './sage -i git' (which first downloads the
spkg; IMHO the only point where Python is used at all).


-leif

Keshav Kini

unread,
Apr 20, 2012, 12:49:34 AM4/20/12
to sage-...@googlegroups.com
Uh... I'm not sure why Google Groups just quoted John's message five times, but sorry about that...

-Keshav

leif

unread,
Apr 20, 2012, 1:01:11 AM4/20/12
to sage-devel
On 20 Apr., 06:49, Keshav Kini <keshav.k...@gmail.com> wrote:
> Uh... I'm not sure why Google Groups just quoted John's message five times,
> but sorry about that...


In this case not that bad, as I completely missed his original post.
>8)

I'm pretty sure Google swallowed it for me in the first place (old web
interface); now I see it.


-leif

Keshav Kini

unread,
Apr 20, 2012, 1:04:59 AM4/20/12
to sage-...@googlegroups.com
D'oh:

keshav@sage ~ $ grep -r '/python' git-1.7.9.4.p1
git-1.7.9.4.p1/src/Makefile:    PYTHON_PATH = /usr/bin/python
git-1.7.9.4.p1/src/Makefile:    PYTHON_PATH = /usr/local/bin/python
git-1.7.9.4.p1/src/git_remote_helpers/Makefile:        PYTHON_PATH = /usr/local/bin/python
git-1.7.9.4.p1/src/git_remote_helpers/Makefile:        PYTHON_PATH = /usr/bin/python
git-1.7.9.4.p1/src/git_remote_helpers/Makefile:     print 'lib/python%i.%i/site-packages' % sys.version_info[:2]")

So we'll need to patch the makefile, I guess. Let's pile this onto #12707...

-Keshav

Keshav Kini

unread,
Apr 20, 2012, 1:06:37 AM4/20/12
to sage-...@googlegroups.com
Er, not patch the makefile, but actually just exporting some environment variables should be sufficient.

-Keshav

leif

unread,
Apr 20, 2012, 1:16:41 AM4/20/12
to sage-devel
I actually do have

/usr/bin/python setup.py install --prefix /data/leif/Sage/sage-4.8/
local

in the spkg log...


-leif

Keshav Kini

unread,
Apr 20, 2012, 2:40:41 AM4/20/12
to sage-...@googlegroups.com

OK, a new SPKG is up in my homedir on boxen. Once ticket #12707 is
accepted, the SPKG will be on the official server, and one should be
able to install it with `sage -i git`, but for now, please test with

$ cd /tmp
$ wget http://boxen.math.washington.edu/home/keshav/files/git-1.7.10.spkg
$ sage -f git-1.7.10.spkg
$ rm git-1.7.10.spkg

Thanks for spotting this bug! To summarize the rest of the posts in this
thread, the problem was that we needed to tell git's configure script
explicitly to use Sage's Python, rather than relying on the PATH
environment variable to convey that desire. John also discovered a
problem with installing on OS X with certain other software installed
(Fink or Darwin Ports), which has also been fixed.

leif

unread,
Apr 20, 2012, 11:04:55 AM4/20/12
to sage-devel
On 20 Apr., 08:40, Keshav Kini <keshav.k...@gmail.com> wrote:
> $ cd /tmp
> $ wget http://boxen.math.washington.edu/home/keshav/files/git-1.7.10.spkg
> $ sage -f git-1.7.10.spkg
> $ rm git-1.7.10.spkg

You mean

$ ./sage -f http://boxen.math.washington.edu/home/keshav/files/git-1.7.10.spkg

? ;-)


-leif

Keshav Kini

unread,
Apr 20, 2012, 11:10:00 AM4/20/12
to sage-...@googlegroups.com

What, that actually works? I could have sworn it didn't... cool!

Jeroen Demeyer

unread,
Apr 20, 2012, 11:17:42 AM4/20/12
to sage-...@googlegroups.com
On 2012-04-20 17:10, Keshav Kini wrote:
> What, that actually works? I could have sworn it didn't... cool!
It works if Sage is completely installed, not if you just downloaded the
source tarball (although it wouldn't be too hard to support curl or wget
if Sage isn't yet installed).

leif

unread,
Apr 20, 2012, 11:26:53 AM4/20/12
to sage-devel
AFAIK it just needs [some] Python and sage_scripts, but I may be
wrong...


-leif

leif

unread,
Apr 22, 2012, 2:09:52 AM4/22/12
to sage-devel
On 20 Apr., 06:49, Keshav Kini <keshav.k...@gmail.com> wrote:
> Uh... I'm not sure why Google Groups just quoted John's message five times,
> but sorry about that...

Must have been some joke by a google operator, which gets apparent if
you read the sage-devel digest:

===========================================================
...

Any ideas?

-Keshav

----
Join us in #sagemath on irc.freenode.net !

On Friday, April 20, 2012 12:23:20 PM UTC+8, John H Palmieri wrote:

> and then it goes on like that for a while.

> --
> John

On Friday, April 20, 2012 12:23:20 PM UTC+8, John H Palmieri wrote:

> and then it goes on like that for a while.

> --
> John

On Friday, April 20, 2012 12:23:20 PM UTC+8, John H Palmieri wrote:

> and then it goes on like that for a while.

> --
> John

On Friday, April 20, 2012 12:23:20 PM UTC+8, John H Palmieri wrote:

> and then it goes on like that for a while.

> --
> John

On Friday, April 20, 2012 12:23:20 PM UTC+8, John H Palmieri wrote:

====================================================

>8D

-leif
Reply all
Reply to author
Forward
0 new messages