Skip to content

Commit fbc630d

Browse files
committed
Don't require ldflags for go get
1 parent dc47fdc commit fbc630d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

setuptools_golang.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _get_ldflags():
5656
raise AssertionError('Could not determine ldflags!')
5757

5858

59-
def _print_cmd(env, cmd):
59+
def _check_call(cmd, cwd, env):
6060
envparts = [
6161
'{}={}'.format(k, pipes.quote(v))
6262
for k, v in sorted(tuple(env.items()))
@@ -65,6 +65,7 @@ def _print_cmd(env, cmd):
6565
'$ {}'.format(' '.join(envparts + [pipes.quote(p) for p in cmd])),
6666
file=sys.stderr,
6767
)
68+
subprocess.check_call(cmd, cwd=cwd, env=dict(os.environ, **env))
6869

6970

7071
@contextlib.contextmanager
@@ -106,25 +107,19 @@ def _raise_error(msg):
106107
shutil.copytree('.', root_path)
107108
pkg_path = os.path.join(root_path, main_dir)
108109

109-
env = {
110-
'GOPATH': tempdir,
110+
env = {'GOPATH': tempdir}
111+
cmd_get = ('go', 'get', '-d')
112+
_check_call(cmd_get, cwd=pkg_path, env=env)
113+
114+
env.update({
111115
'CGO_CFLAGS': _get_cflags(self.compiler),
112116
'CGO_LDFLAGS': _get_ldflags(),
113-
}
114-
cmd_get = ('go', 'get')
115-
_print_cmd(env, cmd_get)
116-
subprocess.check_call(
117-
cmd_get, cwd=pkg_path, env=dict(os.environ, **env),
118-
)
119-
117+
})
120118
cmd_build = (
121119
'go', 'build', '-buildmode=c-shared',
122120
'-o', os.path.abspath(self.get_ext_fullpath(ext.name)),
123121
)
124-
_print_cmd(env, cmd_build)
125-
subprocess.check_call(
126-
cmd_build, cwd=pkg_path, env=dict(os.environ, **env),
127-
)
122+
_check_call(cmd_build, cwd=pkg_path, env=env)
128123

129124
return build_extension
130125

0 commit comments

Comments
 (0)