35 from __future__
import print_function
45 from rospkg
import on_ros_path, RosPack, ResourceNotFound
49 templates[
'CMakeLists.txt'] =
read_template(
'CMakeLists.tmpl')
56 return template%locals()
58 def create_package(package, author, depends, uses_roscpp=False, uses_rospy=False):
59 p = os.path.abspath(package)
61 print(
"%s already exists, aborting"%p, file=sys.stderr)
65 print(
"Created package directory", p)
69 cpp_path = os.path.join(p,
'include', package)
72 print(
"Created include directory", cpp_path)
73 cpp_path = os.path.join(p,
'src')
75 print(
"Created cpp source directory", cpp_path)
81 py_path = os.path.join(p,
'src')
84 print(
"Created python source directory", py_path)
90 for filename, template
in templates.items():
92 p = os.path.abspath(os.path.join(package, filename))
93 with open(p,
'w')
as f:
94 f.write(contents.encode(
'utf-8'))
95 print(
"Created package file", p)
96 print(
"\nPlease edit %s/manifest.xml and mainpage.dox to finish creating your package"%package)
99 from optparse
import OptionParser
100 parser = OptionParser(usage=
"usage: %prog <package-name> [dependencies...]", prog=NAME)
101 options, args = parser.parse_args()
103 parser.error(
"you must specify a package name and optionally also list package dependencies")
106 if not roslib.names.is_legal_resource_base_name(package):
107 parser.error(
"illegal package name: %s\nNames must start with a letter and contain only alphanumeric characters\nand underscores."%package)
111 uses_roscpp =
'roscpp' in depends
112 uses_rospy =
'rospy' in depends
118 except ResourceNotFound:
119 print(
"ERROR: dependency [%s] cannot be found"%d, file=sys.stderr)
122 depends =
u''.join([
u' <depend package="%s"/>\n'%d
for d
in depends])
124 if not on_ros_path(os.getcwd()):
125 print(
'!'*80+
"\nWARNING: current working directory is not on ROS_PACKAGE_PATH!\nPlease update your ROS_PACKAGE_PATH environment variable.\n"+
'!'*80, file=sys.stderr)
126 if type(package) == str:
127 package = package.decode(
'utf-8')
def instantiate_template(template, package, brief, description, author, depends)
def create_package(package, author, depends, uses_roscpp=False, uses_rospy=False)