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