oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
339 stars 67 forks source link

Conda support #21

Closed bchen290 closed 2 years ago

bchen290 commented 2 years ago

The original cx_Oracle had conda packages built for it. Will there eventually be conda packages built for this package? Thank you!

cjbj commented 2 years ago

This would a great idea for a community contribution. https://conda-forge.org/docs/maintainer/adding_pkgs.html

Oracle wasn't involved in adding the conda recipe for cx_Oracle.

xylar commented 2 years ago

I'm working on this: https://github.com/conda-forge/staged-recipes/pull/19367

However, I'm not having any luck getting oracledb to build with clang on OSX:

  x86_64-apple-darwin13.4.0-clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/runner/mambaforge/conda-bld/oracledb_1655972733475/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/include -fPIC -O2 -isystem /Users/runner/mambaforge/conda-bld/oracledb_1655972733475/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/include -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/runner/mambaforge/conda-bld/oracledb_1655972733475/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/include -fdebug-prefix-map=/Users/runner/mambaforge/conda-bld/oracledb_1655972733475/work=/usr/local/src/conda/oracledb-1.0.1 -fdebug-prefix-map=/Users/runner/mambaforge/conda-bld/oracledb_1655972733475/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_=/usr/local/src/conda-prefix -D_FORTIFY_SOURCE=2 -isystem /Users/runner/mambaforge/conda-bld/oracledb_1655972733475/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/include -mmacosx-version-min=10.9 -I/Users/runner/mambaforge/conda-bld/oracledb_1655972733475/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/include/python3.8 -c src/oracledb/base_impl.c -o build/temp.macosx-10.9-x86_64-cpython-38/src/oracledb/base_impl.o -target arm64-apple-macos
  clang-13: error: the clang compiler does not support '-march=core2'

Suggestions in my PR would be welcome. Otherwise, I can open another issue.

cjbj commented 2 years ago

Excellent!

On macOS we are building with Universal2 Python binaries, and also doing a Python 3.7 build on Intel where there isn't a Universal 2 binary. The latter currently needs export ARCHFLAGS="-arch x86_64" before the build (as noted in the install doc). Try something like that.

You could also try this patch which will be landing on GitHub soon. With this patch we won't need to explicitly set ARCHFLAGS.

---
 setup.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index 7a37a6d..b4eaaed 100644
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,7 @@
 import os
 import platform
 import sys
+import sysconfig
 from setuptools import setup, Extension

 # base source directory
@@ -61,11 +62,10 @@ thin_depends = [os.path.join(impl_dir, n) \
 thin_depends.append(base_pxd)

 # if the platform is macOS, add arguments required for cross-compilation for
-# both x86_64 and arm64 architectures.
-# Use a Universal 2 Python binary to build, or set an archtecture
-# before building, e.g. export ARCHFLAGS="-arch x86_64"
+# both x86_64 and arm64 architectures if the python interpreter is a
+# universal2 version.
 extra_compile_args = []
-if sys.platform == "darwin":
+if sys.platform == "darwin" and "universal2" in sysconfig.get_platform():
     if platform.machine() == "x86_64":
         target = "arm64-apple-macos"
     else:
-- 
2.36.1
xylar commented 2 years ago

Great, thanks! I'll add that patch.

xylar commented 2 years ago

@cjbj, that worked like a charm!

xylar commented 2 years ago

https://github.com/conda-forge/staged-recipes/pull/19367 has now been merged. A conda-forge package for oracledb should be available in a couple of hours.

bchen290 commented 2 years ago

Thank you!

xylar commented 2 years ago

Okay, I think this issue can be closed. The following worked for me:

conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -y -n test oracledb
conda activate test
python -c "import oracledb"
anthony-tuininga commented 2 years ago

Great! Thanks, @xylar!

anthony-tuininga commented 2 years ago

Note that the patch that Chris mentioned and you included in your recipe is already on GitHub -- and will be included in the next release. :-)

cjbj commented 2 years ago

@xylar Thank you - that's greatly appreciated.

As a 'heads up' we will probably also create Linux ARM wheels in that next release Anthony mentioned

xylar commented 2 years ago

Okay, we'll also plan for arm builds soon, then.

I see that we're not able to build for PyPy: https://github.com/conda-forge/oracledb-feedstock/pull/2#issuecomment-1164742516 Is PyPy something you want to support?

cjbj commented 2 years ago

We have a lot to add to the thin driver, and PyPy isn't something we've discussed. Even for cx_Oracle, PyPy wasn't a project of ours. Of course if you have the skills to help, I'm sure the community would be grateful.

xylar commented 2 years ago

@cjbj, that's fine. I don't have the skills to help on that. I'll just put https://github.com/conda-forge/oracledb-feedstock/pull/2#issuecomment-1164742516 in draft mode and that will indicate that support for PyPy isn't expected anytime soon.

cjbj commented 2 years ago

@xylar no problems. You've taken the project a long way already - thank you

eudinaesis commented 1 year ago

Sorry, newbie question here @xylar . I'm a little confused -- reading this, it looks like there should be universal architecture support, but at I only see osx-64 -- that's Intel, right? When I forced an install with conda install -c conda-forge/osx-64 oracledb it replaced my openssl with an Intel version. Am I doing something wrong, or is there only an Intel build in Conda-forge now?

xylar commented 1 year ago

@eudinaesis, you are right, we haven't build for ARM64 yet. I don't know why not. Usually, a bot brings in those new architectures automatically but it obviously hasn't happened. I can do my best to migrate over to them manually.

xylar commented 1 year ago

@eudinaesis, please feel free to follow along at https://github.com/conda-forge/oracledb-feedstock/pull/11

eudinaesis commented 1 year ago

@eudinaesis, you are right, we haven't build for ARM64 yet. I don't know why not. Usually, a bot brings in those new architectures automatically but it obviously hasn't happened. I can do my best to migrate over to them manually.

Wow, thanks so much for the quick response!

xylar commented 1 year ago

It's looking good. Try in an hour or 2 and the osx-arm64 package should be there.

eudinaesis commented 1 year ago

It's looking good. Try in an hour or 2 and the osx-arm64 package should be there.

It's there, and I successfully installed it and connected to a database. You are a hero! Thanks so much.