Itzik984
Itzik984

Reputation: 16804

Makefile on python

I'm trying to write a Makefile for a python script, that will create a VMTranslator

executable file, which is supposed to get an input,

meaning this is how it is supposed to be done on shell commands:

1)make <==== should make the VMTranslator executable.

2)VMTranslator BasicTest.vm <==== the user is supposed to use it like this.

i have tried the following according to what i have found online:

#!/usr/local/bin/
    python *$

but it is not working.

the files needed to be included are: codeWriter.py , vmTranslator.py , parser.py .

how can this be done?

Upvotes: 0

Views: 7657

Answers (2)

unwind
unwind

Reputation: 400049

The Python binary is an interpreter. It does not create stand-alone executables.

What you can do is to write a Python script that does what you want, as long as the Python executable is present the script can be made to run transparently:

#!/usr/bin/env python
#

import codeWriter
import vmTranslator
import parser

# Add code here to parse arguments and call into the imported code.

Save that as VMTranslator, and make the file executable (chmod +x VMTranslator).

Upvotes: 6

spacediver
spacediver

Reputation: 1493

Are you able to run your script from shell like this python vmTranslator.py BasicTest.vm?.. This should work if vmTranslator.py includes what it needs to work. If so, you can write the following into your executable shell script VMTranslator:

#!/bin/bash
python vmTranslator.py $1

Then you should be able to run it like this:

./VMTranslator BasicTest.vm

You will need ./ in the beginning for the case if your PATH variable does not include current directory . (which is highly recommended settings these days).

Also, be sure to provide correct shebang line #!/bin/bash to locate shell on your system.

Upvotes: 0

Related Questions