From a77ba1e25d2b5a4f0af11ba52f44ac1b36616119 Mon Sep 17 00:00:00 2001 From: Aaron Hosford Date: Wed, 27 May 2015 00:53:38 -0500 Subject: [PATCH] Added kludge to work around setuptools bug The setuptools module is introducing newlines into PKG-INFO. Added a kludge script to handle all the prep-work for registering the package, including dealing with this issue. --- README.rst | 6 +++--- register_prep.py | 29 +++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 register_prep.py diff --git a/README.rst b/README.rst index b80786a..1d2c71a 100644 --- a/README.rst +++ b/README.rst @@ -37,9 +37,9 @@ input, and attempts to select the best action from a predetermined list of choices using an evolving set of rules that match inputs and offer appropriate suggestions. It then receives a reward signal indicating the quality of its decision, which it uses to adjust the rule set that was -used to make the decision. This process is then repeated, allowing the -algorithm to evaluate the changes it has already made and further refine -the rule set. +used to make the decision. This process is subsequently repeated, +allowing the algorithm to evaluate the changes it has already made and +further refine the rule set. A key feature of XCS is that, unlike many other machine learning algorithms, it not only learns the optimal input/output mapping, but diff --git a/register_prep.py b/register_prep.py new file mode 100644 index 0000000..916d666 --- /dev/null +++ b/register_prep.py @@ -0,0 +1,29 @@ +# Prepares for registration. +__author__ = 'Aaron Hosford' + +import glob +import os + +from xcs import __version__ +import build_readme + +build_readme.build_readme() +os.system('python setup.py sdist bdist_wheel') + +with open('xcs.egg-info/PKG-INFO', encoding='utf-8', mode='rU') as infile: + with open('xcs.egg-info/PKG-INFO-FIXED', encoding='utf-8', mode='w') as outfile: + prev_skipped = False + for line in infile: + if line.strip() or prev_skipped: + outfile.write(line) + prev_skipped = False + else: + prev_skipped = True +os.remove('xcs.egg-info/PKG-INFO') +os.rename('xcs.egg-info/PKG-INFO-FIXED', 'xcs.egg-info/PKG-INFO') + +dist = glob.glob('dist\\*' + __version__ + '*.whl')[-1] +print(dist) +os.system('pip install dist\\' + os.path.basename(dist) + ' --upgrade') + + diff --git a/setup.py b/setup.py index db7243f..444ea8d 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ # Get the long description from the relevant file. First try README.rst, then fall back on # the default string defined here in this file. if path.isfile(path.join(here, 'README.rst')): - with open(path.join(here, 'README.rst'), encoding='utf-8') as description_file: + with open(path.join(here, 'README.rst'), encoding='utf-8', mode='rU') as description_file: long_description = description_file.read() setup(