Skip to content

Commit 75ddfd6

Browse files
authored
Merge pull request #400 from WhiskyChoy/patch-3
Use container for python 3.6 compatibility issue
2 parents 238d36b + 5760e74 commit 75ddfd6

1 file changed

Lines changed: 96 additions & 30 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 96 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,113 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-20.04, windows-latest]
17+
os: [ubuntu-latest, windows-latest]
1818
python-version: ["3.6"]
19-
defaults:
20-
run:
21-
shell: bash
19+
2220
runs-on: ${{ matrix.os }}
2321
timeout-minutes: 30
22+
23+
container: ${{ matrix.os == 'ubuntu-latest' && 'ubuntu:20.04' || '' }}
24+
2425
steps:
25-
- uses: actions/checkout@v3
26+
- name: Prepare tools (Linux)
27+
if: runner.os == 'Linux'
28+
shell: bash
29+
env:
30+
DEBIAN_FRONTEND: noninteractive
31+
TZ: Etc/UTC
32+
run: |
33+
apt-get update
34+
apt-get install -y tzdata
35+
ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
36+
dpkg-reconfigure -f noninteractive tzdata
37+
38+
apt-get install -y git ca-certificates curl build-essential wget \
39+
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
40+
libffi-dev libncursesw5-dev xz-utils tk-dev liblzma-dev uuid-dev
41+
42+
git config --global --add safe.directory /__w/geatpy/geatpy
2643

44+
wget -q https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
45+
tar -xzf Python-3.6.15.tgz
46+
cd Python-3.6.15
47+
./configure --prefix=/opt/python36 --enable-shared --with-ensurepip=install
48+
make -j$(nproc)
49+
make install
50+
cd ..
51+
52+
echo "/opt/python36/lib" > /etc/ld.so.conf.d/python36.conf
53+
ldconfig
54+
55+
ln -sf /opt/python36/bin/python3.6 /usr/local/bin/python3.6
56+
python3.6 -m pip install --upgrade pip
57+
58+
- uses: actions/checkout@v3
59+
with:
60+
fetch-depth: 0
61+
2762
- name: Fetch core files from open_dev branch
63+
shell: bash
2864
run: |
2965
git fetch origin open_dev
3066
git checkout origin/open_dev -- _core
31-
32-
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v3
67+
68+
- name: Set up Python 3.6 (Windows)
69+
if: runner.os == 'Windows'
70+
uses: actions/setup-python@v2
3471
with:
35-
python-version: ${{ matrix.python-version }}
36-
37-
- name: Install dependencies
38-
run: |
39-
pip install cython setuptools
40-
pip install -r requirements.txt
41-
pip install pytest
42-
43-
- name: Copy core files to geatpy/core
44-
run: |
45-
if [[ "$RUNNER_OS" == "Windows" ]]; then
46-
OS_DIR="Windows"
47-
else
48-
OS_DIR="Linux"
49-
fi
50-
PY_VERSION="v${{ matrix.python-version }}"
72+
python-version: "3.6"
73+
74+
- name: Install dependencies (Linux)
75+
if: runner.os == 'Linux'
76+
shell: bash
77+
run: |
78+
python3.6 -m pip install cython setuptools
79+
python3.6 -m pip install -r requirements.txt
80+
python3.6 -m pip install pytest
81+
82+
- name: Install dependencies (Windows)
83+
if: runner.os == 'Windows'
84+
shell: pwsh
85+
run: |
86+
python -m pip install cython setuptools
87+
python -m pip install -r requirements.txt
88+
python -m pip install pytest
89+
90+
- name: Copy core files to geatpy/core (Linux)
91+
if: runner.os == 'Linux'
92+
shell: bash
93+
run: |
5194
mkdir -p geatpy/core
52-
cp -r "_core/${OS_DIR}/lib64/${PY_VERSION}/"* geatpy/core/
53-
54-
- name: Build
95+
cp -r "_core/Linux/lib64/v3.6/"* geatpy/core/
96+
97+
- name: Copy core files to geatpy/core (Windows)
98+
if: runner.os == 'Windows'
99+
shell: pwsh
100+
run: |
101+
New-Item -ItemType Directory -Force -Path geatpy/core | Out-Null
102+
Copy-Item -Recurse -Force "_core\Windows\lib64\v3.6\*" "geatpy\core\"
103+
104+
- name: Build (Linux)
105+
if: runner.os == 'Linux'
106+
shell: bash
107+
run: python3.6 setup.py install
108+
109+
- name: Build (Windows)
110+
if: runner.os == 'Windows'
111+
shell: pwsh
55112
run: python setup.py install
56-
57-
- name: Test with pytest
113+
114+
- name: Test with pytest (Linux)
115+
if: runner.os == 'Linux'
116+
shell: bash
117+
run: |
118+
python3.6 -m geatpy --version
119+
python3.6 -m pytest
120+
121+
- name: Test with pytest (Windows)
122+
if: runner.os == 'Windows'
123+
shell: pwsh
58124
run: |
59125
python -m geatpy --version
60-
pytest
126+
python -m pytest

0 commit comments

Comments
 (0)