-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update setup script and generate versions automatically
- Loading branch information
Showing
4 changed files
with
96 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include README.md | ||
recursive-include docs * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.3.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |