0

I am writing a small code project (or module), and willing to implement the same technique in 3 different languages, namely: Python, JS, Lua. I would like to make a single github repo that contains all the code in all these languages.

My question is: How do I make this as an installable package, that works for all three languages? i.e:

For Python, I would like it to be available via

pip install packagex

For Lua, I would like it to be available via:

luarocks install packagex

And similarly for JS/Node:

npm install packagex

Yes, I can create three different repos for three different platforms and register each one of them as installable packages, but I would like to keep everything in a single source repo. How should I proceed? Thanks.

Matt Sanders
  • 8,023
  • 3
  • 37
  • 49
khan
  • 7,005
  • 15
  • 48
  • 70
  • GitHub is merely a repository for source code, and there is no reason why, for example, a Python project could not be in the same repository as a JavaScript project. How you go about creating your installer is a different story. – Tim Biegeleisen May 27 '16 at 01:48
  • Yep. Everything can be practically contained in a single repository. The issue of creating the installer. – khan May 27 '16 at 02:02
  • Three branches in one repo could hold all your code. But I don't think the installation issue is Git's business. – ElpieKay May 27 '16 at 05:22
  • 1
    There is a good discussion of this in [this existing question](http://stackoverflow.com/questions/14679614/whats-the-best-practice-for-putting-multiple-projects-in-a-git-repository). You could also put each language in a different directory in the root level of your repo. – Matt Sanders May 27 '16 at 06:31
  • Yes, a single repository with three directories can be a way to go. But when creating the installer for each, maybe I will have to pass the source address differently. – khan May 27 '16 at 16:20
  • **Continous Integration** – ddavison May 27 '16 at 18:38

1 Answers1

0

I can answer the LuaRocks part of the question:

LuaRocks

If you choose to create subdirectories for each language and the Lua stuff lives under /lua, you can follow the usual process of creating a rockspec file, and add a source.dir entry, telling it to work within the subdirectory. So, in the above link's example, you'do something like:

source = {
   url = "git://github.com/me/luafruits",
   tag = "v1.0",
   dir = "luafruits/lua"
}

source.dir is documented along with the rest of the rockspec format:

  • source.dir (string) - the name of the directory created when the source archive is unpacked. Can be omitted if it can be inferred from the source.file field. Example: "luasocket-2.0.1"

For Git repositories, source.dir is inferred by default to be the last component of the path, but you can redefine it at will if your code lives in a subdirectory. All other paths in the rockspec will be relative to this source.dir.

Alternatively, you could just add lua/ to all paths of your build section instead. In the "luafruits" example from the documentation, notice that all sources live inside src/. Just use lua/ instead and you're good to go, no need to use source.dir.

Hisham H M
  • 6,398
  • 1
  • 29
  • 30