Re: convert-ly, musicxml2ly, etc. problems

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: convert-ly, musicxml2ly, etc. problems

Han-Wen Nienhuys-2
Bertalan Fodor escreveu:

> Well, that doesn't work in 2.10.0-2, and (according to Rick) in 2.11.x
>
> Because with that you get the message:
>
> C:\Program Files\LilyPond\usr\bin>python -v convert-ly -h
> # installing zipimport hook
> import zipimport # builtin
> # installed zipimport hook
> 'import site' failed; traceback:
> ImportError: No module named site
> Python 2.5 (r25:51908, Nov 15 2006, 17:33:18)
> [GCC 4.1.1] on mingw32
> Type "help", "copyright", "credits" or "license" for more information.
> Traceback (most recent call last):
>  File "convert-ly", line 13, in <module>
>    import os
> ImportError: No module named os

ah, the culprit is the upgrade to python 2.5

Strangely enough, this does work under Wine.

# C:\Program Files/LilyPond/usr\lib/python2.5\site.pyc matches C:\Program Files/LilyPond/usr\lib/python2.5\site.py
import site # precompiled from C:\Program Files/LilyPond/usr\lib/python2.5\site.pyc
# C:\Program Files/LilyPond/usr\lib/python2.5\os.pyc matches C:\Program Files/LilyPond/usr\lib/python2.5\os.py
import os # precompiled from C:\Program Files/LilyPond/usr\lib/python2.5\os.pyc
import nt # builtin



Jan,

do you know how Python 2.4/mingw found out where to locate its modules?


--

Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen

LilyPond Software Design
 -- Code for Music Notation
http://www.lilypond-design.com



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: convert-ly, musicxml2ly, etc. problems

Jan Nieuwenhuizen-2
Han-Wen Nienhuys <[hidden email]> writes:

> Jan,
>
> do you know how Python 2.4/mingw found out where to locate its modules?

The path is set through argv0 relocation, but I had to patch
calculate_path in Modules/getpath.c, see below.  I haven't checked if
this is the new patch bomb, or what changed in python 2.5.

Jan.


@@ -384,13 +407,23 @@ calculate_path(void)
     unsigned long nsexeclength = MAXPATHLEN;
 #endif
 
- /* If there is no slash in the argv0 path, then we have to
- * assume python is on the user's $PATH, since there's no
- * other way to find a directory to start the search from.  If
- * $PATH isn't exported, you lose.
- */
- if (strchr(prog, SEP))
- strncpy(progpath, prog, MAXPATHLEN);
+    /* If PROG is an absolute name, then we're done.  If PROG is not
+     * an absolute name and contains SEP/ALTSEP, then it must be
+     * reachable from CWD.  Otherwise, python is on the user's $PATH,
+     * since there's no other way to find a directory to start the
+     * search from.  If $PATH isn't exported, you lose.
+     */
+    if (IS_ABSOLUTE(prog))
+     strncpy(progpath, prog, MAXPATHLEN);
+    else if (strchr(prog, SEP)
+#ifdef ALTSEP
+     || strchr(prog, ALTSEP)
+#endif /* ALTSEP */
+     )
+      {
+     getcwd(progpath, MAXPATHLEN);
+ joinpath(progpath, prog);
+      }
 #ifdef __APPLE__
      /* On Mac OS X, if a script uses an interpreter of the form
       * "#!/opt/python2.3/bin/python", the kernel only passes "python"
@@ -406,6 +439,9 @@ calculate_path(void)
        ;
 #endif /* __APPLE__ */
  else if (path) {
+#ifdef __MINGW32__
+ char const *ext = strchr(prog, '.') ? "" : ".exe";
+#endif
  while (1) {
  char *delim = strchr(path, DELIM);
 
@@ -420,9 +456,11 @@ calculate_path(void)
  strncpy(progpath, path, MAXPATHLEN);
 
  joinpath(progpath, prog);
+#ifdef __MINGW32__
+ strcat(progpath, ext);
+#endif
  if (isxfile(progpath))
  break;
-
  if (!delim) {
  progpath[0] = '\0';
  break;
@@ -432,7 +470,7 @@ calculate_path(void)
  }
  else
  progpath[0] = '\0';
- if (progpath[0] != SEP)
+ if (!IS_ABSOLUTE(progpath))
  absolutize(progpath);
  strncpy(argv0_path, progpath, MAXPATHLEN);
  argv0_path[MAXPATHLEN] = '\0';
@@ -478,7 +516,7 @@ calculate_path(void)
         while (linklen != -1) {
             /* It's not null terminated! */
             tmpbuffer[linklen] = '\0';
-            if (tmpbuffer[0] == SEP)
+            if (IS_ABSOLUTE(tmpbuffer))
                 /* tmpbuffer should never be longer than MAXPATHLEN,
                    but extra check does not hurt */
                 strncpy(argv0_path, tmpbuffer, MAXPATHLEN);
@@ -545,7 +583,7 @@ calculate_path(void)
     while (1) {
         char *delim = strchr(defpath, DELIM);
 
-        if (defpath[0] != SEP)
+        if (!IS_ABSOLUTE(defpath))
             /* Paths are relative to prefix */
             bufsz += prefixsz;
 
@@ -590,7 +628,7 @@ calculate_path(void)
         while (1) {
             char *delim = strchr(defpath, DELIM);
 
-            if (defpath[0] != SEP) {
+            if (!IS_ABSOLUTE(defpath)) {
                 strcat(buf, prefix);
                 strcat(buf, separator);
             }

--
Jan Nieuwenhuizen <[hidden email]> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien       | http://www.lilypond.org


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel