-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
psycopg2-binary support for M1 chipset #1286
Comments
Hello @armenzg A change to fix the CPPFLAGS/LDFLAGS has already landed in master (52cd944), so that will not be needed anymore from next release on. Are you able to fix https://github.com/psycopg/psycopg2/blob/master/scripts/build/build_macos.sh in order to build wheels working on arm too? Thank you! |
Hi Daniel, Do you (or anyone reading this later) know if you need an Arm device in order to build the wheel? Does this mean that there would be need for Arm infra? (I don't think GH has such kind of runners; maybe require a custom runner?) Or a developer building it in their machine and transferring the wheel to whoever can release it? I'm very unfamiliar with wheels, thus, my questions might be rather naive. Best wishes, |
I am unfamiliar with the M1 chipset so I might be naive as well. But I believe the Mac OS toolkit can cross-compile. |
Hello. Could anyone tell how to get this paackage to work on a M1 machine? What are the step-by-step workarounds? Thank you! |
@pedromassango Hi Pedro,
❯ brew install postgresql
# If you open a new terminal tab you will see that pg_config is available
❯ export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
❯ export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L${HOME}/.pyenv/versions/3.8.10/lib"
❯ python -V
Python 3.8.10
❯ pip install psycopg2-binary==2.8.6 |
This uses [cibuildwheel](https://cibuildwheel.readthedocs.io/en/stable/) in order to cross-compile the arm64 wheels for Python 3.8, 3.9 & 3.10. Fixes psycopg#1286
@pedromassango you will not need the |
I will be away for few months starting in November so I don't know if I will be able to contribute a fully tested script, however, I have a draft in here: I uploaded the produced wheel to a Google Cloud storage that I make public. Other engineers can |
i also figured out how to install without postgresql. My setup is for macOS monterey 12.1.0 and using venv i got pg_config not found with python 3.9.9 My answer is here at StackOverflow https://stackoverflow.com/a/70482055/80353 |
I've uploaded a binary here: https://github.com/fikisipi/psycopg2-m1 |
@fikisipi any reason why you don't contribute a merge request to this project? |
@dvarrazzo I'd like to, but you'll need to set up a private GitHub Action runner in the repo settings. In my repo I booted an Action Runner on my own machine as you can see in the job run log, but for trust purposes (unless the build is deterministic and a checksum is enough?) I think we should rent a scaleway m1 instance for a day. We can further use the native Action to provision the m1 runner that will produce the binary in a transparent way. |
@fikisipi Trust is an important matter, yes, so I don't think it is wise to distribute packages in the project name which are built by third parties. I don't doubt about your good faith or intention but I wouldn't want to create a precedent for others, while at the same time desensitise people into no longer auditing the quality of the packages they install. Recent events of the guy who intentionally messed up the npm packages he maintained should be a warning call for users and a responsibility call for package authors. As such, I would kindly ask you to request pypi to withdraw the package you distributed. I'm happy to look together with you into how to build these packages reliably and distribute them as psycopg2-binary. There is also the problem that it's impossible to create a portable requirements file if the distribution package name is different - a problem we already have with the psycopg2/psycopg2-binary packages. I don't wish to make this more complex for users. Thank you for your understanding and please know that I appreciate your gesture :) |
@dvarrazzo I removed the pypi release, your arguments are completely valid 👍 Would you like me to create a pull request here with a GitHub action for provisioning a M1 build job running on Scaleway |
Hello @fikisipi Thank you very much for your understanding: I appreciate it. I got in touch with Scaleway and asked if they would be available to sponsor the Psycopg project by offering us their service in order to build the packages, otherwise to give us a quote for their service. I assume we can foot a bill of $2 per release. I know well that Apple is short on petty cash and they absolutely need the money from our project to survive, I am very sympathetic of their cause. If, in turn, some of the users interested in the M1 packages would like to contribute to 💜 sponsor the project, it would be great. Thank you very much! |
@dvarrazzo Looking at it, pypa/cibuildwheel seems to have some kind of cross-compilation command for Apple Silicon: I'll try that as well. I see @armenzg tried that in his fork but I can't see if there has been progress. |
- Upgraded black so `typed-ast` install stopped erroring: python/typed_ast#146 - Upgraded pyscopg2 to use the binary version so it would install properly: psycopg/psycopg2#1286 (comment) - Migrated from node-sass to dart sass and fixed a backwards incompatible syntax error. node-sass always has issues installing. sass/dart-sass#879 - fix issue with web pack dev server proxy: https://stackoverflow.com/a/71355040/3720597 ``` Compiled successfully! The app is running at: http://localhost:3000/ Note that the development build is not optimized. To create a production build, use yarn run build. Proxy error: Could not proxy request /favicon.ico from localhost:3000 to http://localhost:8000. See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED). ```
Note: this adds a lot of extra installation and possible bloat to the image. Until psycopg2-binary is available for M1, maybe we could provide a custom wheel. See psycopg/psycopg2#1286 for details on pyscopg2-binary availability for M1.
I have crated some test binary packages for Apple M1. Please test them using:
and verify that they work, e.g.
|
Thanks 👍, this package also works on my M1. Can I use temporary this "test" version in my project @dvarrazzo is it planned to fix https://pypi.org/project/psycopg2-binary/#files version ? |
@stephane-klein thank you for testing. Yes, of course the plan is to make these wheels available on PyPI. |
The test binary package you've made for Apple silicon seem to be working well for me. Thank you! |
Hi everyone, is there a timeline for when will this happen? The fact that I cannot install the binary is really annoying right now. If there is something to do that just takes time and not a lot of knowledge in psycopg2 I am more than happy to help with it 😊 |
@stephane-klein have you been able to use it on your requirements file? i've tried it in a couple of ways - e.g.
pip 22.2.1 (python 3.10.5). it works fine when installing manually (as suggested above). |
The build scripts are merged to master. For information about the packages release please see #1482. |
This is the unique way helped me resolved this issue on my Mac M1, I have google searched for a week kakaka |
Thx a lot. It solves my issue. |
@dvarrazzo Works well. Hope to see it in prod soon. |
@takecare try specifying the wheel in requirements.txt, eg: for python 3.9
|
Works great thanks! For poetry users, you can: Add diff --git a/pyproject.toml b/pyproject.toml
index a886bbd..194f07f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,13 +5,18 @@
description = ""
license = "MIT"
+[[tool.poetry.source]]
+name = "test-pypi"
+url = "https://test.pypi.org/simple"
+secondary = true
+
[tool.poetry.dependencies]
python = "^3.10" And install from
|
thanks for the poetry solve @gnuletik 💯 |
This worked for me as well. Do we still need the |
psycopg#1286 is now closed.
I installed using: |
Hello all,
With a big of guidance I'm happy to contribute a PR.
For now, let me document the current situation for any other M1 users. Please do correct me if I got the details wrong!
Python 3.8.10 is the first 3.8 version with support for M1 chipset (see bug). Older versions of pyenv do not have access to Python 3.8.10 (some details in here).
If you try to install
psycopg2_binary
and expect a wheel, it is not currently available.There's the
SYSTEM_VERSION_COMPAT=1
trick to pretend to be 10.6 instead of 11.x, however, the architecture still returnsarm64
.If you don't have a wheel then you need to build from source. See the log [1] at the bottom of this comment.
In order to have the libraries to build it, I took these steps which are based on this post:
After that, it is possible to build the wheel
Did I do this right? How can I help to have a release that includes an arm64 wheel?
[1]
The text was updated successfully, but these errors were encountered: