adtools / amigaos-cross-toolchain

AmigaOS cross compiler for Linux / MacOSX / Windows
184 stars 48 forks source link

fix issues running on 64 bit hosts: #40

Closed sezero closed 8 years ago

sezero commented 8 years ago
cahirwpz commented 8 years ago

Please test last commit on Fedora system. All host tools including python-lha and texinfo are built with default compiler options (i.e. -m64 on 64-bit architecture).

sezero commented 8 years ago
INFO: extract files from ".build-m68k/archives/vclib.lha"

Traceback (most recent call last):
  File "./toolchain-m68k", line 704, in <module>
    globals()[action].__call__(*args.args)
  File "./toolchain-m68k", line 325, in build
    unpack('vclib', top_dir='vbcc_target_m68k-amigaos')
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 37, in wrapper
    return fn(*args, **kwargs)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 349, in wrapper
    fn(*args, **kwargs)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 409, in unpack
    unarc(src)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 37, in wrapper
    return fn(*args, **kwargs)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 269, in unarc
    import lhafile
ImportError: No module named lhafile
sezero commented 8 years ago

Building python-lha with default compiler options is not enough, because it doesn't solve the sitedir issue I mentioned in the original post.

cahirwpz commented 8 years ago

Ok. Is there any method to extract correct site_dir from python installation? I'd like to have only one simple add_site_dir function.

sezero commented 8 years ago

Is there any method to extract correct site_dir from python installation?

That I don't know.

cahirwpz commented 8 years ago

Following code prints /lib/python2.7/site-packages and /lib/site-python on MacOSX. The first answer is what I prepare manually in add_site_dir. I could extract it from there provided that on your machine the answer is correct.

import site

for prefix, path in zip(site.PREFIXES, site.getsitepackages()):
    print path[len(prefix):]
sezero commented 8 years ago

The thing is, you are manually joining the path with 'lib' already: what you are missing is 'lib64' where some (many) distros use.

sezero commented 8 years ago

On my fedora20-x86_64, your code prints:

$ python chk.py
/lib64/python2.7/site-packages
/lib/python2.7/site-packages
cahirwpz commented 8 years ago

Could you try out following patch?

diff --git a/common.py b/common.py
index 9474d9a..9d11d9c 100644
--- a/common.py
+++ b/common.py
@@ -292,10 +292,9 @@ def unarc(name):

 @fill_in_args
 def add_site_dir(dirname):
-  dirname = path.join(dirname, 'lib', 'python%d.%d' % sys.version_info[:2],
-                      'site-packages')
-  info('adding "%s" to python site dirs', topdir(dirname))
-  site.addsitedir(dirname)
+  sitedir = path.join(dirname, site.USER_SITE[len(site.USER_BASE) + 1:])
+  info('adding "%s" to python site dirs', topdir(sitedir))
+  site.addsitedir(sitedir)

 @contextlib.contextmanager
sezero commented 8 years ago

Got the same error as before:

INFO: extract files from ".build-m68k/archives/vclib.lha"

Traceback (most recent call last):
  File "./toolchain-m68k", line 721, in <module>
    globals()[action].__call__(*args.args)
  File "./toolchain-m68k", line 340, in build
    unpack('vclib', top_dir='vbcc_target_m68k-amigaos')
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 37, in wrapper
    return fn(*args, **kwargs)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 348, in wrapper
    fn(*args, **kwargs)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 408, in unpack
    unarc(src)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 37, in wrapper
    return fn(*args, **kwargs)
  File "/home/ozzie/Download/amigaos-cross-toolchain/common.py", line 269, in unarc
    import lhafile
ImportError: No module named lhafile
cahirwpz commented 8 years ago

The error message is irrelevant now - I know how the crash looks like ;-)

Please tell me what was printed out by 'adding "%s" to python site dirs' and why it's wrong.

sezero commented 8 years ago

INFO: adding ".build-m68k/host/lib/python2.7/site-packages" to python site dirs

cahirwpz commented 8 years ago

I must admit I'm deeply confused. Your Python interpreter tells that it expects user packages to be installed into $SITEDIR/lib/python2.7/site-packages, but later it seeks a package in $SITEDIR/lib64/python2.7/site-packages. What the heck?

Can you run following commands:

python2.7 -m site --user-site
sezero commented 8 years ago

It prints /home/ozzie/.local/lib/python2.7/site-packages

I thought that you used the code you referred above https://github.com/cahirwpz/amigaos-cross-toolchain/pull/40#issuecomment-250905566

cahirwpz commented 8 years ago

No, I did not, because it was not reliable under MacOSX. So far https://github.com/cahirwpz/amigaos-cross-toolchain/pull/40#issuecomment-250913815 was the only reliable method under Debian i686 / x86_64, MacOSX and Cygwin i686.

What system do you run uname -a? Is it kept up to date?

sezero commented 8 years ago

What system do you run uname -a?

$ uname -a
Linux localhost.localdomain 3.19.8-100.fc20.x86_64 #1 SMP Tue May 12 17:08:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Is it kept up to date?

As up-to-date as it can be. F20 has been EOL for some time. but I really don't think that it can affect anything relevant here.

(BTW, am I really the only one with an x86_64 fedora/redhat system here?)

cahirwpz commented 8 years ago

Well, Fedora ain't that popular according to distrowatch ;-)

What about this script, does it print lib64/python2.7/site-packages ?

#!/usr/bin/python2.7

import distutils.sysconfig
import os.path

prefix = distutils.sysconfig.EXEC_PREFIX
destlib = distutils.sysconfig.get_config_var('DESTLIB')
print os.path.join(destlib[len(prefix) + 1:], 'site-packages')
sezero commented 8 years ago

It prints lib64/python2.7/site-packages

cahirwpz commented 8 years ago

Try out following patch:

diff --git a/common.py b/common.py
index 740b1ca..fc3ab84 100644
--- a/common.py
+++ b/common.py
@@ -5,7 +5,7 @@ from glob import glob
 from logging import debug, info, error
 from os import path
 import contextlib
-import distutils.spawn
+from distutils import spawn, sysconfig
 import os
 import shutil
 import site
@@ -101,7 +101,7 @@ def topdir(name):

 @fill_in_args
 def find_executable(name):
-  return (distutils.spawn.find_executable(name) or
+  return (spawn.find_executable(name) or
           panic('Executable "%s" not found!', name))

@@ -292,8 +292,9 @@ def unarc(name):

 @fill_in_args
 def add_site_dir(dirname):
-  dirname = path.join(dirname, 'lib', 'python%d.%d' % sys.version_info[:2],
-                      'site-packages')
+  prefix = sysconfig.EXEC_PREFIX
+  destlib = sysconfig.get_config_var('DESTLIB')
+  dirname = path.join(dirname, destlib[len(prefix) + 1:], 'site-packages')
   info('adding "%s" to python site dirs', topdir(dirname))
   site.addsitedir(dirname)
sezero commented 8 years ago

The patch works, i.e. python-lha is found and lha extraction as no issues.

One irrelevant issue:

DEBUG: enter directory ".build-m68k/build/libdebug"
DEBUG: execute "make"
cd /home/ozzie/Download/amigaos-cross-toolchain/submodules/libdebug && autoconf
autoconf: configure.in: No such file or directory
make: *** [/home/ozzie/Download/amigaos-cross-toolchain/submodules/libdebug/configure] Error 1
ERROR: command "make" failed with 2
cahirwpz commented 8 years ago

I cannot reproduce this issue. Please start the build from scratch with the most recent version of toolchain-m68k script.

sezero commented 8 years ago

Started everything from scratch, can't reproduce myself, either. Huh..

sezero commented 8 years ago

With commit 31a6c508 the sitedir issue seems fixed, so this can be closed I think.