@@ -292,6 +292,21 @@ def pack_fn(projectName, description, entryPoints, version, authors, directory):
292292def read_toml_project (file_path : str ) -> dict [str , any ]:
293293 with open (file_path , "rb" ) as f :
294294 content = tomllib .load (f )
295+ if "project" not in content :
296+ raise Exception ("pyproject.toml is missing the required field: project" )
297+ if "name" not in content ["project" ]:
298+ raise Exception (
299+ "pyproject.toml is missing the required field: project.name"
300+ )
301+ if "description" not in content ["project" ]:
302+ raise Exception (
303+ "pyproject.toml is missing the required field: project.description"
304+ )
305+ if "version" not in content ["project" ]:
306+ raise Exception (
307+ "pyproject.toml is missing the required field: project.version"
308+ )
309+
295310 return {
296311 "name" : content ["project" ]["name" ],
297312 "description" : content ["project" ]["description" ],
@@ -320,6 +335,20 @@ def pack(root):
320335 )
321336 return
322337 config = check_config (root )
338+ if not config ["project_name" ] or config ["project_name" ].strip () == "" :
339+ raise Exception ("Project name cannot be empty" )
340+
341+ if not config ["description" ] or config ["description" ].strip () == "" :
342+ raise Exception ("Project description cannot be empty" )
343+
344+ invalid_chars = ["&" , "<" , ">" , '"' , "'" , ";" ]
345+ for char in invalid_chars :
346+ if char in config ["project_name" ]:
347+ raise Exception (f"Project name contains invalid character: '{ char } '" )
348+
349+ for char in invalid_chars :
350+ if char in config ["description" ]:
351+ raise Exception (f"Project description contains invalid character: '{ char } '" )
323352 click .echo (
324353 f"Packaging project { config ['project_name' ]} :{ version or config ['version' ]} description { config ['description' ]} authored by { config ['authors' ]} "
325354 )
0 commit comments