Skip to content

Commit

Permalink
Merge f17e199 into 7f7b765
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfix committed Apr 17, 2021
2 parents 7f7b765 + f17e199 commit 4530df9
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 175 deletions.
1 change: 0 additions & 1 deletion .github/build/macos/cpymad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ _() {
{ set -x; return $exitcode; } 2>/dev/null
}

build 2.7
build 3.5
build 3.6
build 3.7
Expand Down
2 changes: 1 addition & 1 deletion .github/build/manylinux1/cpymad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $PY/pip install cython
$PY/python setup.py sdist
$PY/pip uninstall cython -y

for PYBIN in /opt/python/*/bin; do
for PYBIN in /opt/python/cp3*/bin; do
"${PYBIN}/pip" install -U setuptools
"${PYBIN}/pip" wheel dist/*.tar.gz --no-deps -w dist/
done
Expand Down
48 changes: 15 additions & 33 deletions .github/build/msys2/cpymad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,15 @@ set -ex

main()
{
ARCH=$1
MADXDIR=${2:-$MADXDIR}

# Create python environments:
_ conda create -qyf -n py27 python=2.7 wheel cython -c anaconda
_ conda create -qyf -n py35 python=3.5 wheel cython -c anaconda
_ conda create -qyf -n py36 python=3.6 wheel cython -c anaconda
_ conda create -qyf -n py37 python=3.7 wheel cython -c anaconda
_ conda create -qyf -n py38 python=3.8 wheel cython -c anaconda
_ conda create -qyf -n py39 python=3.9 wheel cython -c anaconda

# Build cpymad wheels:
if [[ $ARCH == i686 ]]; then
CFLAGS=
build py27 27 win32-2.7 ''
build py35 35 win32-3.5 .cp35-win32
build py36 36 win32-3.6 .cp36-win32
build py37 37 win32-3.7 .cp37-win32
build py38 38 win32-3.8 .cp38-win32
build py39 39 win32-3.9 .cp39-win32
else
CFLAGS=-DMS_WIN64
build py27 27 win-amd64-2.7 ''
build py35 35 win-amd64-3.5 .cp35-win_amd64
build py36 36 win-amd64-3.6 .cp36-win_amd64
build py37 37 win-amd64-3.7 .cp37-win_amd64
build py38 38 win-amd64-3.8 .cp38-win_amd64
build py39 39 win-amd64-3.9 .cp39-win_amd64
fi
MADXDIR=${1:-$MADXDIR}
CFLAGS=-DMS_WIN64
PLATFORM=win-amd64

build 3.5
build 3.6
build 3.7
build 3.8
build 3.9
}

# We manually build the C extension using our msys gcc because setuptools is
Expand All @@ -45,10 +25,11 @@ main()
# and cpymad!
build()
{
py_env=$1
py_ver=$2
dir_tag=$3
file_tag=$4
py_dot=$1
py_ver=${py_dot/./}
py_env=py${py_ver}
dir_tag=${PLATFORM}-${py_dot}
file_tag=.cp${py_ver}-${PLATFORM/-/_}

# Ensure that cython code and extension module will be rebuilt since the
# cython code is partially incompatible between python versions:
Expand All @@ -60,6 +41,7 @@ build()
# `.pyd` in $libdir) to prevent the final `python setup.py bdist_wheel`
# command from trying trying to perform either of these steps with MSVC.

_ conda create -qyf -n $py_env python=$py_dot wheel cython -c anaconda
_ conda activate $py_env
tempdir=build/temp.$dir_tag/Release/src/cpymad
libdir=build/lib.$dir_tag/cpymad
Expand Down
53 changes: 14 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ jobs:
build_linux:
name: "Build: Linux"
runs-on: ubuntu-latest
strategy:
matrix:
arch: [i686, x86_64]
steps:
- uses: actions/checkout@v2
- run: echo "MADX_VERSION=$(cat MADX_VERSION)" >> $GITHUB_ENV
Expand All @@ -23,7 +20,7 @@ jobs:
path: ../MAD-X/dist
key: "\
madx-${{ env.MADX_VERSION }}-\
linux-${{ matrix.arch }}-\
linux-\
patches-${{ hashFiles('.github/patch/*') }}-\
scripts-${{ hashFiles('.github/build/manylinux1/madx*') }}\
"
Expand All @@ -40,29 +37,26 @@ jobs:
docker run --rm --init \
-w /mnt/MAD-X \
-v `pwd`/..:/mnt \
quay.io/pypa/manylinux1_${{ matrix.arch }} \
quay.io/pypa/manylinux1_x86_64 \
../cpymad/.github/build/manylinux1/madx.sh
- name: Build cpymad wheels
run: |
docker run --rm --init \
-w /mnt/cpymad \
-v `pwd`/..:/mnt \
quay.io/pypa/manylinux1_${{ matrix.arch }} \
quay.io/pypa/manylinux1_x86_64 \
.github/build/manylinux1/cpymad.sh
- name: Upload cpymad wheels
uses: actions/upload-artifact@v2
with:
name: dist-linux-${{ matrix.arch }}
name: dist-linux
path: dist

build_windows:
name: "Build: Windows"
runs-on: windows-latest
strategy:
matrix:
arch: [i686, x86_64]
defaults:
run:
shell: bash -l {0}
Expand All @@ -79,7 +73,7 @@ jobs:
path: ../MAD-X/dist
key: "\
madx-${{ env.MADX_VERSION }}-\
windows-${{ matrix.arch }}-\
windows-\
patches-${{ hashFiles('.github/patch/*') }}-\
scripts-${{ hashFiles('.github/build/manylinux1/madx*') }}\
"
Expand All @@ -93,10 +87,7 @@ jobs:
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
architecture: ${{ matrix.arch == 'i686' && 'x86' || 'x64' }}
python-version: '3.8'
# must be explicitly specified if architecture is not x64:
miniconda-version: latest

- name: Install build tools
run: |
Expand All @@ -109,20 +100,17 @@ jobs:

- name: Build cpymad wheels
# We need 'bash -l' to make conda available within the script:
run: bash -l .github/build/msys2/cpymad.sh ${{ matrix.arch }} ../MAD-X/dist
run: bash -l .github/build/msys2/cpymad.sh ../MAD-X/dist

- name: Upload cpymad wheels
uses: actions/upload-artifact@v2
with:
name: dist-windows-${{ matrix.arch }}
name: dist-windows
path: dist

build_macos:
name: "Build: MacOS"
runs-on: macos-latest
strategy:
matrix:
arch: [x86_64]
steps:
- uses: actions/checkout@v2
- run: echo "MADX_VERSION=$(cat MADX_VERSION)" >> $GITHUB_ENV
Expand All @@ -136,7 +124,7 @@ jobs:
path: ../MAD-X/dist
key: "\
madx-${{ env.MADX_VERSION }}-\
macos-${{ matrix.arch }}-\
macos-\
patches-${{ hashFiles('.github/patch/*') }}-\
scripts-${{ hashFiles('.github/build/macos/madx*') }}\
"
Expand All @@ -156,14 +144,11 @@ jobs:
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
architecture: ${{ matrix.arch == 'i686' && 'x86' || 'x64' }}
python-version: '3.8'
# must be explicitly specified if architecture is not x64:
miniconda-version: latest

- name: Build cpymad wheels
# We need 'bash -l' to make conda available within the script:
run: bash -l .github/build/macos/cpymad.sh ${{ matrix.arch }} ../MAD-X/dist
run: bash -l .github/build/macos/cpymad.sh ../MAD-X/dist

- name: Fixup wheel dependencies
run: |
Expand All @@ -174,7 +159,7 @@ jobs:
- name: Upload cpymad wheels
uses: actions/upload-artifact@v2
with:
name: dist-macos-${{ matrix.arch }}
name: dist-macos
path: dist

test:
Expand All @@ -186,15 +171,7 @@ jobs:
# 32bit python is currently only available on windows in
# actions/setup-python:
os: [linux, windows, macos]
arch: [x86_64]
python: ['2.7', '3.5', '3.6', '3.7', '3.8', '3.9']
include:
- {os: windows, arch: i686, python: '2.7'}
- {os: windows, arch: i686, python: '3.5'}
- {os: windows, arch: i686, python: '3.6'}
- {os: windows, arch: i686, python: '3.7'}
- {os: windows, arch: i686, python: '3.8'}
- {os: windows, arch: i686, python: '3.9'}
python: ['3.5', '3.6', '3.7', '3.8', '3.9']

defaults:
run:
Expand All @@ -205,12 +182,11 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch == 'i686' && 'x86' || 'x64' }}

- name: Download cpymad wheels
uses: actions/download-artifact@v2
with:
name: dist-${{ matrix.os }}-${{ matrix.arch }}
name: dist-${{ matrix.os }}
path: dist

- name: Install cpymad from wheel
Expand Down Expand Up @@ -245,11 +221,10 @@ jobs:
ref: gh-pages
- uses: actions/setup-python@v2
with:
architecture: 'x64'
python-version: '3.x'
- uses: actions/download-artifact@v2
with:
name: dist-linux-x86_64
name: dist-linux
path: dist

- run: pip install cpymad[doc] -f dist
Expand Down Expand Up @@ -286,7 +261,7 @@ jobs:
- name: Merge artifacts to single folder
run: |
mv dist/dist-*/*.whl dist/
mv dist/dist-linux-x86_64/*.tar.gz dist/
mv dist/dist-linux/*.tar.gz dist/
- name: Install twine
run: pip install twine
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ classifiers =
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX :: Linux
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Topic :: Scientific/Engineering :: Physics
long_description_content_type = text/x-rst

[options]
zip_safe = false
include_package_data = true
python_requires = >=2.7
python_requires = >=3.5
install_requires =
importlib_resources
numpy
Expand Down
1 change: 0 additions & 1 deletion src/cpymad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import unicode_literals

__title__ = 'cpymad'
Expand Down
Loading

0 comments on commit 4530df9

Please sign in to comment.