diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b9fed3fcc2025c1b987381a6d34ada4e66e55ad0..6089160269d5ea613fae7036f8d4c1e480cab4f9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,11 +35,6 @@ stages: ${script} --help; done -# test basic setup on python2 -basic-2.7: - <<: *test-python - image: python:2.7 - # test basic setup on python3 basic-3.7: <<: *test-python diff --git a/bilby/__init__.py b/bilby/__init__.py index 5f5535823b5a63159016d0ebba5374c95643c2e6..eff33090a25b4c0147cce0166ac9b4ddbe433705 100644 --- a/bilby/__init__.py +++ b/bilby/__init__.py @@ -17,6 +17,7 @@ https://lscsoft.docs.ligo.org/bilby/installation.html. from __future__ import absolute_import +import sys from . import core, gw, hyper @@ -25,3 +26,25 @@ from .core.sampler import run_sampler from .core.likelihood import Likelihood __version__ = utils.get_version_information() + + +if sys.version_info < (3,): + raise ImportError( +"""You are running bilby 0.6.4 on Python 2 + +Bilby 0.6.4 and above are no longer compatible with Python 2, and you still +ended up with this version installed. That's unfortunate; sorry about that. +It should not have happened. Make sure you have pip >= 9.0 to avoid this kind +of issue, as well as setuptools >= 24.2: + + $ pip install pip setuptools --upgrade + +Your choices: + +- Upgrade to Python 3. + +- Install an older version of bilby: + + $ pip install 'bilby<0.6.4' + +""") diff --git a/docs/installation.txt b/docs/installation.txt index a6ae1a11ad2c6e7b232f839c19671c4cc211cfa4..96dc0f90d1d8cc0ae7a09e0be727b21f28402ecf 100644 --- a/docs/installation.txt +++ b/docs/installation.txt @@ -10,7 +10,7 @@ Installation $ conda install -c conda-forge bilby - Supported python versions: 2.7, 3.5+. + Supported python versions: 3.5+. .. tab:: Pip @@ -18,7 +18,7 @@ Installation $ pip install bilby - Supported python versions: 2.7, 3.5+. + Supported python versions: 3.5+. This will install all requirements for running :code:`bilby` for general @@ -47,7 +47,7 @@ wave inference, please additionally run the following commands. Install bilby from source ------------------------- -:code:`bilby` is developed and tested with both Python 2.7+ and Python 3.7+. In the +:code:`bilby` is developed and tested with Python 3.6+. In the following, we assume you have a working python installation, `python pip <https://packaging.python.org/tutorials/installing-packages/#use-pip-for-installing)>`_, and `git <https://git-scm.com/>`_. See :ref:`installing-python` for our @@ -60,7 +60,7 @@ Clone the repository, install the requirements, and then install the software: $ git clone git@git.ligo.org:lscsoft/bilby.git $ cd bilby/ $ pip install -r requirements.txt - $ python setup.py install + $ pip install . Once you have run these steps, you have :code:`bilby` installed. You can now try to run the examples. @@ -79,6 +79,13 @@ try to run the examples. $ git clone https://git.ligo.org/lscsoft/bilby.git +.. note:: + You may be use to using :code:`$ python setup.py install` to install software + from source. While it is possible to do this, current recommentations from + the python community (see, e.g. `this site <https://python3statement.org/practicalities/>`_ + are to use :code:`pip`. For development install, the :code:`-e` flag can be + used. + Installing optional requirements ================================ diff --git a/setup.py b/setup.py index cb95ccb365e1b41a947ef0ee0fdf4a1d393fd20e..fada98be29d377da45eafb969a31d3b4357a6247 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,15 @@ from setuptools import setup import subprocess +import sys import os +# check that python version is 3.5 or above +python_version = sys.version_info +if python_version < (3, 5): + sys.exit("Python < 3.5 is not supported, aborting setup") +print("Confirmed Python version {}.{}.{} >= 3.5.0".format(*python_version[:3])) + def write_version_file(version): """ Writes a file with version information to be used at run time @@ -77,6 +84,7 @@ setup(name='bilby', package_data={'bilby.gw': ['prior_files/*'], 'bilby.gw.detector': ['noise_curves/*.txt', 'detectors/*'], 'bilby': [version_file]}, + python_requires='>=3.5', install_requires=[ 'future', 'dynesty>=1.0.0', @@ -94,7 +102,7 @@ setup(name='bilby', 'bilby_convert_resume=cli_bilby.resume:main'] }, classifiers=[ - "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"])