Repository: arrow Updated Branches: refs/heads/master 8814d62b1 -> 73455b56f (forced update)
ARROW-430: Improved version handling This reintroduces `setuptools_scm` versioning for git clones and sdists/wheels. git-archives are handled by a separate chunk of code that will infer the version from the `pom.xml` As in the Maven world, always the next to-be-released version is specified and Python PEP 440 development versions are based on the previous release, it used the most minimal pre-release version specified there. I would suggest to keep the conda package versioning as it is currently, i.e. manually set it to 0.1.0postX. Also: I would rather not parse the Maven XML but that is the most simple way currently to ensure that the versioning system is in a state where we can still make releases with the Maven release plugin. Author: Uwe L. Korn <uw...@xhochy.com> Closes #248 from xhochy/ARROW-430 and squashes the following commits: 39753f8 [Uwe L. Korn] Infer version from java/pom.xml 05c44ea [Uwe L. Korn] Get rid of setuptools_scm_git_archive 14b8136 [Uwe L. Korn] Revert "ARROW-429: Revert ARROW-379 until git-archive issues are resolved" Change-Id: I4f6d291e63b2518af47c2a81049aa24a38c92821 Project: http://git-wip-us.apache.org/repos/asf/arrow/repo Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/73455b56 Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/73455b56 Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/73455b56 Branch: refs/heads/master Commit: 73455b56f705c3c11d3c29447082641dcab4c63a Parents: f6bf112 Author: Uwe L. Korn <uw...@xhochy.com> Authored: Tue Dec 20 14:10:21 2016 -0500 Committer: Wes McKinney <wes.mckin...@twosigma.com> Committed: Tue Dec 20 16:19:26 2016 -0500 ---------------------------------------------------------------------- cpp/cmake_modules/FindParquet.cmake | 109 ---------------------------- dev/release/00-prepare.sh | 5 -- python/cmake_modules/FindParquet.cmake | 109 ++++++++++++++++++++++++++++ python/pyarrow/__init__.py | 10 ++- python/setup.cfg | 20 +++++ python/setup.py | 34 ++++----- 6 files changed, 150 insertions(+), 137 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/arrow/blob/73455b56/cpp/cmake_modules/FindParquet.cmake ---------------------------------------------------------------------- diff --git a/cpp/cmake_modules/FindParquet.cmake b/cpp/cmake_modules/FindParquet.cmake deleted file mode 100644 index 7445e09..0000000 --- a/cpp/cmake_modules/FindParquet.cmake +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright 2012 Cloudera Inc. -# -# Licensed 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. - -# - Find PARQUET (parquet/parquet.h, libparquet.a, libparquet.so) -# This module defines -# PARQUET_INCLUDE_DIR, directory containing headers -# PARQUET_LIBS, directory containing parquet libraries -# PARQUET_STATIC_LIB, path to libparquet.a -# PARQUET_SHARED_LIB, path to libparquet's shared library -# PARQUET_FOUND, whether parquet has been found - -if( NOT "$ENV{PARQUET_HOME}" STREQUAL "") - file( TO_CMAKE_PATH "$ENV{PARQUET_HOME}" _native_path ) - list( APPEND _parquet_roots ${_native_path} ) -elseif ( Parquet_HOME ) - list( APPEND _parquet_roots ${Parquet_HOME} ) -endif() - -# Try the parameterized roots, if they exist -if ( _parquet_roots ) - find_path( PARQUET_INCLUDE_DIR NAMES parquet/api/reader.h - PATHS ${_parquet_roots} NO_DEFAULT_PATH - PATH_SUFFIXES "include" ) - find_library( PARQUET_LIBRARIES NAMES parquet - PATHS ${_parquet_roots} NO_DEFAULT_PATH - PATH_SUFFIXES "lib" ) - - find_library(PARQUET_ARROW_LIBRARIES NAMES parquet_arrow - PATHS ${_parquet_roots} NO_DEFAULT_PATH - PATH_SUFFIXES "lib") -else () - find_path(PARQUET_INCLUDE_DIR NAMES parquet/api/reader.h ) - find_library(PARQUET_LIBRARIES NAMES parquet) - find_library(PARQUET_ARROW_LIBRARIES NAMES parquet_arrow) -endif () - - -if (PARQUET_INCLUDE_DIR AND PARQUET_LIBRARIES) - set(PARQUET_FOUND TRUE) - get_filename_component( PARQUET_LIBS ${PARQUET_LIBRARIES} PATH ) - set(PARQUET_LIB_NAME libparquet) - set(PARQUET_STATIC_LIB ${PARQUET_LIBS}/${PARQUET_LIB_NAME}.a) - set(PARQUET_SHARED_LIB ${PARQUET_LIBS}/${PARQUET_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) -else () - set(PARQUET_FOUND FALSE) -endif () - -if (PARQUET_INCLUDE_DIR AND PARQUET_ARROW_LIBRARIES) - set(PARQUET_ARROW_FOUND TRUE) - get_filename_component(PARQUET_ARROW_LIBS ${PARQUET_ARROW_LIBRARIES} PATH) - set(PARQUET_ARROW_LIB_NAME libparquet_arrow) - set(PARQUET_ARROW_STATIC_LIB - ${PARQUET_ARROW_LIBS}/${PARQUET_ARROW_LIB_NAME}.a) - set(PARQUET_ARROW_SHARED_LIB - ${PARQUET_ARROW_LIBS}/${PARQUET_ARROW_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) -else () - set(PARQUET_ARROW_FOUND FALSE) -endif () - -if (PARQUET_FOUND) - if (NOT Parquet_FIND_QUIETLY) - message(STATUS "Found the Parquet library: ${PARQUET_LIBRARIES}") - endif () -else () - if (NOT Parquet_FIND_QUIETLY) - set(PARQUET_ERR_MSG "Could not find the Parquet library. Looked in ") - if ( _parquet_roots ) - set(PARQUET_ERR_MSG "${PARQUET_ERR_MSG} in ${_parquet_roots}.") - else () - set(PARQUET_ERR_MSG "${PARQUET_ERR_MSG} system search paths.") - endif () - if (Parquet_FIND_REQUIRED) - message(FATAL_ERROR "${PARQUET_ERR_MSG}") - else (Parquet_FIND_REQUIRED) - message(STATUS "${PARQUET_ERR_MSG}") - endif (Parquet_FIND_REQUIRED) - endif () -endif () - -if (PARQUET_ARROW_FOUND) - if (NOT Parquet_FIND_QUIETLY) - message(STATUS "Found the Parquet Arrow library: ${PARQUET_ARROW_LIBS}") - endif() -endif() - -mark_as_advanced( - PARQUET_FOUND - PARQUET_INCLUDE_DIR - PARQUET_LIBS - PARQUET_LIBRARIES - PARQUET_STATIC_LIB - PARQUET_SHARED_LIB - - PARQUET_ARROW_FOUND - PARQUET_ARROW_LIBS - PARQUET_ARROW_STATIC_LIB - PARQUET_ARROW_SHARED_LIB -) http://git-wip-us.apache.org/repos/asf/arrow/blob/73455b56/dev/release/00-prepare.sh ---------------------------------------------------------------------- diff --git a/dev/release/00-prepare.sh b/dev/release/00-prepare.sh index 3423a3e..00af5e7 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" http://git-wip-us.apache.org/repos/asf/arrow/blob/73455b56/python/cmake_modules/FindParquet.cmake ---------------------------------------------------------------------- diff --git a/python/cmake_modules/FindParquet.cmake b/python/cmake_modules/FindParquet.cmake new file mode 100644 index 0000000..7445e09 --- /dev/null +++ b/python/cmake_modules/FindParquet.cmake @@ -0,0 +1,109 @@ +# Copyright 2012 Cloudera Inc. +# +# Licensed 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. + +# - Find PARQUET (parquet/parquet.h, libparquet.a, libparquet.so) +# This module defines +# PARQUET_INCLUDE_DIR, directory containing headers +# PARQUET_LIBS, directory containing parquet libraries +# PARQUET_STATIC_LIB, path to libparquet.a +# PARQUET_SHARED_LIB, path to libparquet's shared library +# PARQUET_FOUND, whether parquet has been found + +if( NOT "$ENV{PARQUET_HOME}" STREQUAL "") + file( TO_CMAKE_PATH "$ENV{PARQUET_HOME}" _native_path ) + list( APPEND _parquet_roots ${_native_path} ) +elseif ( Parquet_HOME ) + list( APPEND _parquet_roots ${Parquet_HOME} ) +endif() + +# Try the parameterized roots, if they exist +if ( _parquet_roots ) + find_path( PARQUET_INCLUDE_DIR NAMES parquet/api/reader.h + PATHS ${_parquet_roots} NO_DEFAULT_PATH + PATH_SUFFIXES "include" ) + find_library( PARQUET_LIBRARIES NAMES parquet + PATHS ${_parquet_roots} NO_DEFAULT_PATH + PATH_SUFFIXES "lib" ) + + find_library(PARQUET_ARROW_LIBRARIES NAMES parquet_arrow + PATHS ${_parquet_roots} NO_DEFAULT_PATH + PATH_SUFFIXES "lib") +else () + find_path(PARQUET_INCLUDE_DIR NAMES parquet/api/reader.h ) + find_library(PARQUET_LIBRARIES NAMES parquet) + find_library(PARQUET_ARROW_LIBRARIES NAMES parquet_arrow) +endif () + + +if (PARQUET_INCLUDE_DIR AND PARQUET_LIBRARIES) + set(PARQUET_FOUND TRUE) + get_filename_component( PARQUET_LIBS ${PARQUET_LIBRARIES} PATH ) + set(PARQUET_LIB_NAME libparquet) + set(PARQUET_STATIC_LIB ${PARQUET_LIBS}/${PARQUET_LIB_NAME}.a) + set(PARQUET_SHARED_LIB ${PARQUET_LIBS}/${PARQUET_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) +else () + set(PARQUET_FOUND FALSE) +endif () + +if (PARQUET_INCLUDE_DIR AND PARQUET_ARROW_LIBRARIES) + set(PARQUET_ARROW_FOUND TRUE) + get_filename_component(PARQUET_ARROW_LIBS ${PARQUET_ARROW_LIBRARIES} PATH) + set(PARQUET_ARROW_LIB_NAME libparquet_arrow) + set(PARQUET_ARROW_STATIC_LIB + ${PARQUET_ARROW_LIBS}/${PARQUET_ARROW_LIB_NAME}.a) + set(PARQUET_ARROW_SHARED_LIB + ${PARQUET_ARROW_LIBS}/${PARQUET_ARROW_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) +else () + set(PARQUET_ARROW_FOUND FALSE) +endif () + +if (PARQUET_FOUND) + if (NOT Parquet_FIND_QUIETLY) + message(STATUS "Found the Parquet library: ${PARQUET_LIBRARIES}") + endif () +else () + if (NOT Parquet_FIND_QUIETLY) + set(PARQUET_ERR_MSG "Could not find the Parquet library. Looked in ") + if ( _parquet_roots ) + set(PARQUET_ERR_MSG "${PARQUET_ERR_MSG} in ${_parquet_roots}.") + else () + set(PARQUET_ERR_MSG "${PARQUET_ERR_MSG} system search paths.") + endif () + if (Parquet_FIND_REQUIRED) + message(FATAL_ERROR "${PARQUET_ERR_MSG}") + else (Parquet_FIND_REQUIRED) + message(STATUS "${PARQUET_ERR_MSG}") + endif (Parquet_FIND_REQUIRED) + endif () +endif () + +if (PARQUET_ARROW_FOUND) + if (NOT Parquet_FIND_QUIETLY) + message(STATUS "Found the Parquet Arrow library: ${PARQUET_ARROW_LIBS}") + endif() +endif() + +mark_as_advanced( + PARQUET_FOUND + PARQUET_INCLUDE_DIR + PARQUET_LIBS + PARQUET_LIBRARIES + PARQUET_STATIC_LIB + PARQUET_SHARED_LIB + + PARQUET_ARROW_FOUND + PARQUET_ARROW_LIBS + PARQUET_ARROW_STATIC_LIB + PARQUET_ARROW_SHARED_LIB +) http://git-wip-us.apache.org/repos/asf/arrow/blob/73455b56/python/pyarrow/__init__.py ---------------------------------------------------------------------- diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py index a42e39c..39ba4c7 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 @@ from pyarrow.schema import (null, bool_, DataType, Field, Schema, schema) from pyarrow.table import Column, RecordBatch, Table, from_pandas_dataframe - -from pyarrow.version import version as __version__ http://git-wip-us.apache.org/repos/asf/arrow/blob/73455b56/python/setup.cfg ---------------------------------------------------------------------- diff --git a/python/setup.cfg b/python/setup.cfg new file mode 100644 index 0000000..caae3e0 --- /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 http://git-wip-us.apache.org/repos/asf/arrow/blob/73455b56/python/setup.py ---------------------------------------------------------------------- diff --git a/python/setup.py b/python/setup.py index 5f448f7..2e595e2 100644 --- a/python/setup.py +++ b/python/setup.py @@ -42,27 +42,9 @@ is_64_bit = sys.maxsize > 2**32 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,23 @@ class build_ext(_build_ext): return [self._get_cmake_ext_path(name) for name in self.get_names()] -write_version_py() - 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'], - version=VERSION, zip_safe=False, package_data={'pyarrow': ['*.pxd', '*.pyx']}, # Dummy extension to trigger build_ext @@ -290,6 +280,8 @@ setup( 'clean': clean, 'build_ext': build_ext }, + use_scm_version = {"root": "..", "relative_to": __file__}, + setup_requires=['setuptools_scm'], install_requires=['cython >= 0.23', 'numpy >= 1.9', 'six >= 1.0.0'], description=DESC, license='Apache License, Version 2.0',