Why is node-gyp written in python?

1,607 views
Skip to first unread message

Gagle

unread,
Feb 16, 2014, 5:12:43 AM2/16/14
to nod...@googlegroups.com
I mean, it's a very huge dependency. Node.js can be installed in any system with low resources. If python were a 5MB dependency, it's ok, but python also depends on sqlite. Don't you think that node-gyp could be rewritten itself in node.js? I know it's a hard work but from my point of view, it's worth trying.

Angel Java Lopez

unread,
Feb 16, 2014, 5:37:13 AM2/16/14
to nod...@googlegroups.com
I never used gyp DIRECTLY (only via node-gyp, or v8 compile instructions), but apparently, it uses Python in its guts:


The "json" configuration files are Python dictionaries, and I suspect that python is used to read them. And for many other tasks in gyp. Curiously, I cannot find Python listed as a dependency of gyp, file/readme?

I'm not sure the python version required/support (2.6? 2.7? 3.x?)

Angel "Java" Lopez
@ajlopez



On Sun, Feb 16, 2014 at 7:12 AM, Gagle <gagl...@gmail.com> wrote:
I mean, it's a very huge dependency. Node.js can be installed in any system with low resources. If python were a 5MB dependency, it's ok, but python also depends on sqlite. Don't you think that node-gyp could be rewritten itself in node.js? I know it's a hard work but from my point of view, it's worth trying.

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Gagle

unread,
Feb 16, 2014, 6:50:26 AM2/16/14
to nod...@googlegroups.com
node-gyp depends on gyp, and gyp is written with python.

José F. Romaniello

unread,
Feb 16, 2014, 8:45:30 AM2/16/14
to nod...@googlegroups.com

I assume because what it does is complex and no one had the time to rewrite and maintain.

Installing python has never been a problem on most *nix. Since Windows doesn't have an official package manager you have to download it. If you are a software developer you probably have python 2.7 installed.

Something that has been discussed over and over without any agreement, IMHO you shouldn't build your dependencies on production. We pre-built our deps in CI(which match the target distribution and arch)  before running tests and we send the pkg ready to run.

El feb 16, 2014 7:12 a.m., "Gagle" <gagl...@gmail.com> escribió:
I mean, it's a very huge dependency. Node.js can be installed in any system with low resources. If python were a 5MB dependency, it's ok, but python also depends on sqlite. Don't you think that node-gyp could be rewritten itself in node.js? I know it's a hard work but from my point of view, it's worth trying.

--

Charlie McConnell

unread,
Feb 16, 2014, 8:48:36 AM2/16/14
to nod...@googlegroups.com
gyp is the build system v8 uses, which is why it was adopted for several node purposes.
 
--
Charlie McConnell

Kevin Ingwersen

unread,
Feb 16, 2014, 10:50:53 AM2/16/14
to nod...@googlegroups.com
GYP is quite awesome indeed. It just lacks a few small things.
It runs on Python 2.7, and to get Py on windows, youre gonna have to suffer a nice flood of download material. I just wish there was a more portable Python. Like, a typical PHP build is just 10MB or so - python seems to always come around with 100mb or alike o-o
But then again, I am sure only devs really have it installed, since not every consumer PC has a toolchain installed… x3
--



Aria Stewart

unread,
Feb 16, 2014, 12:32:18 PM2/16/14
to nod...@googlegroups.com
On Sun, Feb 16, 2014 at 04:50:53PM +0100, Kevin Ingwersen wrote:
> GYP is quite awesome indeed. It just lacks a few small things.
> It runs on Python 2.7, and to get Py on windows, youre gonna have to suffer a nice flood of download material. I just wish there was a more portable Python. Like, a typical PHP build is just 10MB or so - python seems to always come around with 100mb or alike o-o
> But then again, I am sure only devs really have it installed, since not every consumer PC has a toolchain installed... x3

I did write a parser for gyp files, including some of the inclusion and
conditional behavior -- look at the 'gyp' project in the npm registry.

If anyone wants to bind that to, say, a fez or gulp based builder, I'd think
that's about the coolest thing since sliced bread.

Kevin Ingwersen

unread,
Feb 16, 2014, 12:37:38 PM2/16/14
to nod...@googlegroups.com
Does the gyp project also parse single-quoted strings - such as found in node.gyp? :o

Aria Stewart

unread,
Feb 16, 2014, 12:34:54 PM2/16/14
to nod...@googlegroups.com
On Sun, Feb 16, 2014 at 06:37:38PM +0100, Kevin Ingwersen wrote:
> Does the gyp project also parse single-quoted strings - such as found in node.gyp? :o

It does now! Fixed that the day it was reported ;-)

It's also really easy to hack on -- it's a series of inherited ometa grammars.
About as straightforward as that gets.

Alex Kocharin

unread,
Feb 17, 2014, 6:36:13 PM2/17/14
to nod...@googlegroups.com
 
16.02.2014, 14:12, "Gagle" <gagl...@gmail.com>:
I mean, it's a very huge dependency. Node.js can be installed in any system with low resources. If python were a 5MB dependency, it's ok, but python also depends on sqlite. Don't you think that node-gyp could be rewritten itself in node.js? I know it's a hard work but from my point of view, it's worth trying.
 
Don't worry, according to Atwood's Law, node-gyp will eventually be written in javascript. ;)
 

Alex Kocharin

unread,
Feb 18, 2014, 2:55:08 AM2/18/14
to nod...@googlegroups.com

16.02.2014, 21:36, "Aria Stewart" <ared...@nbtsc.org>:
Is there any reason not to use a regular YAML parser for it?

Kevin Ingwersen

unread,
Feb 18, 2014, 4:24:53 AM2/18/14
to nod...@googlegroups.com
„Atwood’s Law“? What’s dat o.o

I’d really like to help, when people are writing a js based build system - because I would really like to see something that looks more like nodejs x3.


Alex Kocharin

unread,
Feb 18, 2014, 6:15:49 AM2/18/14
to nod...@googlegroups.com

18.02.2014, 13:24, "Kevin Ingwersen" <ingwi...@googlemail.com>:
> Am Di. Feb. 18 2014 00:36:13 schrieb Alex Kocharin:
>
>>  16.02.2014, 14:12, "Gagle" <gagl...@gmail.com>:
>>>  I mean, it's a very huge dependency. Node.js can be installed in any system with low resources. If python were a 5MB dependency, it's ok, but python also depends on sqlite. Don't you think that node-gyp could be rewritten itself in node.js? I know it's a hard work but from my point of view, it's worth trying.
>>  Don't worry, according to Atwood's Law, node-gyp will eventually be written in javascript. ;)
>
> "Atwood's Law"? What's dat o.o

"Any application that can be written in JavaScript, will eventually be written in JavaScript". ;)

Kevin Ingwersen

unread,
Feb 18, 2014, 7:48:27 AM2/18/14
to nod...@googlegroups.com
Makes sense now =)!

Angel Java Lopez

unread,
Feb 18, 2014, 8:01:21 AM2/18/14
to nod...@googlegroups.com

Aria Stewart

unread,
Feb 19, 2014, 7:34:59 AM2/19/14
to Alex Kocharin, nod...@googlegroups.com
On Feb 18, 2014 2:55 AM, Alex Kocharin <al...@kocharin.ru> wrote:
> Is there any reason not to use a regular YAML parser for it?

Other than the language not being YAML?

Kevin Ingwersen

unread,
Feb 19, 2014, 7:42:54 AM2/19/14
to nod...@googlegroups.com, Alex Kocharin
GYP’s „language“ is a giant python dictionary - very JSON like. Hence, you can use certain python expressions, for expanding variables and stuff. Thats why you cant use YAML. o.o

Alex Kocharin

unread,
Feb 19, 2014, 9:36:11 AM2/19/14
to nod...@googlegroups.com

19.02.2014, 16:39, "Aria Stewart" <ared...@nbtsc.org>:
> On Feb 18, 2014 2:55 AM, Alex Kocharin <al...@kocharin.ru> wrote:
>
>>  Is there any reason not to use a regular YAML parser for it?
>
> Other than the language not being YAML?

JSON is not YAML as well, but it is parsed by a generic yaml parser just fine.

Alex Kocharin

unread,
Feb 19, 2014, 9:44:08 AM2/19/14
to Kevin Ingwersen, nod...@googlegroups.com

Can a gyp parser expand something like that? `{ 'test': [2 * x for x in [1,2,3]] }`

If you CAN use python expressions, it means that you have to implement a full-bloated python interpreter in order to parse that file.

Hmm... maybe pyjs or skulpt will do the job.


19.02.2014, 16:43, "Kevin Ingwersen" <ingwi...@googlemail.com>:

Angel Java Lopez

unread,
Feb 19, 2014, 9:51:27 AM2/19/14
to nod...@googlegroups.com
Ummm... but node-gyp IS USING gyp


It is not only read the config file, and voila! to get rid off python, the gyp logic should be rewritten in JavaScript

Am I right?


Kevin Ingwersen

unread,
Feb 19, 2014, 3:02:21 PM2/19/14
to nod...@googlegroups.com
Yes, you are. No python, no node-gyp currently.
I am thinking about porting/expanding a C++ based build system to be used with NodeJS, which has a script-like language, that makes dynamic building easier and the like: https://github.com/eichlan/build
I have forked it, and am adding functions to it currently ( https://github.com/IngwiePhoenix/build )
But that’s just an idea o.o

Aria Stewart

unread,
Feb 21, 2014, 12:15:05 AM2/21/14
to nod...@googlegroups.com, Kevin Ingwersen
On Wed, Feb 19, 2014 at 06:44:08PM +0400, Alex Kocharin wrote:
>
> Can a gyp parser expand something like that? `{ 'test': [2 * x for x in [1,2,3]] }`

Mine can't yet, but that's eventually the goal -- support all expression-level syntax that's legal.

> If you CAN use python expressions, it means that you have to implement a full-bloated python interpreter in order to parse that file.

Just expression syntax -- which is a very much smaller subset.

Aria Stewart

unread,
Feb 21, 2014, 12:16:05 AM2/21/14
to nod...@googlegroups.com
Yes, but won't reject invalid input properly.
Reply all
Reply to author
Forward
0 new messages