Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change VERSION to version.py #349

Merged
merged 3 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'