diff --git a/sdks/python/apache_beam/programming_guide_test.py b/sdks/python/apache_beam/programming_guide_test.py index 28d4bddd798e..1ac777bbb863 100644 --- a/sdks/python/apache_beam/programming_guide_test.py +++ b/sdks/python/apache_beam/programming_guide_test.py @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + import unittest import apache_beam as beam diff --git a/sdks/python/setup.py b/sdks/python/setup.py index 4ad898d4b7cb..719d188ed266 100644 --- a/sdks/python/setup.py +++ b/sdks/python/setup.py @@ -166,7 +166,11 @@ def cythonize(*args, **kwargs): 'embeddings', 'onnxruntime', 'langchain', - 'sentence-transformers', + # sentence-transformers 3.0+ requires transformers 4.34+ + # which uses Python 3.10+ union syntax + # Use 2.x versions for Python 3.9 compatibility with transformers <4.55.0 + 'sentence-transformers>=2.2.2,<3.0.0; python_version < "3.10"', + 'sentence-transformers>=2.2.2; python_version >= "3.10"', 'skl2onnx', 'pillow', 'pyod', @@ -581,7 +585,11 @@ def get_portability_package_data(): 'torch': ['torch>=1.9.0,<2.8.0'], 'tensorflow': ['tensorflow>=2.12rc1,<2.21'], 'transformers': [ - 'transformers>=4.28.0,<4.56.0', + # Restrict transformers to <4.55.0 for Python 3.9 compatibility + # Versions 4.55.0+ use Python 3.10+ union syntax (int | None) + # which causes TypeError on Python 3.9 + 'transformers>=4.28.0,<4.55.0; python_version < "3.10"', + 'transformers>=4.28.0,<4.56.0; python_version >= "3.10"', 'tensorflow>=2.12.0', 'torch>=1.9.0' ],