Skip to content

Commit

Permalink
Warn about Python packages that use the deprecated egg.mk
Browse files Browse the repository at this point in the history
Suggested by wiz.
  • Loading branch information
rillig committed Dec 16, 2023
1 parent b188f2b commit 61d79ef
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
19 changes: 19 additions & 0 deletions v23/mklinechecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
80 changes: 80 additions & 0 deletions v23/mklinechecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 61d79ef

Please sign in to comment.