Closed trungnq97 closed 5 years ago
You’re using Python 3. Print needs to be used as a function ... I.e. print(i)
XAR has set the interpreter from your ‘—python-interpreter python3’ ... change that if you want Python 2.
This is not a XAR bug.
I thought so too. But I tried print
with no (...)
together with python2, I still saw the same error.
Bellow, I used python3 with print(...)
.
trung@trung-VirtualBox:~/workspace$ cat hellopy/hello2.py
#!/usr/bin/env python3
print("Hello")
trung@trung-VirtualBox:~/workspace$ make_xar --python-interpreter python3 --raw hellopy --raw-executable hello2.py --output hello2
2018-08-20 22:40:19,938 INFO Squashing /tmp/tmpwm0plvgs to /tmp/tmp4ikf54ol
Parallel mksquashfs: Using 2 processors
Creating 4.0 filesystem on /tmp/tmprxz_gpvc, block size 262144.
[===================================================================================================================|] 2/2 100%
Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 262144
compressed data, uncompressed metadata, compressed fragments, uncompressed xattrs
duplicates are removed
Filesystem size 0.38 Kbytes (0.00 Mbytes)
98.99% of uncompressed filesystem size (0.39 Kbytes)
Inode table size 98 bytes (0.10 Kbytes)
100.00% of uncompressed inode table size (98 bytes)
Directory table size 47 bytes (0.05 Kbytes)
100.00% of uncompressed directory table size (47 bytes)
Number of duplicate files found 0
Number of inodes 3
Number of files 2
Number of fragments 1
Number of symbolic links 0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 1
Number of ids (unique uids + gids) 1
Number of uids 1
nobody (65534)
Number of gids 1
nogroup (65534)
trung@trung-VirtualBox:~/workspace$ ./hello2
/dev/shm/uid-1000/a2a85f6e-ns-4026531840/hello2.py: 2: /dev/shm/uid-1000/a2a85f6e-ns-4026531840/hello2.py: Syntax error: word unexpected (expecting ")")
You are building a raw XAR, when you should be building a Python XAR. You can build a Python XAR using this command:
make_xar --python hellopy --python-interpreter python3 --python-entry-point hello2 --output hello2
The raw
XAR is for building a XAR with a custom bootstrapping script (and doesn't respect any --python-*
flags). It requires a shell script as the executable. This minimal bootstrapping script, taken from bootstrap_py.py, should work.
#!/bin/sh
# Name: __bootstrap__.sh
BOOTSTRAP_PATH="$0"
DIR=$(dirname "$BOOTSTRAP_PATH")
shift
python3 "$DIR/hello2.py" "$@"
make_xar --raw hellopy --raw-executable __bootstrap__.sh --output hello
I'll leave this issue open for improving the make_xar
CLI documentation and argument verification.
Thanks @terrelln . It works. A quick question, it seems that I have to build xarexec_fuse
in the destination host that I want to run xar on?
@trungnq97 - Yes, that is what mounts and runs the squashfs image.
Hi all,
I've received the error below when executing a xar executable file:
Executable python script
Build xar
Any hint is welcome.
OS: Ubuntu 16.04 LTS