summaryrefslogtreecommitdiff
path: root/.github/workflows/wheel-builder.yml
blob: cf4c7c0257254fe5174e2beee39dac78a0fc2182 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Wheel Builder
permissions:
  contents: read
on:
  workflow_dispatch:
    inputs:
      version:
        description: The version to build
        required: false
  pull_request:
    paths:
      - .github/workflows/wheel-builder.yml
      - setup.py
      - setup.cfg
      - pyproject.toml


jobs:
  manylinux:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        PYTHON:
          - { VERSION: "cp36-cp36m", ABI_VERSION: 'cp36' }
          - { VERSION: "pp37-pypy37_pp73" }
          - { VERSION: "pp38-pypy38_pp73" }
          - { VERSION: "pp39-pypy39_pp73" }
        MANYLINUX:
          - { CONTAINER: "cryptography-manylinux2014:x86_64", NAME: "manylinux2014" }
          - { CONTAINER: "cryptography-manylinux_2_28:x86_64", NAME: "manylinux_2_28" }
          - { CONTAINER: "cryptography-musllinux_1_1:x86_64", NAME: "musllinux_1_1" }
        exclude:
          # There are no readily available musllinux PyPy distributions
          - PYTHON: { VERSION: "pp37-pypy37_pp73" }
            MANYLINUX: { NAME: "musllinux_1_1", CONTAINER: "cryptography-musllinux_1_1:x86_64" }
          - PYTHON: { VERSION: "pp38-pypy38_pp73" }
            MANYLINUX: { NAME: "musllinux_1_1", CONTAINER: "cryptography-musllinux_1_1:x86_64"}
          - PYTHON: { VERSION: "pp39-pypy39_pp73" }
            MANYLINUX: { NAME: "musllinux_1_1", CONTAINER: "cryptography-musllinux_1_1:x86_64"}
    name: "${{ matrix.PYTHON.VERSION }} for ${{ matrix.MANYLINUX.NAME }}"
    container: ghcr.io/pyca/${{ matrix.MANYLINUX.CONTAINER }}
    steps:
      - uses: actions/checkout@v3.5.0
        with:
          # The tag to build or the tag received by the tag event
          ref: ${{ github.event.inputs.version || github.ref }}
      - run: /opt/python/${{ matrix.PYTHON.VERSION }}/bin/python -m venv .venv
      - name: Install python dependencies
        run: .venv/bin/pip install -U pip wheel setuptools-rust
      - name: Make sdist
        run: .venv/bin/python setup.py sdist
      - run: tar zxvf dist/bcrypt*.tar.gz && mkdir tmpwheelhouse
      - name: Build the wheel
        run: |
          if [ -n "${{ matrix.PYTHON.ABI_VERSION }}" ]; then
              PY_LIMITED_API="--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}"
          fi
          cd bcrypt* && ../.venv/bin/python setup.py bdist_wheel $PY_LIMITED_API && mv dist/bcrypt*.whl ../tmpwheelhouse
        env:
          RUSTUP_HOME: /root/.rustup
      - run: auditwheel repair tmpwheelhouse/bcrypt*.whl -w wheelhouse/
      - run: .venv/bin/pip install bcrypt --no-index -f wheelhouse/
      - run: |
          .venv/bin/python -c "import bcrypt; password = b'super secret password';hashed = bcrypt.hashpw(password, bcrypt.gensalt());bcrypt.checkpw(password, hashed)"

      - run: mkdir bcrypt-wheelhouse
      - run: mv wheelhouse/bcrypt*.whl bcrypt-wheelhouse/
      - uses: actions/upload-artifact@v3.1.2
        with:
          name: "bcrypt-${{ github.event.inputs.version }}-${{ matrix.MANYLINUX.NAME }} -${{ matrix.PYTHON.ABI_VERSION }}"
          path: bcrypt-wheelhouse/

  macos:
    runs-on: macos-11
    strategy:
      matrix:
        PYTHON:
          - VERSION: '3.10'
            ABI_VERSION: 'cp36'
            DOWNLOAD_URL: 'https://www.python.org/ftp/python/3.10.1/python-3.10.1-macos11.pkg'
            BIN_PATH: '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3'
    name: "Python ${{ matrix.PYTHON.VERSION }} for ABI ${{ matrix.PYTHON.ABI_VERSION }} on macOS"
    steps:
      - uses: actions/checkout@v3.5.0
        with:
          # The tag to build or the tag received by the tag event
          ref: ${{ github.event.inputs.version || github.ref }}
          persist-credentials: false
      - run: |
          curl "${{ matrix.PYTHON.DOWNLOAD_URL }}" -o python.pkg
          sudo installer -pkg python.pkg -target /
      - uses: dtolnay/rust-toolchain@52e69531e6f69a396bc9d1226284493a5db969ff
        with:
          toolchain: stable
          # Add the arm64 target in addition to the native arch (x86_64)
          target: aarch64-apple-darwin

      - run: ${{ matrix.PYTHON.BIN_PATH }} -m venv venv
      - run: venv/bin/pip install -U pip wheel setuptools-rust
      - name: Make sdist
        run: venv/bin/python setup.py sdist
      - run: tar zxvf dist/bcrypt*.tar.gz && mkdir wheelhouse
      - name: Build the wheel
        run: cd bcrypt* && ../venv/bin/python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/bcrypt*.whl ../wheelhouse
        env:
          PYTHON_VERSION: ${{ matrix.PYTHON.ABI_VERSION }}
          MACOSX_DEPLOYMENT_TARGET: '10.10'
          CFLAGS: '-arch arm64 -arch x86_64'
          ARCHFLAGS: '-arch arm64 -arch x86_64'
          _PYTHON_HOST_PLATFORM: 'macosx-10.9-universal2'
      - run: venv/bin/pip install -f wheelhouse --no-index bcrypt
      - run: |
          venv/bin/python -c "import bcrypt;password = b'super secret password';hashed = bcrypt.hashpw(password, bcrypt.gensalt());bcrypt.checkpw(password, hashed)"

      - run: mkdir bcrypt-wheelhouse
      - run: mv wheelhouse/bcrypt*.whl bcrypt-wheelhouse/
      - uses: actions/upload-artifact@v3.1.2
        with:
          name: "bcrypt-${{ github.event.inputs.version }}-macOS-${{ matrix.PYTHON.ABI_VERSION }}"
          path: bcrypt-wheelhouse/

  windows:
    runs-on: windows-latest
    strategy:
      matrix:
        WINDOWS:
          - {ARCH: 'x86', RUST_TRIPLE: 'i686-pc-windows-msvc'}
          - {ARCH: 'x64', RUST_TRIPLE: 'x86_64-pc-windows-msvc'}
        PYTHON:
          - {VERSION: "3.6", ABI_VERSION: "cp36"}
    name: "${{ matrix.PYTHON.VERSION }} ${{ matrix.PYTHON.ABI_VERSION }} ${{ matrix.WINDOWS.ARCH }}"
    steps:
      - uses: actions/checkout@v3.5.0
        with:
          # The tag to build or the tag received by the tag event
          ref: ${{ github.event.inputs.version || github.ref }}
          persist-credentials: false
      - name: Setup python
        uses: actions/setup-python@v4.5.0
        with:
          python-version: ${{ matrix.PYTHON.VERSION }}
          architecture: ${{ matrix.WINDOWS.ARCH }}
      - uses: dtolnay/rust-toolchain@52e69531e6f69a396bc9d1226284493a5db969ff
        with:
          toolchain: stable
          target: ${{ matrix.WINDOWS.RUST_TRIPLE }}

      - run: python -m pip install -U pip wheel setuptools-rust
      - name: Make sdist
        run: python setup.py sdist
      - run: tar zxvf dist/bcrypt*.tar.gz && mkdir wheelhouse
        shell: bash
      - run: cd bcrypt* && python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/bcrypt*.whl ../wheelhouse
      - run: pip install -f wheelhouse --no-index bcrypt
      - run: |
          python -c "import bcrypt; password = b'super secret password';hashed = bcrypt.hashpw(password, bcrypt.gensalt());bcrypt.checkpw(password, hashed)"

      # TODO: can we setup another python and test in the same job? this would catch bad linking problems (e.g. build and test on py36, but then install py38 and see if it works
      - run: mkdir bcrypt-wheelhouse
      - run: move wheelhouse\bcrypt*.whl bcrypt-wheelhouse\
      - uses: actions/upload-artifact@v3.1.2
        with:
          name: "bcrypt-${{ github.event.inputs.version }}-${{ matrix.WINDOWS.ARCH }}-${{ matrix.PYTHON.ABI_VERSION }}"
          path: bcrypt-wheelhouse\