Create a binary for my lua scripts

979 views
Skip to first unread message

Arjun Jain

unread,
Oct 9, 2014, 8:35:18 AM10/9/14
to torch7 on behalf of Afroze Ibrahim
Hi all,

I am in a position where I want a 3d party to be able to use my
lua/torch api's (along with some custom torch lua only modules),
however I do not want to give him access to my source code. What is my
best option?

Thanks in advance for your help.

Best,
Arjun

smth chntla

unread,
Oct 9, 2014, 9:33:00 AM10/9/14
to tor...@googlegroups.com
Arjun,

I wrote a small page here:
https://github.com/soumith/torch-ship-binaries
This slightly changes if you want android/iOS binaries, but this works for Linux or OSX.

Let me paste the contents here for visibility:

1) Create a self-contained torch install:

git clone https://github.com/soumith/torch-distro.git
cd torch-distro
install.sh

(you can add and remove packages from install.sh, i've added what I usually need all the time).

2) Convert your lua scripts into bytecode:

luajit -b [script.lua] [script.out]

More doc here: http://luajit.org/running.html

3) Place the byte-code scripts in torch-distro/myscripts

4) Create a shell script in the root of torch-distro that sets the proper environment for your end-user, and passes the commandline options into your main lua script: torch-distro/run.sh

#!/bin/bash
currdir=`dirname $0`
currdir=$(cd "$currdir" && pwd)
export PATH=$currdir/install/bin/$PATH
export LD_LIBRARY_PATH=$currdir/install/lib/$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$currdir/install/lib/$DYLD_LIBRARY_PATH
$currdir/install/bin/luajit myscripts/main.lua $*

5) Zip it and ship it, ask your thirdparty to unzip and start the program with "run.sh" All the commandline options will be passed to the entry lua script, so you can have command-line options using torch.CmdLine or penlight etc.

soumith

unread,
Oct 9, 2014, 9:36:42 AM10/9/14
to torch7 on behalf of smth chntla
fixed some typos at the original URL.

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at http://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Jonathan Tompson

unread,
Oct 9, 2014, 9:36:58 AM10/9/14
to torch7 on behalf of smth chntla
Wow buddy! You have a package for everything. This I s awesome!

One question though... do you have a package to make me breakfast in the morning? Or is that not open source yet?

Sent from my iPhone. Expect mistakes.
--

Arjun Jain

unread,
Oct 9, 2014, 9:41:56 AM10/9/14
to torch7 on behalf of smth chntla
Wow! This is perfect, thank you very much Soumith! Exactly what I
want. You are the best! :-)

On Thu, Oct 9, 2014 at 9:33 AM, smth chntla via torch7
<torch7+noreply-APn2wQfnkJPt8vpT4...@googlegroups.com>
wrote:
Reply all
Reply to author
Forward
0 new messages