Skip to content

Commit f03b69a

Browse files
committedJan 31, 2017
Don't link in libpython / libpypy
1 parent fbc630d commit f03b69a

File tree

3 files changed

+1
-81
lines changed

3 files changed

+1
-81
lines changed
 

‎setuptools_golang.py

+1-41
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import unicode_literals
33

44
import contextlib
5-
import distutils.sysconfig
65
import os
76
import pipes
87
import shutil
@@ -13,49 +12,10 @@
1312
from setuptools.command.build_ext import build_ext as _build_ext
1413

1514

16-
PYPY = '__pypy__' in sys.builtin_module_names
17-
18-
1915
def _get_cflags(compiler):
2016
return ' '.join('-I{}'.format(p) for p in compiler.include_dirs)
2117

2218

23-
def _get_ldflags_pypy():
24-
if PYPY: # pragma: no cover (pypy only)
25-
return '-L{} -lpypy-c'.format(
26-
os.path.dirname(os.path.realpath(sys.executable)),
27-
)
28-
else:
29-
return None
30-
31-
32-
def _get_ldflags_pkg_config():
33-
try:
34-
return subprocess.check_output((
35-
'pkg-config', '--libs',
36-
'python-{}.{}'.format(*sys.version_info[:2]),
37-
)).decode('UTF-8').strip()
38-
except (subprocess.CalledProcessError, OSError):
39-
return None
40-
41-
42-
def _get_ldflags_bldlibrary():
43-
return distutils.sysconfig.get_config_var('BLDLIBRARY')
44-
45-
46-
def _get_ldflags():
47-
for func in (
48-
_get_ldflags_pypy,
49-
_get_ldflags_pkg_config,
50-
_get_ldflags_bldlibrary,
51-
):
52-
ret = func()
53-
if ret is not None:
54-
return ret
55-
else:
56-
raise AssertionError('Could not determine ldflags!')
57-
58-
5919
def _check_call(cmd, cwd, env):
6020
envparts = [
6121
'{}={}'.format(k, pipes.quote(v))
@@ -113,7 +73,7 @@ def _raise_error(msg):
11373

11474
env.update({
11575
'CGO_CFLAGS': _get_cflags(self.compiler),
116-
'CGO_LDFLAGS': _get_ldflags(),
76+
'CGO_LDFLAGS': '-Wl,--unresolved-symbols=ignore-all',
11777
})
11878
cmd_build = (
11979
'go', 'build', '-buildmode=c-shared',

‎setuptools_golang_test.py

-29
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
import setuptools_golang
1212

1313

14-
xfailif_pypy = pytest.mark.xfail(
15-
setuptools_golang.PYPY, reason='pypy is a special snowflake',
16-
)
17-
18-
1914
@pytest.fixture(autouse=True, scope='session')
2015
def enable_coverage_subprocesses():
2116
here = os.path.dirname(os.path.abspath(__file__))
@@ -56,30 +51,6 @@ def test_sets_cmdclass():
5651
assert dist.cmdclass['build_ext']
5752

5853

59-
GET_LDFLAGS = (
60-
'import distutils.spawn;'
61-
"print(bool(distutils.spawn.find_executable('pkg-config')));"
62-
'import setuptools_golang;'
63-
'print(setuptools_golang._get_ldflags());'
64-
)
65-
66-
67-
@xfailif_pypy
68-
def test_from_pkg_config():
69-
output = run_output(sys.executable, '-c', GET_LDFLAGS)
70-
assert output.startswith('True\n')
71-
assert '-lpython' in output
72-
73-
74-
@xfailif_pypy
75-
def test_no_pkg_config():
76-
# Blank PATH so we don't have pkg-config
77-
env = dict(os.environ, PATH='')
78-
output = run_output(sys.executable, '-c', GET_LDFLAGS, env=env)
79-
assert output.startswith('False\n')
80-
assert '-lpython' in output
81-
82-
8354
@pytest.yield_fixture(scope='session')
8455
def venv(tmpdir_factory):
8556
"""A shared virtualenv fixture, be careful not to install two of the same

‎tox.ini

-11
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ commands =
1515
pre-commit install -f --install-hooks
1616
pre-commit run --all-files
1717

18-
[testenv:pypy]
19-
deps = {[testenv]deps}
20-
passenv = {[testenv]passenv}
21-
setenv = {[testenv]setenv}
22-
commands =
23-
coverage erase
24-
coverage run -m pytest {posargs:setuptools_golang_test.py}
25-
coverage combine
26-
# Omit --fail-under for pypy
27-
coverage report --show-missing
28-
2918
[testenv:venv]
3019
envdir = venv-{[tox]project}
3120
commands =

0 commit comments

Comments
 (0)
Please sign in to comment.