Skip to content

Commit

Permalink
weka.jar is now included in release archives
Browse files Browse the repository at this point in the history
  • Loading branch information
fracpete committed Sep 16, 2018
1 parent 5990ce7 commit 076b169
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
@@ -1,6 +1,5 @@
recursive-include python *.arff
recursive-include python *.jar
recursive-exclude python weka-src.jar
recursive-exclude python weka.jar
include DESCRIPTION.rst
include CHANGES.rst
55 changes: 2 additions & 53 deletions setup.py
Expand Up @@ -14,57 +14,7 @@
# setup.py
# Copyright (C) 2014-2018 Fracpete (pythonwekawrapper at gmail dot com)

import os
from setuptools import setup
from urllib.request import urlopen, URLError, HTTPError


def download_file(url, outfile):
"""
Downloads the file associated with the URL and saves it to the specified output file.
Taken from here: http://stackoverflow.com/a/4028894
:param url: the URL to download
:type url: str
:param outfile: the name of the output file
:type outfile: str
:returns: whether the download was successful
:rtype: bool
"""
try:
# Open the url
f = urlopen(url)
print("Downloading '" + url + "' to '" + outfile + "'")
# Open our local file for writing
with open(outfile, "wb") as local_file:
local_file.write(f.read())
# handle errors
except HTTPError as e:
print("HTTP Error: " + str(e.code) + " " + url)
return False
except URLError as e:
print("URL Error: " + str(e.reason) + " " + url)
return False
return True


def download_weka():
"""
Downloads the Weka jar from github associated with this release if nececssary.
"""
url = "https://github.com/fracpete/python-weka-wrapper3/raw/a6158f1310c5059e7031f3314525c510cb46d598/python/weka/lib/weka.jar"
outfile = os.path.join(os.path.dirname(__file__), "python", "weka", "lib", "weka.jar")
if not os.path.exists(outfile):
if not download_file(url, outfile):
print("Failed to download Weka jar '" + url + "' to '" + outfile + "'!")
else:
print("Download of Weka jar successful!")


def ext_modules():
"""
Initiates Weka jar download.
"""
download_weka()


def _read(f):
Expand Down Expand Up @@ -105,16 +55,15 @@ def _read(f):
"weka": ["lib/*.jar"],
},
include_package_data=True,
version="0.1.4",
version="0.1.5",
author='Peter "fracpete" Reutemann',
author_email='pythonwekawrapper@gmail.com',
install_requires=[
"javabridge>=1.0.14",
"numpy"
"numpy",
],
extras_require={
'plots': ["matplotlib"],
'graphs': ["pygraphviz", "PIL"],
},
ext_modules=ext_modules(),
)

0 comments on commit 076b169

Please sign in to comment.