You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/08/09 17:49:32 UTC

[arrow] branch master updated: ARROW-3029: [Python] Generate version file when building

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 0c38a21  ARROW-3029: [Python] Generate version file when building
0c38a21 is described below

commit 0c38a21be6456aa1dabd860bc357f3e23f896364
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Thu Aug 9 13:49:28 2018 -0400

    ARROW-3029: [Python] Generate version file when building
    
    Remove the reliance on pkg_resources to find out the version of an install PyArrow.
    Here, this makes `import pyarrow` around 200 ms. faster.
    
    Author: Antoine Pitrou <an...@python.org>
    
    Closes #2415 from pitrou/ARROW-3029-use-generated-version-file and squashes the following commits:
    
    0504c7d7 <Antoine Pitrou> ARROW-3029:  Generate version file when building
---
 python/.gitignore          | 4 +---
 python/pyarrow/__init__.py | 5 ++---
 python/setup.py            | 8 +++++---
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/python/.gitignore b/python/.gitignore
index 0633bb4..c6125ad 100644
--- a/python/.gitignore
+++ b/python/.gitignore
@@ -15,14 +15,12 @@ Testing/
 # Generated sources
 *.c
 *.cpp
-pyarrow/version.py
 pyarrow/*_api.h
+pyarrow/_generated_version.py
 
 # Bundled headers
 pyarrow/include
 
-# Python files
-
 # setup.py working directory
 build
 # setup.py dist directory
diff --git a/python/pyarrow/__init__.py b/python/pyarrow/__init__.py
index 44edda4..cb6b599 100644
--- a/python/pyarrow/__init__.py
+++ b/python/pyarrow/__init__.py
@@ -20,10 +20,9 @@
 import os as _os
 import sys as _sys
 
-from pkg_resources import get_distribution, DistributionNotFound
 try:
-    __version__ = get_distribution(__name__).version
-except DistributionNotFound:
+    from ._generated_version import version as __version__
+except ImportError:
     # Package is not installed, parse git tag at runtime
     try:
         import setuptools_scm
diff --git a/python/setup.py b/python/setup.py
index d32b020..b8d3a6d 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -546,9 +546,11 @@ setup(
             'plasma_store = pyarrow:_plasma_store_entry_point'
         ]
     },
-    use_scm_version={"root": "..",
-                     "relative_to": __file__,
-                     "parse": parse_git},
+    use_scm_version={"root": os.path.dirname(setup_dir),
+                     "parse": parse_git,
+                     "write_to": os.path.join(setup_dir,
+                                              "pyarrow/_generated_version.py"),
+                     },
     setup_requires=['setuptools_scm', 'cython >= 0.27'] + setup_requires,
     install_requires=install_requires,
     tests_require=['pytest', 'pandas'],