Update setup.py

This commit is contained in:
Garrett Holmstrom 2013-02-20 17:36:00 -08:00
parent b59b6a19a1
commit c243e9d850
4 changed files with 62 additions and 6 deletions

4
.gitignore vendored
View File

@ -6,5 +6,9 @@
.DS_Store
core
core.*
*.egg_info
*.pyc
*.pyo
__pycache__
/build
/dist

0
README Normal file
View File

View File

@ -14,8 +14,29 @@
import argparse
import operator
import os.path
import subprocess
__version__ = 'devel'
if '__file__' in globals():
# Check if this is a git repo; maybe we can get more precise version info
try:
repo_path = os.path.join(os.path.dirname(__file__), '..')
git = subprocess.Popen(['git', 'describe'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env={'GIT_DIR': os.path.join(repo_path, '.git')})
git.wait()
git.stderr.read()
if git.exitcode == 0:
__version__ = git.stdout.read().strip()
if type(__version__).__name__ == 'bytes':
__version__ = __version__.decode()
except:
# Not really a bad thing; we'll just use what we had
pass
__version__ = '0.0'
class Arg(object):
'''

View File

@ -12,19 +12,48 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from distutils.core import setup
from distutils.command.sdist import sdist
import os.path
try:
from setuptools import setup
extra = {'install_requires': ['requests', 'six']}
except ImportError:
from distutils.core import setup
extra = {}
from requestbuilder import __version__
class sdist_with_git_version(sdist):
'''Like sdist, but also hardcoding the version in __init__.__version__ so
it's consistent even outside of the source tree'''
def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
version_line = "__version__ = '{0}'\n".format(__version__)
old_init_name = os.path.join(base_dir, 'requestbuilder/__init__.py')
new_init_name = old_init_name + '.new'
with open(new_init_name, 'w') as new_init:
with open(old_init_name) as old_init:
for line in old_init:
if line.startswith('__version__ ='):
new_init.write(version_line)
else:
new_init.write(line)
new_init.flush()
os.rename(new_init_name, old_init_name)
setup(name = 'requestbuilder',
version = __version__,
description = 'Command line-driven HTTP request builder',
author = 'Garrett Holmstrom (gholms)',
author_email = 'gholms@fedoraproject.org',
author_email = 'gholms@devzero.com',
packages = ['requestbuilder'],
license = 'ISC',
platforms = 'Posix; MacOS X',
classifiers = ['Development Status :: 2 - Pre-Alpha',
classifiers = ['Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: ISC License (ISCL)',
'Programming Language :: Python',
@ -32,5 +61,7 @@ setup(name = 'requestbuilder',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Internet'],
requires = ['boto (>= 2.2)'],
provides = ['requestbuilder'])
requires = ['requests', 'six'],
provides = ['requestbuilder'],
cmdclass = {'sdist': sdist_with_git_version},
**extra)