The Package Manager for Lua
Total Page:16
File Type:pdf, Size:1020Kb
the package manager for Lua Hisham Muhammad @hisham_hm http://hisham.hm LuaConf 2016 Rio de Janeiro Lua# a pecu$iar language %uper $ight&eight 'esigned for em(edding in applications ).tar.gz is 272,i(- Minima$istic ./0 12atteries not inc$uded3 1Ho& do I ___ in Lua43 Modu$es to the rescue! 6hat is LuaRocks /ackage manager... $ike dpkg (apt-# !/M (7um-# Ru(78ems, npm# etc. ...for Lua e9tension modu$es... &ritten in Lua (.lua :$es- or binar7 modu$es (.so/.d$$ :$es- ...that $ets 7ou 1add features3 to Lua net&orking# database# graphics, etc etc etc. The LuaRocks pro<ect .n internationa$ communit7 http://luarocks.org Site for :nding and up$oading rocks http://github.com/keplerpro<ect/luarocks 'e=elopment of the luarocks command-line too$ http://githu(.com/$eafo/luarocks-site 'e=elopment of the site ;he LuaRocks.org module ecos7stem 1200 1000 800 600 400 200 0 'Sep 2009 'Mar 2010 'Sep 2010 'Mar 2011 'Sep 2011 'Mar 2012 'Sep 2012 'Mar 2013 'Sep 2013 'Mar 2014 'Sep 2014 'Feb 2015 'Sep 2015 'Mar 2016 'Jul 2016 App$ication programming in Lua Lua is not on$7 a $anguage for scripting /erfect$7 capable for application programming 0ts &e$$ designed C ./0 makes it a great e9tensi($e $anguage %o it>s an e9cel$ent language to form a modu$e ecos7stem around App$ication programming in Lua is a reality %e=era$ Lua (ased pro<ects out there %er=er-side too$s# games, etc. Lo& $e=el code comes from e9isting libraries 6hat 0 mean (7 Lua (ased 2ui$t on top of the Lua interpreter ?r on top of frame&orks like Lo=e2'# ?pen!est7# ;orch that give 7ou a pre-enhanced Lua environment Lots of opportunit7 for code reuse . practical e9amp$e In a recent project de=e$oped at LabLua# &e $e=eraged these rocks: for these tasks: 9a=ante H;;P server dkjson "%ON parsing lua reAuests H;;/ c$ient lua schema ;a(le Ba$idation luafiles7stem Dilesystem operations luaposi9 Unix faci$ities serpent %eria$ization copas Coroutine schedu$ing lanes ;hreading lualogging Extensi(le logging )plus 8 other indirect dependencies) Pla7s nice with =arious ecos7stems ;orch uses Lua!ocks https://github.com/torch/rocks Lo=e2' G Lua!ocks H Lo=e!ocks https://github.com/.$lo7ed/$o=erocks ;arantoo$ data(ase Fses Lua!ocks as its package manager ?pen!est7 Lots of OpenResty modules in luarocks.org Pla7s nice with =arious ecos7stems Lua!ocks supports diIerent (ui$d s7stem (ackends Its o&n (ui$t-in (uild system# Make# CMake... Lua!ocks.org supports mu$tip$e repositories https://$uarocks.org/m/tarantoo$ for ;arantoo$ 2ring 7our ecosystem o=er# users &i$l (enefit5 Fp and running in one slide5 ~$ wget http://lua.org/ftp/lua-5.3.3.tar.gz ~$ tar zxpf lua-5.3.3.tar.gz ~$ cd lua-5.3.3 ~$ make linux; sudo make install; cd .. ~$ wget http://luarocks.org/releases/luarocks-2.3.0.tar.gz ~$ tar zxpf luarocks-2.3.0.tar.gz ~$ cd luarocks-2.3.0 ~$ ./configure; sudo make bootstrap; cd .. ~$ sudo luarocks install luasocket ~$ lua Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > require "socket" Fp and running in one slide5 ~$ wget http://lua.org/ftp/lua-5.3.3.tar.gz ~$ tar zxpf lua-5.3.3.tar.gz ~$ cd lua-5.3.3 ~$ make linux; sudo make install; cd .. ~$ wget http://luarocks.org/releases/luarocks-2.3.0.tar.gz ~$ tar zxpf luarocks-2.3.0.tar.gz ~$ cd luarocks-2.3.0 ~$ ./configure; sudo make bootstrap; cd .. ~$ sudo luarocks install luasocket ~$ lua Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > require "socket" Fp and running in one slide5 ~$ wget http://lua.org/ftp/lua-5.3.3.tar.gz ~$ tar zxpf lua-5.3.3.tar.gz ~$ cd lua-5.3.3 ~$ make linux; sudo make install; cd .. ~$ wget http://luarocks.org/releases/luarocks-2.3.0.tar.gz ~$ tar zxpf luarocks-2.3.0.tar.gz ~$ cd luarocks-2.3.0 ~$ ./configure; sudo make bootstrap; cd .. ~$ sudo luarocks install luasocket ~$ lua Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > require "socket" Fp and running in one slide5 ~$ wget http://lua.org/ftp/lua-5.3.3.tar.gz ~$ tar zxpf lua-5.3.3.tar.gz ~$ cd lua-5.3.3 ~$ make linux; sudo make install; cd .. ~$ wget http://luarocks.org/releases/luarocks-2.3.0.tar.gz ~$ tar zxpf luarocks-2.3.0.tar.gz ~$ cd luarocks-2.3.0 ~$ ./configure; sudo make bootstrap; cd .. ~$ sudo luarocks install luasocket ~$ lua Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > require "socket" or# simp$7... ?n Dedora# for e9amp$e... ~$ yum install lua ~$ yum install luarocks F(untu packages are outdated5 P$ease insta$$ manua$$7 as e9plained in the previous slide ?n Mac ?% J &ith Home(re&... ~$ brew install lua )0n Homebre&# the Lua package includes LuaRocks5- ?n Windows? 6e>=e got 7ou co=ered5 LuaRocks-2.3.0-win32.zip /ackage includes Lua# LuaRocks and an 0@%;.LL.2.; script. 0f 7ou are a module de=e$oper %hare 7our modu$es at $uarocks.org5 Create an account and: ~$ luarocks upload mymodule-1.0-1.rockspec a rockspec is a simple metadata :$e that points to 7our source code Let Lua!ocks take care of dep$o7ment issues Linu9# O%J# 6indo&s# other Unix s7stems... Lua paths Bisual Studio =s. Min86 on Windo&s4 Compi$er Kags? (Ne=er hear comp$aints a(out f/0C again5- 0 mean it# it's real$7 simp$e5 package = "LPeg" version = "1.0.0-1" source = { url = "http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.0.tar.gz", } description = { summary = "Parsing Expression Grammars For Lua", detailed = [[ LPeg is a new pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs). The nice thing about PEGs is that it has a formal basis and allows an efficient and simple implementation, and does most things we expect from a pattern-matching library (and more, as we can define entire grammars). ]], homepage = "http://www.inf.puc-rio.br/~roberto/lpeg.html", license = "MIT/X11" } dependencies = { "lua >= 5.1" } build = { type = "builtin", modules = { lpeg = { "lpcap.c", "lpcode.c", "lpprint.c", "lptree.c", "lpvm.c" }, re = "re.lua" } } ;hank 7ou! http://luarocks.org Hisham Muhammad @hisham_hm http://hisham.hm .(out these slides Deel free to share this presentation and to use parts of it in 7our o&n materia$ Licensed under the Creati=e Commons CC 2Y 4.0: https://creati=ecommons.org/$icenses/(7/M.0/ .