Skip to content

Commit db9aa89

Browse files
author
Justin Boswell
authored
Fixes for swift (#116)
* Only export compiler if CC/CXX are not specified * Reduce what's installed on the swift centos docker image * Added support for differentiating centos from manylinux * Trimmed down swift docker images
1 parent 38af2cf commit db9aa89

File tree

7 files changed

+47
-105
lines changed

7 files changed

+47
-105
lines changed

.github/docker-images/swift-5-al2-x64/Dockerfile

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@ FROM swift:5.4-amazonlinux2
55
# Install prereqs
66
# any prereqs that appear to be missing are installed on base swift image i.e. tar, git
77
###############################################################################
8-
RUN yum -y update \
9-
&& yum -y install \
8+
RUN yum -y install \
109
curl \
1110
sudo \
1211
# Python
1312
python3 \
14-
python3-devel \
1513
python3-pip \
16-
make \
17-
cmake3 \
18-
gcc-c++ \
1914
openssl-devel \
2015
&& yum clean all \
21-
&& rm -rf /var/cache/yum \
22-
&& ln -s /usr/bin/cmake3 /usr/bin/cmake \
23-
&& ln -s /usr/bin/ctest3 /usr/bin/ctest \
24-
&& cmake --version \
25-
&& ctest --version
16+
&& rm -rf /var/cache/yum
2617

2718
###############################################################################
2819
# Python/AWS CLI
@@ -31,28 +22,9 @@ RUN python3 -m pip install --upgrade pip setuptools virtualenv \
3122
&& python3 -m pip install --upgrade awscli \
3223
&& aws --version
3324

34-
###############################################################################
35-
# Install pre-built OpenSSL
36-
###############################################################################
37-
WORKDIR /tmp
38-
RUN curl -sSL https://d19elf31gohf1l.cloudfront.net/_binaries/libcrypto/libcrypto-1.1.1-linux-x64.tar.gz -o libcrypto.tar.gz \
39-
&& mkdir /opt/openssl \
40-
&& tar xzf libcrypto.tar.gz -C /opt/openssl \
41-
&& LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/openssl/lib /opt/openssl/bin/openssl version \
42-
&& rm -f /tmp/libcrypto.tar.gz
43-
44-
###############################################################################
45-
# Install pre-built CMake
46-
###############################################################################
47-
WORKDIR /tmp
48-
RUN curl -sSL https://d19elf31gohf1l.cloudfront.net/_binaries/cmake/cmake-3.13-manylinux1-x64.tar.gz -o cmake.tar.gz \
49-
&& tar xvzf cmake.tar.gz -C /usr/local \
50-
&& cmake --version \
51-
&& rm -f /tmp/cmake.tar.gz
52-
5325
###############################################################################
5426
# Install entrypoint
5527
###############################################################################
5628
ADD entrypoint.sh /usr/local/bin/builder
5729
RUN chmod a+x /usr/local/bin/builder
58-
ENTRYPOINT ["/usr/local/bin/builder"]
30+
ENTRYPOINT ["/usr/local/bin/builder"]

.github/docker-images/swift-5-centos-x64/Dockerfile

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,15 @@ FROM swift:5.4-centos7
55
# Install prereqs
66
# any prereqs that appear to be missing are installed on base swift image i.e. tar, git
77
###############################################################################
8-
RUN yum -y update \
9-
&& yum -y install \
8+
RUN yum -y install \
109
sudo \
1110
# Python
1211
python3 \
13-
python3-devel \
1412
python3-pip \
15-
make \
16-
cmake \
17-
cmake3 \
1813
openssl-devel \
19-
gcc-c++ \
2014
&& yum clean all \
21-
&& rm -rf /var/cache/yum
22-
###############################################################################
23-
# Handle cmake on centos properly
24-
###############################################################################
25-
RUN sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \
26-
--slave /usr/local/bin/ctest ctest /usr/bin/ctest \
27-
--slave /usr/local/bin/cpack cpack /usr/bin/cpack \
28-
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \
29-
--family cmake
15+
&& rm -rf /var/cache/yum
3016

31-
RUN sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
32-
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
33-
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
34-
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
35-
--family cmake
36-
37-
RUN ln -s /usr/bin/cmake3 /usr/bin/cmake \
38-
ln -s /usr/bin/ctest3 /usr/bin/ctest \
39-
cmake --version \
40-
&& ctest --version
4117

4218
###############################################################################
4319
# Python/AWS CLI
@@ -46,20 +22,9 @@ RUN python3 -m pip install --upgrade pip setuptools virtualenv \
4622
&& python3 -m pip install --upgrade awscli \
4723
&& aws --version
4824

49-
###############################################################################
50-
# Install pre-built OpenSSL
51-
###############################################################################
52-
WORKDIR /tmp
53-
RUN curl -sSL https://d19elf31gohf1l.cloudfront.net/_binaries/libcrypto/libcrypto-1.1.1-linux-x64.tar.gz -o libcrypto.tar.gz \
54-
&& mkdir /opt/openssl \
55-
&& tar xzf libcrypto.tar.gz -C /opt/openssl \
56-
&& LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/openssl/lib /opt/openssl/bin/openssl version \
57-
&& rm -f /tmp/libcrypto.tar.gz
58-
59-
6025
###############################################################################
6126
# Install entrypoint
6227
###############################################################################
6328
ADD entrypoint.sh /usr/local/bin/builder
6429
RUN chmod a+x /usr/local/bin/builder
65-
ENTRYPOINT ["/usr/local/bin/builder"]
30+
ENTRYPOINT ["/usr/local/bin/builder"]

.github/docker-images/swift-5-ubuntu-16-x64/Dockerfile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ RUN apt-get update -qq \
1111
curl \
1212
# Python
1313
python3 \
14-
python3-dev \
1514
python3-pip \
16-
build-essential \
1715
# For PPAs
1816
libssl-dev \
1917
software-properties-common \
@@ -28,15 +26,6 @@ RUN python3 -m pip install setuptools \
2826
&& python3 -m pip install --upgrade awscli \
2927
&& aws --version
3028

31-
###############################################################################
32-
# Install pre-built CMake
33-
###############################################################################
34-
WORKDIR /tmp
35-
RUN curl -sSL https://d19elf31gohf1l.cloudfront.net/_binaries/cmake/cmake-3.13-manylinux1-x64.tar.gz -o cmake.tar.gz \
36-
&& tar xvzf cmake.tar.gz -C /usr/local \
37-
&& cmake --version \
38-
&& rm -f /tmp/cmake.tar.gz
39-
4029
###############################################################################
4130
# Install entrypoint
4231
###############################################################################

builder/actions/install.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,19 @@ def export_compiler(compiler, env):
9999
return
100100

101101
toolchain = env.toolchain
102-
cc_path = toolchain.compiler_path()
103-
cxx_path = toolchain.cxx_compiler_path()
104-
if cc_path:
105-
env.shell.setenv('CC', cc_path)
106-
else:
107-
print('WARNING: C compiler {} could not be found for export'.format(compiler))
108-
if cxx_path:
109-
env.shell.setenv('CXX', cc_path)
110-
else:
111-
print('WARNING: CXX compiler {} could not be found for export'.format(compiler))
102+
if not env.shell.getenv('CC'):
103+
cc_path = toolchain.compiler_path()
104+
if cc_path:
105+
env.shell.setenv('CC', cc_path)
106+
else:
107+
print('WARNING: C compiler {} could not be found for export'.format(compiler))
108+
109+
if not env.shell.getenv('CXX'):
110+
cxx_path = toolchain.cxx_compiler_path()
111+
if cxx_path:
112+
env.shell.setenv('CXX', cc_path)
113+
else:
114+
print('WARNING: CXX compiler {} could not be found for export'.format(compiler))
112115

113116

114117
class InstallCompiler(Action):

builder/core/data.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ class PKG_TOOLS(Enum):
197197
'python': "/opt/python/cp39-cp39/bin/python",
198198
},
199199
},
200+
'centos': {
201+
'os': 'linux',
202+
'pkg_tool': PKG_TOOLS.YUM,
203+
'pkg_update': 'yum update -y',
204+
'pkg_install': 'yum install -y',
205+
'sudo': False,
206+
207+
'variables': {
208+
'python': 'python3'
209+
}
210+
},
200211
'windows': {
201212
'os': 'windows',
202213
'variables': {

builder/core/host.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import re
88
import sys
99

10+
from functools import lru_cache
11+
1012

1113
def current_os():
1214
if sys.platform == 'win32':
@@ -61,15 +63,9 @@ def _file_contains(path, search):
6163
return False
6264

6365

64-
# cache the result of this, since it involves a bunch of file I/O
65-
_current_host = None
66-
67-
66+
@lru_cache(1)
6867
def current_host():
6968
""" Between sys.platform or linux distro identifiers, determine the specific os """
70-
global _current_host
71-
if _current_host:
72-
return _current_host
7369

7470
def _discover_host():
7571
platform = current_os()
@@ -79,9 +75,13 @@ def _discover_host():
7975
if _file_contains('/etc/system-release', 'Bare Metal') or _file_contains('/etc/system-release', 'Amazon Linux AMI'):
8076
return 'al2012'
8177
if _file_contains('/etc/redhat-release', 'CentOS release 5.'):
82-
return 'manylinux'
78+
if os.path.exists('/opt/python/cp27-cp27m'):
79+
return 'manylinux'
80+
return 'centos'
8381
if _file_contains('/etc/redhat-release', 'CentOS Linux release 7.'):
84-
return 'manylinux'
82+
if os.path.exists('/opt/python/cp39-cp39'):
83+
return 'manylinux'
84+
return 'centos'
8585
if _file_contains('/etc/lsb-release', 'Ubuntu'):
8686
return 'ubuntu'
8787
if _file_contains('/etc/os-release', 'Debian'):
@@ -93,8 +93,7 @@ def _discover_host():
9393
return 'linux'
9494
else:
9595
return platform
96-
_current_host = _discover_host()
97-
return _current_host
96+
return _discover_host()
9897

9998

10099
def package_tool(host=current_host()):

builder/core/shell.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ def setenv(self, var, value, **kwargs):
8282
if not self.dryrun:
8383
os.environ[var] = value
8484

85+
def getenv(self, var, default=None):
86+
""" Get an environment variable """
87+
try:
88+
return os.environ[var]
89+
except:
90+
return default
91+
8592
def addpathenv(self, var, path, **kwargs):
8693
"""Add a path to an environment variable"""
8794
prev = os.getenv(var)
@@ -91,10 +98,6 @@ def addpathenv(self, var, path, **kwargs):
9198
value = path
9299
self.setenv(var, value, **kwargs)
93100

94-
def getenv(self, var):
95-
""" Get an environment variable """
96-
return os.environ[var]
97-
98101
def pushenv(self, **kwargs):
99102
""" Store the current environment on a stack, for restoration later """
100103
if not kwargs.get('quiet', False):

0 commit comments

Comments
 (0)