-1

I am developing an API in Unix environment for virtual machines. Most of the modules are developed in python. I have few questions on this.

  1. I have the file extension as abc.py . I would like to make this as a command. For example , "virtman dominfo [vmid]" should be the command syntax. Now I have to give "virtman.py dominfo [vmid]" to achieve this. So how can make this as a command?

  2. I want to make this as an installable API, I mean to install through apt-get/ yum install. What are the steps I need to do to achieve this or some reference URL's would be helpful.

  3. Inside the API I am using absolute path like '/root/virtman/manager/' . Consider running this API in any unix environment , how can I make this absolute path generic to any OS/machine. Or should I have to assume some location where the API will get installed and give that path everywhere?

I read lot of articles but I didn't get the clear picture,so any hints/suggestions would be helpful.

Dany
  • 2,692
  • 7
  • 44
  • 67
  • Although it may seem as one thing to accomplish for you, these are three different questions. They should be raised separately (after having searched for existing answers for each question, obviously). – unixsmurf Nov 01 '14 at 13:16

1 Answers1

1

This seems like it's three questions in one, so I'll attempt to answer each in turn:

File Extensions

Python scripts don't need to have a .py extension in order to be run. For example:

#!/usr/bin/python print("Hello, World!")

Save this as a file called hello and flag it as executable. You should be able to run it from a terminal window by entering ./hello

apt-get / yum

Different systems use different packaging systems. For example, Debian and derivatives such as Ubuntu use .deb files, while Red Hat and co. use .rpm instead (though Debian can load .rpm files via the "Alien" tool). Each is slightly different, so I can't really give you a "generic" answer - hopefully this should be enough to get you started: https://fedoraproject.org/wiki/How_to_create_an_RPM_package

Generic Paths

You should be okay if you stick to the usual /var, /etc, /tmp layout - see this Wikipedia page for details.

GoBusto
  • 4,632
  • 6
  • 28
  • 45