From 14b8136646fc650763189ee706bc1605ab00518f Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 20 Dec 2016 15:27:06 +0100 Subject: [PATCH 1/3] Revert "ARROW-429: Revert ARROW-379 until git-archive issues are resolved" This reverts commit 68e39c6868d449f10243707ca1a7513aaa29761f. --- dev/release/00-prepare.sh | 5 ----- python/.git_archival.txt | 1 + python/.gitattributes | 1 + python/pyarrow/__init__.py | 10 ++++++++-- python/setup.cfg | 20 ++++++++++++++++++++ python/setup.py | 23 ++--------------------- 6 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 python/.git_archival.txt create mode 100644 python/.gitattributes create mode 100644 python/setup.cfg diff --git a/dev/release/00-prepare.sh b/dev/release/00-prepare.sh index 3423a3e6c5b..00af5e77681 100644 --- a/dev/release/00-prepare.sh +++ b/dev/release/00-prepare.sh @@ -43,9 +43,4 @@ mvn release:prepare -Dtag=${tag} -DreleaseVersion=${version} -DautoVersionSubmod cd - -cd "${SOURCE_DIR}/../../python" -sed -i "s/VERSION = '[^']*'/VERSION = '${version}'/g" setup.py -sed -i "s/ISRELEASED = False/ISRELEASED = True/g" setup.py -cd - - echo "Finish staging binary artifacts by running: sh dev/release/01-perform.sh" diff --git a/python/.git_archival.txt b/python/.git_archival.txt new file mode 100644 index 00000000000..95cb3eea4e3 --- /dev/null +++ b/python/.git_archival.txt @@ -0,0 +1 @@ +ref-names: $Format:%D$ diff --git a/python/.gitattributes b/python/.gitattributes new file mode 100644 index 00000000000..00a7b00c94e --- /dev/null +++ b/python/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py index a42e39cf986..39ba4c72e7d 100644 --- a/python/pyarrow/__init__.py +++ b/python/pyarrow/__init__.py @@ -17,6 +17,14 @@ # flake8: noqa +from pkg_resources import get_distribution, DistributionNotFound +try: + __version__ = get_distribution(__name__).version +except DistributionNotFound: + # package is not installed + pass + + import pyarrow.config from pyarrow.array import (Array, @@ -43,5 +51,3 @@ DataType, Field, Schema, schema) from pyarrow.table import Column, RecordBatch, Table, from_pandas_dataframe - -from pyarrow.version import version as __version__ diff --git a/python/setup.cfg b/python/setup.cfg new file mode 100644 index 00000000000..caae3e081b6 --- /dev/null +++ b/python/setup.cfg @@ -0,0 +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. + +[build_sphinx] +source-dir = doc/ +build-dir = doc/_build diff --git a/python/setup.py b/python/setup.py index 5f448f7d507..5acdca34a08 100644 --- a/python/setup.py +++ b/python/setup.py @@ -42,27 +42,9 @@ if Cython.__version__ < '0.19.1': raise Exception('Please upgrade to Cython 0.19.1 or newer') -VERSION = '0.1.0' -ISRELEASED = False - -if not ISRELEASED: - VERSION += '.dev' - setup_dir = os.path.abspath(os.path.dirname(__file__)) -def write_version_py(filename=os.path.join(setup_dir, 'pyarrow/version.py')): - a = open(filename, 'w') - file_content = "\n".join(["", - "# THIS FILE IS GENERATED FROM SETUP.PY", - "version = '%(version)s'", - "isrelease = '%(isrelease)s'"]) - - a.write(file_content % {'version': VERSION, - 'isrelease': str(ISRELEASED)}) - a.close() - - class clean(_clean): def run(self): @@ -272,15 +254,12 @@ def get_outputs(self): return [self._get_cmake_ext_path(name) for name in self.get_names()] -write_version_py() - DESC = """\ Python library for Apache Arrow""" setup( name="pyarrow", packages=['pyarrow', 'pyarrow.tests'], - version=VERSION, zip_safe=False, package_data={'pyarrow': ['*.pxd', '*.pyx']}, # Dummy extension to trigger build_ext @@ -290,6 +269,8 @@ def get_outputs(self): 'clean': clean, 'build_ext': build_ext }, + use_scm_version = {"root": "..", "relative_to": __file__}, + setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'], install_requires=['cython >= 0.23', 'numpy >= 1.9', 'six >= 1.0.0'], description=DESC, license='Apache License, Version 2.0', From 05c44ea74fd9aab97794be000922800a30c56acf Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 20 Dec 2016 15:28:04 +0100 Subject: [PATCH 2/3] Get rid of setuptools_scm_git_archive Change-Id: Ie1bc6230e9871cd2cb2c133997da0954023ff8ac --- python/.git_archival.txt | 1 - python/.gitattributes | 1 - python/setup.py | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 python/.git_archival.txt delete mode 100644 python/.gitattributes diff --git a/python/.git_archival.txt b/python/.git_archival.txt deleted file mode 100644 index 95cb3eea4e3..00000000000 --- a/python/.git_archival.txt +++ /dev/null @@ -1 +0,0 @@ -ref-names: $Format:%D$ diff --git a/python/.gitattributes b/python/.gitattributes deleted file mode 100644 index 00a7b00c94e..00000000000 --- a/python/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -.git_archival.txt export-subst diff --git a/python/setup.py b/python/setup.py index 5acdca34a08..187c4fa7c9a 100644 --- a/python/setup.py +++ b/python/setup.py @@ -270,7 +270,7 @@ def get_outputs(self): 'build_ext': build_ext }, use_scm_version = {"root": "..", "relative_to": __file__}, - setup_requires=['setuptools_scm', 'setuptools_scm_git_archive'], + setup_requires=['setuptools_scm'], install_requires=['cython >= 0.23', 'numpy >= 1.9', 'six >= 1.0.0'], description=DESC, license='Apache License, Version 2.0', From 39753f8ada0b4cb4587ecb7bfaaa403997bc9085 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Tue, 20 Dec 2016 18:30:35 +0100 Subject: [PATCH 3/3] Infer version from java/pom.xml Change-Id: I15222a85934d68cb458ed2e05251ff98fd8f9c77 --- {cpp => python}/cmake_modules/FindParquet.cmake | 0 python/setup.py | 11 +++++++++++ 2 files changed, 11 insertions(+) rename {cpp => python}/cmake_modules/FindParquet.cmake (100%) diff --git a/cpp/cmake_modules/FindParquet.cmake b/python/cmake_modules/FindParquet.cmake similarity index 100% rename from cpp/cmake_modules/FindParquet.cmake rename to python/cmake_modules/FindParquet.cmake diff --git a/python/setup.py b/python/setup.py index 187c4fa7c9a..2e595e2dc87 100644 --- a/python/setup.py +++ b/python/setup.py @@ -257,6 +257,17 @@ def get_outputs(self): DESC = """\ Python library for Apache Arrow""" +# In the case of a git-archive, we don't have any version information +# from the SCM to infer a version. The only source is the java/pom.xml. +# +# Note that this is only the case for git-archives. sdist tarballs have +# all relevant information (but not the Java sources). +if not os.path.exists('../.git') and os.path.exists('../java/pom.xml'): + import xml.etree.ElementTree as ET + tree = ET.parse('../java/pom.xml') + version_tag = list(tree.getroot().findall('{http://maven.apache.org/POM/4.0.0}version'))[0] + os.environ["SETUPTOOLS_SCM_PRETEND_VERSION"] = version_tag.text.replace("-SNAPSHOT", "a0") + setup( name="pyarrow", packages=['pyarrow', 'pyarrow.tests'],