Skip to content

Commit

Permalink
Get binding suffix from python
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Oct 26, 2023
1 parent 6b19cd2 commit 20496ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion recipe/recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (s *RecipeSuite) TestPythonVariables(c *C) {

python3Bin = "_unknown_"
c.Assert(evalPythonCode(3, "test"), Equals, "")
c.Assert(getPythonBindingSuffix(), Equals, "")
c.Assert(getPythonBindingSuffix(3), Equals, "")

python3Bin = "python3"
}
Expand Down
20 changes: 3 additions & 17 deletions recipe/runtime_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package recipe
// ////////////////////////////////////////////////////////////////////////////////// //

import (
"fmt"
"os"
"os/exec"
"strconv"
Expand Down Expand Up @@ -153,7 +152,7 @@ func getRuntimeVariable(name string, r *Recipe) string {
dynVarCache[name] = getPythonSiteArch(3)

case "PYTHON3_BINDING_SUFFIX":
dynVarCache[name] = getPythonBindingSuffix()
dynVarCache[name] = getPythonBindingSuffix(3)

case "LIBDIR":
dynVarCache[name] = getLibDir(false)
Expand Down Expand Up @@ -195,21 +194,8 @@ func getPythonSiteArch(majorVersion int) string {
}

// getPythonBindingSuffix returns suffix for Python bindings
func getPythonBindingSuffix() string {
version := getPythonVersion(3)

if version == "" {
return ""
}

version = strutil.Exclude(version, ".")
systemInfo := getSystemInfo()

if systemInfo == nil {
return ""
}

return fmt.Sprintf(".cpython-%sm-%s-linux-gnu.so", version, systemInfo.Arch)
func getPythonBindingSuffix(majorVersion int) string {
return evalPythonCode(majorVersion, `import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))`)
}

// evalPythonCode evaluates Python code
Expand Down

0 comments on commit 20496ce

Please sign in to comment.