@@ -13,6 +13,7 @@ def main(
1313 path_manifest : str ,
1414 path_setup : str ,
1515 path_init : str ,
16+ path_cmake : str ,
1617 is_from_manifest : bool ,
1718 * args , ** kwargs
1819) -> bool :
@@ -77,6 +78,15 @@ def main(
7778 with open (path_init , "w" ) as f :
7879 f .write (init )
7980
81+ # modify the CMake file
82+ cmake_crt_version = None
83+ # search the first "project" line
84+ with open (path_cmake , "r" ) as f :
85+ cmake = f .read ()
86+ cmake = re .sub (r"(project\(diffCheck VERSION )(\d+\.\d+\.\d+)" , r"\g<1>" + version , cmake )
87+ with open (path_cmake , "w" ) as f :
88+ f .write (cmake )
89+
8090 return True
8191
8292if __name__ == "__main__" :
@@ -98,24 +108,31 @@ def main(
98108 parser .add_argument (
99109 "--path-manifest" ,
100110 type = str ,
101- required = False ,
111+ required = True ,
102112 default = "./manifest.yml" ,
103113 help = "The path to the manifest file."
104114 )
105115 parser .add_argument (
106116 "--path-setup" ,
107117 type = str ,
108- required = False ,
109- default = "./py/pypi /setup.py" ,
118+ required = True ,
119+ default = "./src/gh/diffCheck /setup.py" ,
110120 help = "The path to the setup file."
111121 )
112122 parser .add_argument (
113123 "--path-init" ,
114124 type = str ,
115- required = False ,
116- default = "./py/pypi/ACPy /__init__.py" ,
125+ required = True ,
126+ default = "./src/gh/diffCheck/diffCheck /__init__.py" ,
117127 help = "The path to the __init__ file."
118128 )
129+ parser .add_argument (
130+ "--path-cmake" ,
131+ type = str ,
132+ required = True ,
133+ default = "./CMakeLists.txt" ,
134+ help = "The path to the CMake file."
135+ )
119136
120137 args = parser .parse_args ()
121138 parse_errors = []
@@ -154,23 +171,17 @@ def main(
154171 is_init_ok = False
155172 parse_errors .append (f"Path to __init__ file is invalid: { args .path_init } " )
156173
174+ is_cmake_ok = True
175+ if not os .path .isfile (args .path_cmake ):
176+ is_cmake_ok = False
177+ parse_errors .append (f"Path to CMake file is invalid: { args .path_cmake } " )
178+
157179 print ("Versionizer checks:" )
158- if is_version_ok :
159- print ("\t [x] Correct version format" )
160- else :
161- print (f"\t [ ] Correct version format" )
162- if is_manifest_ok :
163- print ("\t [x] Manifest file path is valid" )
164- else :
165- print (f"\t [ ] Manifest file path is valid" )
166- if is_setup_ok :
167- print ("\t [x] Setup file path is valid" )
168- else :
169- print (f"\t [ ] Setup file path is valid" )
170- if is_init_ok :
171- print ("\t [x] __init__ file path is valid" )
172- else :
173- print (f"\t [ ] __init__ file path is valid" )
180+ print (f"\t [{ 'x' if is_version_ok else ' ' } ] Correct version format: { args .version } " )
181+ print (f"\t [{ 'x' if is_manifest_ok else ' ' } ] Manifest file exists: { args .path_manifest } " )
182+ print (f"\t [{ 'x' if is_setup_ok else ' ' } ] Setup file exists: { args .path_setup } " )
183+ print (f"\t [{ 'x' if is_init_ok else ' ' } ] __init__ file exists: { args .path_init } " )
184+ print (f"\t [{ 'x' if is_cmake_ok else ' ' } ] CMake file exists: { args .path_cmake } " )
174185 if parse_errors .__len__ () != 0 :
175186 print ("[ERRORS]:" )
176187 for error in parse_errors :
@@ -183,6 +194,7 @@ def main(
183194 path_manifest = args .path_manifest ,
184195 path_setup = args .path_setup ,
185196 path_init = args .path_init ,
197+ path_cmake = args .path_cmake ,
186198 is_from_manifest = args .from_manifest
187199 )
188200
0 commit comments