forked from asottile/setuptools-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clean up of downloaded modules when using go.mod
Projects that use go.mod will result in the build downloading the modules to an temporary path. Golang introduced read only directories to protect the generated module cache from accidental writes, resulting in failures to build when exiting the temporary directory context. Adapt the solution from pre-commit to make the directory and file writable on removal and include a rudimentary test that exercises download via a simple example module hosted by the golang org in github. Fixes asottile#49
- Loading branch information
1 parent
a6eaed0
commit b9fd68b
Showing
7 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/asottile/setuptools-golang/testing/gomodules | ||
|
||
go 1.14 | ||
|
||
require github.com/golang/example v0.0.0-20170904185048-46695d81d1fa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa h1:iqCQC2Z53KkwGgTN9szyL4q0OQHmuNjeoNnMT6lk66k= | ||
github.com/golang/example v0.0.0-20170904185048-46695d81d1fa/go.mod h1:tO/5UvQ/uKigUjQBPqzstj6uxd3fUIjddi19DxGJeWg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
// #include <Python.h> | ||
import "C" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/golang/example/stringutil" | ||
) | ||
|
||
//export reversemsg | ||
func reversemsg() *C.PyObject { | ||
fmt.Print(stringutil.Reverse("elpmaxe tset")) | ||
|
||
return C.Py_None | ||
} | ||
|
||
func main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
// #include <Python.h> | ||
// | ||
// PyObject* reversemsg(); | ||
// | ||
// static struct PyMethodDef methods[] = { | ||
// {"reversemsg", (PyCFunction)reversemsg, METH_NOARGS}, | ||
// {NULL, NULL} | ||
// }; | ||
// | ||
// #if PY_MAJOR_VERSION >= 3 | ||
// static struct PyModuleDef module = { | ||
// PyModuleDef_HEAD_INIT, | ||
// "gomodules", | ||
// NULL, | ||
// -1, | ||
// methods | ||
// }; | ||
// | ||
// PyMODINIT_FUNC PyInit_gomodules(void) { | ||
// return PyModule_Create(&module); | ||
// } | ||
// #else | ||
// PyMODINIT_FUNC initgomodules(void) { | ||
// Py_InitModule3("gomodules", methods, NULL); | ||
// } | ||
// #endif | ||
import "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from setuptools import Extension | ||
from setuptools import setup | ||
|
||
|
||
setup( | ||
name='gomod', | ||
ext_modules=[Extension('gomodules', ['reversemsg.go'])], | ||
build_golang={ | ||
'root': 'github.com/asottile/setuptools-golang/testing/gomodules', | ||
}, | ||
# Would do this, but we're testing *our* implementation and this would | ||
# install from pypi. We can rely on setuptools-golang being already | ||
# installed under test. | ||
# setup_requires=['setuptools-golang'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters