diff --git a/v23/mklinechecker.go b/v23/mklinechecker.go index bd814417..364a273a 100644 --- a/v23/mklinechecker.go +++ b/v23/mklinechecker.go @@ -306,11 +306,30 @@ func (ck MkLineChecker) checkInclude() { case includedFile.HasSuffixPath("intltool/buildlink3.mk"): mkline.Warnf("Please write \"USE_TOOLS+= intltool\" instead of this line.") + + case includedFile.HasSuffixPath("lang/python/egg.mk"): + ck.checkIncludePythonWheel() } ck.checkIncludeBuiltin() } +func (ck MkLineChecker) checkIncludePythonWheel() { + if pkg := ck.MkLines.pkg; pkg != nil { + accepted := pkg.vars.LastValue("PYTHON_VERSIONS_ACCEPTED") + incompat := pkg.vars.LastValue("PYTHON_VERSIONS_INCOMPATIBLE") + switch { + case contains(accepted, "3") && !contains(accepted, "2"), + contains(incompat, "27"): + mkline := ck.MkLine + mkline.Warnf("Python egg.mk is deprecated, use wheel.mk instead.") + mkline.Explain( + "https://packaging.python.org/en/latest/discussions/wheel-vs-egg/", + "describes the difference between the formats.") + } + } +} + func (ck MkLineChecker) checkIncludeBuiltin() { mkline := ck.MkLine diff --git a/v23/mklinechecker_test.go b/v23/mklinechecker_test.go index 6a1bbad9..84561345 100644 --- a/v23/mklinechecker_test.go +++ b/v23/mklinechecker_test.go @@ -508,6 +508,86 @@ func (s *Suite) Test_MkLineChecker_checkInclude__hacks(c *check.C) { "Relative path \"../../category/package/nonexistent.mk\" does not exist.") } +func (s *Suite) Test_MkLineChecker_checkIncludePythonWheel__no_restrictions(c *check.C) { + t := s.Init(c) + + t.CreateFileLines("lang/python/egg.mk", + MkCvsID) + t.SetUpPackage("devel/py-test") + t.FinishSetUp() + t.Chdir("devel/py-test") + + G.Check(".") + + t.CheckOutputEmpty() +} + +func (s *Suite) Test_MkLineChecker_checkIncludePythonWheel__not_Python_2(c *check.C) { + t := s.Init(c) + + t.CreateFileLines("lang/python/egg.mk", + MkCvsID) + t.SetUpPackage("devel/py-test", + "PYTHON_VERSIONS_INCOMPATIBLE=\t27", + ".include \"../../lang/python/egg.mk\"") + t.FinishSetUp() + t.Chdir("devel/py-test") + + G.Check(".") + + t.CheckOutputLines( + "WARN: Makefile:21: Python egg.mk is deprecated, use wheel.mk instead.") +} + +func (s *Suite) Test_MkLineChecker_checkIncludePythonWheel__not_Python_3(c *check.C) { + t := s.Init(c) + + t.CreateFileLines("lang/python/egg.mk", + MkCvsID) + t.SetUpPackage("devel/py-test", + "PYTHON_VERSIONS_INCOMPATIBLE=\t38\t# rationale", + ".include \"../../lang/python/egg.mk\"") + t.FinishSetUp() + t.Chdir("devel/py-test") + + G.Check(".") + + t.CheckOutputEmpty() +} + +func (s *Suite) Test_MkLineChecker_checkIncludePythonWheel__only_Python_2(c *check.C) { + t := s.Init(c) + + t.CreateFileLines("lang/python/egg.mk", + MkCvsID) + t.SetUpPackage("devel/py-test", + "PYTHON_VERSIONS_ACCEPTED=\t27\t# rationale", + ".include \"../../lang/python/egg.mk\"") + t.FinishSetUp() + t.Chdir("devel/py-test") + + G.Check(".") + + t.CheckOutputEmpty() +} + +func (s *Suite) Test_MkLineChecker_checkIncludePythonWheel__only_Python_3(c *check.C) { + t := s.Init(c) + + t.CreateFileLines("lang/python/egg.mk", + MkCvsID) + t.SetUpPackage("devel/py-test", + "PYTHON_VERSIONS_ACCEPTED=\t310 38\t# rationale", + ".include \"../../lang/python/egg.mk\"") + t.FinishSetUp() + t.Chdir("devel/py-test") + + G.Check(".") + + t.CheckOutputLines( + "WARN: Makefile:21: Python egg.mk is deprecated, use wheel.mk instead.") +} + // A buildlink3.mk file may include its corresponding builtin.mk file directly. func (s *Suite) Test_MkLineChecker_checkIncludeBuiltin__buildlink3_mk(c *check.C) { t := s.Init(c)