allow to run amitools again in place

This commit is contained in:
Christian Vogelgsang 2016-10-30 19:56:27 +01:00
parent 4213054643
commit df28dee721
12 changed files with 63 additions and 9 deletions

View File

@ -23,9 +23,7 @@ will be very helpful.
- [Cython][1] >= 0.21
- All other packages are installed automatically, if missing:
- [pytest][2]
- [lhafile - FS Edition][3]
- setuptools_scm
- pytest-runner
- [lhafile - FS Edition][3] (Optional: required to use lha file scanner)
- First make sure to have the Python package installer ```pip```:
- On Mac OS X using [MacPorts][4] (Tool is called ```pip-2.7``` here):
```
@ -58,12 +56,7 @@ pacman -S mingw-w64-x86_64-python2-pip mingw-w64-x86_64-gcc git make
## Installation
- The musashi CPU emulator required for vamos needs some code generated first:
```
make do_gen
```
- This will create some files in directory ```gen```
- Now you can use Python's ```setuptools``` to install everything:
- You have multiple variants to install the tools with Python's `setuptools`:
- **Global Install** is available for all users of your system and needs root privileges
```
sudo python setup.py install
@ -76,6 +69,12 @@ python setup.py install --user
you to change/develop the code and test it immediately. (I prefer user install here)
```
python setup.py develop --user
```
- **Run In Place** allows you to run the binaries directly from the `bin` directory
without any installation. You need `setup.py` only to build the native library
of vamos:
```
python setup.py build
```
## Contents

45
bin/amitools Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env python2.7
#
# a small wrapper to run amitools' scripts from here without installation
#
# it assumes that this script resides in a directory of the amitools base dir
from __future__ import print_function
import os
import sys
import importlib
# get current directory
cur_dir = os.path.dirname(__file__)
# amitools folder is in parent dir
base_dir = os.path.abspath(os.path.join(cur_dir, os.pardir))
# check for amitools dir
at_dir = os.path.join(base_dir, "amitools")
if not os.path.isdir(at_dir):
print("amitools: can't find 'amitools' dir in base dir!!", file=sys.stderr)
sys.exit(1)
# add base dir to python path
sys.path.insert(1, base_dir)
# tool
tool = os.path.basename(__file__)
# tool module name
tool_module = "amitools.tools." + tool
main = None
# import tool module
try:
mod = importlib.import_module(tool_module)
mod_dict = mod.__dict__
# check for main function
if 'main' not in mod_dict:
print("amitools: no 'main' function in tool module found!", file=sys.stderr)
sys.exit(3)
main = mod_dict['main']
except ImportError as e:
print("amitools: error importing tool '%s': %s" % (tool_module, e), file=sys.stderr)
sys.exit(2)
# call tool
main()

1
bin/fdtool Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/geotool Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/hunktool Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/rdbtool Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/romtool Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/typetool Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/vamos Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/vamospath Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/xdfscan Symbolic link
View File

@ -0,0 +1 @@
amitools

1
bin/xdftool Symbolic link
View File

@ -0,0 +1 @@
amitools