pynie /

#!/usr/bin/env python

from distutils.core import setup
from import build
from distutils.dep_util import newer_group, newer
from distutils.spawn import spawn
from subprocess import Popen,PIPE
from re import compile
from fileinput import input
from os import mkdir, remove
from os.path import exists
from sys import executable, version_info

pc_raw = Popen("parrot_config --dump", shell=True, stdout=PIPE).stdout.readlines()
if not pc_raw:
    print("\nplease check parrot_config is in your PATH!")

pc = {}
rx = compile("(.*) => '(.*)'")

for l in pc_raw:
    if version_info[0] == 3:
        l = l.decode()
    m = rx.match(l)
    if m:
        pc[] =

pv = pc['VERSION'].split('.')
if int(pv[0]) == 0 or (int(pv[0]) == 1 and int(pv[1]) < 4):
    print("\nPlease use Parrot version 1.4 or higher")

PARROT        = "%s/parrot%s" % (pc['bindir'], pc['exe'])
GRAMMAR_GEN   = "%s/%s/library/PGE/Perl6Grammar.pbc" % (pc['libdir'], pc['versiondir'])
NQP           = "%s/%s/languages/nqp/nqp.pbc" % (pc['libdir'], pc['versiondir'])
PCT           = "%s/library/PCT.pbc" % pc['libdir']
PBC_TO_EXE    = "%s/pbc_to_exe%s" % (pc['bindir'], pc['exe'])


SOURCES = GEN_SOURCES + [ 'pynie.pir',
  'src/parser/indent.pir' ]


  'pynie%s' % pc['exe'],
  'installable_pynie%s' % pc['exe'] ]

def real_build():
    if not exists('include'):

    if newer_group(BUILTINS_PIR, 'include/gen_builtins.pir'):
        f = open('include/gen_builtins.pir', 'w')
        for l in input(BUILTINS_PIR): f.write(l)

    if newer('Grammar/', 'include/gen_grammar.pir'):
        spawn([PARROT, GRAMMAR_GEN, '--output=include/gen_grammar.pir', 'Grammar/'])

    if newer('Grammar/Actions.nqp','include/gen_actions.pir'):
        spawn([PARROT, NQP, '--output=include/gen_actions.pir', '--encoding=fixed_8', '--target=pir', 'Grammar/Actions.nqp'])

    if newer_group(SOURCES + BUILTINS_PIR, 'pynie.pbc'):
        spawn([PARROT, '-o', 'pynie.pbc', 'pynie.pir'])

    if newer('pynie.pbc', 'pynie%s' % pc['exe']):
        spawn([PBC_TO_EXE, 'pynie.pbc'])

class build_pynie(build):
    def run(self):

class test_pynie(build):
    def run(self):
        spawn([executable, ''])

class clean_pynie(build):
    def run(self):
        [remove(f) for f in CLEANUPS if exists(f)]

class help_pynie(build):
    def run(self):
            Following targets are available for the user:

              build:             pynie.pbc and pynie executable
                                 This is the default.

              test:              Run the test suite.

              clean:             Basic cleaning up.

              help:              Print this help message.

      description='Pynie - Python on Parrot',
      cmdclass = {
            'build': build_pynie,
            'clean': clean_pynie,
            'test':  test_pynie,
            'help':  help_pynie,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.