Source

pynie / setup.py

Full commit
blairuk f3a07ba 










blairuk 3b7e30c 
blairuk f3a07ba 


blairuk 3b7e30c 
blairuk f3a07ba 
allisonrandal d406a52 
blairuk f3a07ba 



blairuk 3b7e30c 

blairuk f3a07ba 


allisonrandal ae41cfa 

allisonrandal d406a52 
allisonrandal ae41cfa 


blairuk f8aee0b 



allisonrandal ae41cfa 
blairuk f3a07ba 










allisonrandal d406a52 



isop44 0501ae3 
allisonrandal 7a23248 



isop44 b6c4368 
blairuk f3a07ba 


allisonrandal 40a46f2 

blairuk f3a07ba 

allisonrandal d406a52 
blairuk f3a07ba 


allisonrandal d406a52 
blairuk f3a07ba 









allisonrandal d406a52 
blairuk f3a07ba 
allisonrandal d406a52 

allisonrandal ae41cfa 
allisonrandal d406a52 

blairuk f3a07ba 









allisonrandal d406a52 
blairuk f3a07ba 



allisonrandal d406a52 
blairuk f3a07ba 


blairuk 3b7e30c 
blairuk f3a07ba 

allisonrandal ae41cfa 
blairuk f3a07ba 





allisonrandal d406a52 
blairuk 3b7e30c 
blairuk f3a07ba 












allisonrandal d406a52 
#!/usr/bin/env python

from distutils.core import setup
from distutils.command.build 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!")
    exit(1)

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

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

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")
    exit(1)

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'])

GEN_SOURCES = [
  'include/gen_grammar.pir',
  'include/gen_actions.pir',
  'include/gen_builtins.pir',
]

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

BUILTINS_PIR = [
  'src/builtins/funcs.pir',
  'src/builtins/helper.pir',
  'src/builtins/io.pir',
  'src/builtins/lists.pir',
  'src/builtins/oper.pir',
  'Objects/typeobject.pir',
  'Objects/listobject.pir',
  'Objects/stringobject.pir',
  'Objects/dictobject.pir',
  ]

CLEANUPS = GEN_SOURCES + [
  'pynie.pbc',
  'pynie.o',
  'pynie.c',
  'pynie%s' % pc['exe'],
  'installable_pynie%s' % pc['exe'] ]

def real_build():
    if not exists('include'):
        mkdir('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)
        f.close()

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

    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):
        real_build()
        build.run(self)

class test_pynie(build):
    def run(self):
        real_build()
        spawn([executable, 'runtests.py'])
        build.run(self)

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


class help_pynie(build):
    def run(self):
        print("""
            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.
        """)

setup(name='Pynie',
      version='0.1',
      description='Pynie - Python on Parrot',
      url='http://code.google.com/p/pynie/',
      cmdclass = {
            'build': build_pynie,
            'clean': clean_pynie,
            'test':  test_pynie,
            'help':  help_pynie,
      }
)