@@ -1866,15 +1866,20 @@ def _python_checkpatchfiles():
1866
1866
pypi_base_url = "https://pypi.org"
1867
1867
with open (listfilename , "r" ) as listfile :
1868
1868
content = listfile .read ()
1869
- patchfile_pattern = re .compile (r"lib-graalpython/patches/([^/]+)/(sdist|whl)/(. *\.patch)" )
1869
+ patchfile_pattern = re .compile (r"lib-graalpython/patches/([^/]+)/.*?([^/] *\.patch)" )
1870
1870
checked = {
1871
+ # meson-python puts the whole license text in the field. It's MIT
1872
+ 'meson-python-0.12.patch' ,
1873
+ 'meson-python-0.13.patch' ,
1871
1874
# scipy puts the whole license text in the field, skip it. It's new BSD
1872
1875
'scipy-1.3.1.patch' ,
1873
1876
'scipy-1.4.1.patch' ,
1874
1877
'scipy-1.7.3.patch' ,
1875
1878
'scipy-1.8.1.patch' ,
1876
1879
'scipy-1.9.1.patch' ,
1880
+ 'scipy-1.9.3.patch' ,
1877
1881
'scipy-1.10.0.patch' ,
1882
+ 'scipy-1.10.1.patch' ,
1878
1883
# pandas puts the whole license text in the field. Its BSD-3-Clause
1879
1884
'pandas-1.4.3.patch' ,
1880
1885
'pandas-1.5.2.patch' ,
@@ -1883,24 +1888,38 @@ def _python_checkpatchfiles():
1883
1888
'setuptools-60.9.patch' ,
1884
1889
'setuptools-63.patch' ,
1885
1890
'setuptools-65.patch' ,
1886
- 'wheel-0.33.patch' ,
1887
- 'wheel-0.34.patch'
1891
+ # Empty license field. It's MIT
1892
+ 'urllib3-2.patch' ,
1893
+ # Empty license field. It's MIT
1894
+ 'wheel-pre-0.35.patch' ,
1888
1895
}
1889
1896
allowed_licenses = [
1890
- "MIT" , "BSD" , "BSD-3-Clause" , "BSD 3-Clause License" ,
1891
- "BSD or Apache License, Version 2.0" , "Apache License, Version 2.0" ,
1892
- "MIT license" , "PSF" , "BSD-3-Clause OR Apache-2.0" , "Apache" , "Apache License" , "new BSD" ,
1893
- "(Apache-2.0 OR BSD-3-Clause) AND PSF-2.0" , "Apache 2.0" , "MPL-2.0" , "BSD 3-Clause" ,
1897
+ "MIT" ,
1898
+ "BSD" ,
1899
+ "BSD-3-Clause" ,
1900
+ "Apache License, Version 2.0" ,
1901
+ "PSF" ,
1902
+ "Apache" ,
1903
+ "new BSD" ,
1904
+ "Apache-2.0" ,
1905
+ "MPL-2.0" ,
1894
1906
"LGPL" ,
1895
1907
]
1908
+
1909
+ def as_license_regex (name ):
1910
+ subregex = re .escape (name ).replace (r'\-' , '[- ]' )
1911
+ return f'(?:{ subregex } (?: license)?)'
1912
+
1913
+ allowed_licenses_regex = re .compile ('|' .join (map (as_license_regex , allowed_licenses )), re .IGNORECASE )
1914
+
1896
1915
for line in content .split ("\n " ):
1897
1916
if not line or os .stat (line ).st_size == 0 :
1898
1917
# empty files are just markers and do not need to be license checked
1899
1918
continue
1900
1919
match = patchfile_pattern .search (line )
1901
1920
if match :
1902
1921
package_name = match .group (1 )
1903
- patch_name = match .group (3 )
1922
+ patch_name = match .group (2 )
1904
1923
if patch_name in checked :
1905
1924
continue
1906
1925
checked .add (patch_name )
@@ -1909,12 +1928,15 @@ def _python_checkpatchfiles():
1909
1928
response = urllib_request .urlopen (package_url )
1910
1929
try :
1911
1930
data = json .loads (response .read ())
1912
- data_license = data ["info" ]["license" ]
1913
- if data_license not in allowed_licenses :
1914
- mx .abort (
1915
- f"The license for the original project of patch file { patch_name !r} is { data_license !r} . "
1916
- f"We cannot include a patch for it. Allowed licenses are: { allowed_licenses } "
1917
- )
1931
+ license_field = data ["info" ]["license" ]
1932
+ license_field_no_parens = re .sub (r'[()]' , '' , license_field )
1933
+ license_tokens = re .split (r' AND | OR ' , license_field_no_parens )
1934
+ for license_token in license_tokens :
1935
+ if not allowed_licenses_regex .match (license_token ):
1936
+ mx .abort (
1937
+ f"The license for the original project of patch file { patch_name !r} is { license_field !r} . "
1938
+ f"We cannot include a patch for it. Allowed licenses are: { allowed_licenses } "
1939
+ )
1918
1940
except Exception as e : # pylint: disable=broad-except;
1919
1941
mx .abort ("Error getting %r.\n %r" % (package_url , e ))
1920
1942
finally :
0 commit comments