Skip to content

Commit

Permalink
Switch to argparse
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Mar 5, 2024
1 parent 6ed6e42 commit 83f70ad
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions tools/build/make_python_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os.path
import tools
import shutil
from optparse import OptionParser
from argparse import ArgumentParser


def build_init(module, source, infname, outfname):
Expand Down Expand Up @@ -41,22 +41,21 @@ def get_example_path(fname):


def main():
parser = OptionParser()
parser.add_option("--build_dir", help="IMP build directory", default=None)
parser.add_option("-s", "--source",
dest="source", help="Where to find IMP source.")

options, args = parser.parse_args()
if len(args) != 1:
parser.error("You must specify an IMP module")
module, = args

mf = tools.ModulesFinder(source_dir=options.source,
external_dir=options.build_dir,
module_name=module)
module = mf[module]
parser = ArgumentParser()
parser.add_argument("--build_dir", help="IMP build directory",
default=None)
parser.add_argument("-s", "--source",
dest="source", help="Where to find IMP source.")
parser.add_argument("module", help="IMP module name")

args = parser.parse_args()

mf = tools.ModulesFinder(source_dir=args.source,
external_dir=args.build_dir,
module_name=args.module)
module = mf[args.module]
build_init(
module, options.source,
module, args.source,
os.path.join(module.path, "pyext", "src", "__init__.py"),
os.path.join("lib", "IMP", module.name, '__init__.py'))

Expand Down

0 comments on commit 83f70ad

Please sign in to comment.