hyperopt / hyperopt-sklearn

Hyper-parameter optimization for sklearn
hyperopt.github.io/hyperopt-sklearn
Other
1.59k stars 272 forks source link

Cleanup setup.py #117

Closed Seanny123 closed 6 years ago

Seanny123 commented 6 years ago

Modernizes setup.py so that it's compatible with Windows and is less complex.

Simlar to #81, I was also having trouble installing on Windows 10 with Python 3.6. Specifically, I was getting the error:

PS C:\Users\mr_bo\git\hyperopt-sklearn> pip install -e .
Obtaining file:///C:/Users/mr_bo/git/hyperopt-sklearn
    Complete output from command python setup.py egg_info:
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.38.tar.gz
    Traceback (most recent call last):
      File "c:\users\mr_bo\git\hyperopt\distribute_setup.py", line 150, in use_setuptools
        raise ImportError
    ImportError

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\mr_bo\git\hyperopt-sklearn\setup.py", line 36, in <module>
        distribute_setup.use_setuptools()
      File "c:\users\mr_bo\git\hyperopt\distribute_setup.py", line 152, in use_setuptools
        return _do_download(version, download_base, to_dir, download_delay)
      File "c:\users\mr_bo\git\hyperopt\distribute_setup.py", line 131, in _do_download
        to_dir, download_delay)
      File "c:\users\mr_bo\git\hyperopt\distribute_setup.py", line 201, in download_setuptools
        src = urlopen(url)
      File "c:\tools\anaconda3\lib\urllib\request.py", line 223, in urlopen
        return opener.open(url, data, timeout)
      File "c:\tools\anaconda3\lib\urllib\request.py", line 532, in open
        response = meth(req, response)
      File "c:\tools\anaconda3\lib\urllib\request.py", line 642, in http_response
        'http', request, response, code, msg, hdrs)
      File "c:\tools\anaconda3\lib\urllib\request.py", line 570, in error
        return self._call_chain(*args)
      File "c:\tools\anaconda3\lib\urllib\request.py", line 504, in _call_chain
        result = func(*args)
      File "c:\tools\anaconda3\lib\urllib\request.py", line 650, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 403: SSL is required

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\mr_bo\git\hyperopt-sklearn\

However, when I deleted the chunk:

if debug: logging.basicConfig(level=logging.DEBUG)
# distribute import and testing
try:
    import distribute_setup
    distribute_setup.use_setuptools()
    logging.debug("distribute_setup.py imported and used")
except ImportError:
    # fallback to setuptools?
    # distribute_setup.py was not in this directory
    if not (setup_tools_fallback):
        import setuptools
        if not (hasattr(setuptools,'_distribute') and \
                setuptools._distribute):
            raise ImportError("distribute was not found and fallback to setuptools was not allowed")
        else:
            logging.debug("distribute_setup.py not found, defaulted to system distribute")
    else:
        logging.debug("distribute_setup.py not found, defaulting to system setuptools")

from setup.py, I was able to install the package. Consequently, I've created this PR to clean up setup.py.

I decided to copy Nengo's style of setup.py. Nengo has stringent setup requirements and it:

bjkomer commented 6 years ago

Thanks for the PR! Seems to work fine. The one difference I've noticed from the previous version is that it now installs the package as hyperopt-sklearn instead of hpsklearn. (still uses import hpsklearn in python though). I feel like this makes more sense than the old behaviour, and better to change it now than later. There just might be some issues popping up when a PyPI release comes about.

Seanny123 commented 6 years ago

@bjkomer fixed