Skip to content

Commit

Permalink
Change VERSION to version.py (#349)
Browse files Browse the repository at this point in the history
* VERSION => version.py

* remove smart_open/VERSION

* fix loading of version in setup.py
  • Loading branch information
mpenkov committed Sep 11, 2019
1 parent ed62400 commit ac3db9b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ include LICENSE
include README.rst
include CHANGELOG.rst
include setup.py
include smart_open/VERSION
2 changes: 1 addition & 1 deletion release/merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."
version="$(head -n 1 smart_open/VERSION)"
version=$(env -i python -c "from smart_open.version import __version__; print(__version__)")

read -p "Push version $version to github.com? yes or no: " reply
if [ "$reply" != "yes" ]
Expand Down
4 changes: 2 additions & 2 deletions release/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ git branch -D release-"$version"
set -e

git checkout upstream/master -b release-"$version"
echo "$version" > smart_open/VERSION
git commit smart_open/VERSION -m "bump version to $version"
echo "__version__ = '$version'" > smart_open/version.py
git commit smart_open/version.py -m "bump version to $version"

echo "Next, update CHANGELOG.md."
echo "Consider running summarize_pr.sh for each PR merged since the last release."
Expand Down
2 changes: 1 addition & 1 deletion release/push_pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cd ..
pip install twine
python setup.py sdist

version="$(head -n 1 smart_open/VERSION)"
version=$(env -i python -c "from smart_open.version import __version__; print(__version__)")
read -p "Push version $version to PyPI? This step is non-reversible. Answer yes or no: " reply
if [ "$reply" != "yes" ]
then
Expand Down
31 changes: 20 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,29 @@
from setuptools import setup, find_packages


def read(fname):
return io.open(os.path.join(os.path.dirname(__file__), fname), encoding='utf-8').read()
def _get_version():
curr_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(curr_dir, 'smart_open', 'version.py')) as fin:
#
# __version__ = '1.8.4'
#
line = fin.readline().strip()
parts = line.split(' ')
assert parts[0] == '__version__'
assert parts[1] == '='
return parts[2][1:-1]


#
# This code intentially duplicates a similar function in __init__.py. The
# alternative would be to somehow import that module to access the function,
# which would be too messy for a setup.py script.
# We cannot do "from smart_open.version import __version__" because that will
# require the dependencies for smart_open to already be in place, and that is
# not necessarily the case when running setup.py for the first time.
#
def _get_version():
curr_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(curr_dir, 'smart_open', 'VERSION')) as fin:
return fin.read().strip()
__version__ = _get_version()


def read(fname):
return io.open(os.path.join(os.path.dirname(__file__), fname), encoding='utf-8').read()


tests_require = [
Expand All @@ -53,13 +63,12 @@ def _get_version():

setup(
name='smart_open',
version=_get_version(),
version=__version__,
description='Utils for streaming large files (S3, HDFS, gzip, bz2...)',
long_description=read('README.rst'),

packages=find_packages(),
package_data={
"smart_open": ["VERSION"],
"smart_open.tests": ["test_data/*gz"],
},

Expand Down
1 change: 0 additions & 1 deletion smart_open/VERSION

This file was deleted.

9 changes: 2 additions & 7 deletions smart_open/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,15 @@
"""

import logging
from smart_open import version
import os.path

from .smart_open_lib import open, smart_open, register_compressor
from .s3 import iter_bucket as s3_iter_bucket
__all__ = ['open', 'smart_open', 's3_iter_bucket', 'register_compressor']


def _get_version():
curr_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(curr_dir, 'VERSION')) as fin:
return fin.read().strip()


__version__ = _get_version()
__version__ = version.__version__

logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
1 change: 1 addition & 0 deletions smart_open/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '1.8.4'

0 comments on commit ac3db9b

Please sign in to comment.