Skip to content

Commit 3f71db8

Browse files
authored
feat(dev): Install postgreqsl on Apple M1 to build psycopg2-binary (#28607)
Create a new target which installs different libraries via brew depending on the context. For instance, on Apple M1 machines it should installed a couple more libraries. This helps to install the psycopg2-binary package since there's no wheel for it. We also upgrade the version of it in order to avoid needing to set some CPPFLAGS & LDFLAGS. In the future, the bootstrap script and documentation should be using this target. Fixes #28606
1 parent a1dba54 commit 3f71db8

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

.github/workflows/development-environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ jobs:
4747
- name: Install prerequisites
4848
# brew can be finicky but it does not always means that the rest of the job will fail
4949
# Xcode CLI & brew are already installed, thus, no need to call xcode-select install
50-
# Sometimes, brew needs to be updated before brew bundle would work
50+
continue-on-error: true
5151
run: |
52-
brew update -q && brew bundle -q || exit 0
52+
make prerequisites
5353
5454
- name: Setup Python
5555
uses: ./.github/actions/setup-python

.github/workflows/python-deps.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ jobs:
3030
- name: Install prerequisites
3131
# brew can be finicky but it does not always means that the rest of the job will fail
3232
run: |
33-
# Needed for xmlsec
34-
brew install libxmlsec1 pkg-config
33+
make prerequisites
3534
3635
- name: Setup Python
3736
uses: ./.github/actions/setup-python

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ install-py-dev :
1919
build-platform-assets \
2020
direnv-help \
2121
upgrade-pip \
22+
prerequisites \
2223
setup-git-config :
2324
@SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh $@
2425

requirements-base.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ Pillow==8.2.0; python_version == '3.6'
3535
Pillow==8.3.1; python_version > '3.6'
3636
progressbar2==3.32.0
3737
python-rapidjson==1.4
38-
psycopg2-binary==2.8.6
38+
psycopg2-binary==2.8.6; python_version == '3.6'
39+
# For development only: This version removes needing to setting flags for Apple's M1 chipset
40+
psycopg2-binary==2.9.1; python_version > '3.6'
3941
PyJWT==2.1.0
4042
python-dateutil==2.8.1
4143
python-memcached==1.59

scripts/lib.sh

+10
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ reset-db() {
216216
apply-migrations
217217
}
218218

219+
prerequisites() {
220+
brew update -q && brew bundle -q
221+
if query-apple-m1; then
222+
# psycopg2-binary does not have an arm64 wheel, thus, we need to build it locally
223+
# by installing postgresql
224+
# See details: https://github.com/psycopg/psycopg2/issues/1286
225+
brew install postgresql
226+
fi
227+
}
228+
219229
direnv-help() {
220230
cat >&2 <<EOF
221231
If you're a Sentry employee and you're stuck or have questions, ask in #discuss-dev-tooling.

0 commit comments

Comments
 (0)