Skip to content

Commit

Permalink
update setup script and generate versions automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
ralequi committed Jun 24, 2022
1 parent 9c864c6 commit 5826e9f
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 26 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include README.md
recursive-include docs *
1 change: 1 addition & 0 deletions pystorcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from . import common
from . import exc
from .version import __version__


_SINGLETON_MODULE_LOCK = threading.Lock()
Expand Down
1 change: 1 addition & 0 deletions pystorcli/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.3.7"
118 changes: 92 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,99 @@
# Copyright 2018 Martin Dojcak
# Copyright 2022 Rafael Leira, Naudit HPCN S.L.
#
# This program is licensed under BSD 3-clause license.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
################################################################

from setuptools import setup
from subprocess import Popen, PIPE
import os
import setuptools
import re


def read_file(path):
with open(os.path.join(os.path.dirname(__file__), path)) as fp:
return fp.read()


def _get_version_match(content):
# Search for lines of the form: # __version__ = 'ver'
regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
version_match = re.search(regex, content, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string in '__init__.py'.")


def get_version(path):
try:
p = Popen(['git', 'describe', '--always', '--tags'],
stdout=PIPE, stderr=PIPE)
p.stderr.close()
line = p.stdout.readlines()[0]
describe = line.strip()[1:].decode('utf-8').split('-')
if len(describe) == 1:
return describe[0]
else:
return describe[0]+'.'+describe[1]

except Exception as e:
print(e)
return _get_version_match(read_file(path))


def write_version(path):
'''
Write the version on variavle __version__ in version.py and returns the version
'''
version = get_version(os.path.join(path, '__init__.py'))

with open(os.path.join(path, 'version.py'), 'w') as f:
f.write('__version__ = "{}"\n'.format(version))

return version


def get_long_description():
this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

return long_description


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
REQUIREMENTS = [
]

CLASSIFIERS = [
"Programming Language :: Python :: 3",
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Natural Language :: English',
'Operating System :: POSIX',
'Topic :: System :: Hardware :: Hardware Drivers',
'Topic :: System :: Installation/Setup',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python',
]

setuptools.setup(
name="pystorcli",
version="0.3.6",
author="Martin Dojcak",
author_email="[email protected]",
description="StorCLI module wrapper",
long_description=read('README.md'),
setup(
name="PyStorCLI2",
version=write_version('pystorcli'),
author="Rafael Leira",
author_email="[email protected]",
description="StorCLI module wrapper 2",
long_description=get_long_description(),
long_description_content_type="text/markdown",
url="https://github.com/Chillisystems/pystorcli",
packages=setuptools.find_packages(),
url="https://github.com/Naudit/pystorcli2",
packages=['pystorcli'],
scripts=['bin/pystorcli-metrics'],
classifiers=(
"Programming Language :: Python :: 3",
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Natural Language :: English',
'Operating System :: POSIX',
'Topic :: System :: Hardware :: Hardware Drivers',
'Topic :: System :: Installation/Setup',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python',
),
)
classifiers=CLASSIFIERS,
install_requires=REQUIREMENTS,
)

0 comments on commit 5826e9f

Please sign in to comment.