Skip to content

Drop Python 2 and 3.4 #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 20, 2019
Merged

Conversation

markcampanelli
Copy link
Contributor

@markcampanelli markcampanelli commented May 17, 2019

pvlib python pull request guidelines

Thank you for your contribution to pvlib python! You may delete all of these instructions except for the list below.

You may submit a pull request with your code at any stage of completion.

The following items must be addressed before the code can be merged. Please don't hesitate to ask for help if you're unsure of how to accomplish any of the items below:

  • Closes issue Plan for dropping Python 2.7 #501
  • I am familiar with the contributing guidelines.
  • Fully tested. Added and/or modified tests to ensure correct behavior for all reasonable inputs. Tests (usually) must pass on the TravisCI and Appveyor testing services.
  • Updates entries to docs/sphinx/source/api.rst for API changes.
  • Adds description and name entries in the appropriate docs/sphinx/source/whatsnew file for all changes.
  • Code quality and style is sufficient. Passes LGTM and SticklerCI checks.
  • New code is fully documented. Includes sphinx/numpydoc compliant docstrings and comments in the code where necessary.
  • Pull request is nearly complete and ready for detailed review.

Brief description of the problem and proposed solution (if not already fully described in the issue linked to above):

To ease development for the 0.7.0 release, let's drop support for Python 2 and 3.4 sooner rather than later.

@markcampanelli
Copy link
Contributor Author

markcampanelli commented May 17, 2019

@wholmgren Mind if we do this sooner rather than later to simplify development for 0.7.0?

We can always make a 0.6.4 branch/release for any hotfixes.

@wholmgren
Copy link
Member

No objection here. You'll need to drop 2.7 from the azure-pipelines.yml too.

@wholmgren
Copy link
Member

another mention of python 2.7: https://pvlib-python.readthedocs.io/en/stable/contributing.html#code-style

.travis.yml Outdated
- python: 3.5
env: CONDA_ENV=py35
- python: 3.6
env:
- CONDA_ENV=py36
- TASK="coverage"
- DEPLOY_ENV="true"
- python: 3.6
- python: 3.7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wholmgren Do you know if this is a significant problem in the current builds?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a problem -- this only specifies the base travis python version. The conda requirements file specifies the python version that's actually used in the test environment. I figured it was better to use the same version for consistency. But Travis did not yet have a base 3.7 available when it came time to add it to build matrix, so I used 3.6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check my update in 6207754?

It's based on travis-ci/travis-ci#9815.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I missed the memo on this: Is the plan to retire Travis once the Azure pipelines are deemed stable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check my update in 6207754?

I don't know what if any nuance there might be on this, but if it works and it's not noticeably slower then it's ok with me. Is there any benefit to making this change?

Is the plan to retire Travis once the Azure pipelines are deemed stable?

Main purpose of adding azure was that it let us remove appveyor. I want to see the azure pipelines documentation improve before making a plan to retire Travis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just set up CI using Azure pipelines for Ubuntu 16.04, Windows, and macOS here. It might be nice to maintain only a single CI in pvlib.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the example! #719 tracks this - well, at least the macOS part. Additional work would be required to transition the deploy section of the travis config to azure. #727 also relevant.

@@ -63,14 +54,6 @@ install:
- echo "install"
- conda env create --file ci/requirements-$CONDA_ENV.yml
- source activate test_env # all envs are named test_env in the yml files
# needed to make sure that pandas is compiled against the right
# version of numpy
- if [[ "$CONDA_ENV" == "py27-min" ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wholmgren Do we need to define a new minimum environment in Python 3?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch. I'm pretty sure you'll be able to pin the minimum version numbers in the pip section of the file. I'm less sure about the conda section of the file. Either way is fine with me. I don't think we'll need anything special after that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I was wrong -- I'm not able to easily create a python 3.5 environment with the current numpy/pandas minimums on my mac. I suspect it's possible but I don't think it's worth the effort to struggle against theses old packages. I can easily build and test the environment with pandas 0.17:

# requirements-py35-min.yml
name: test_env
channels:
    - defaults
dependencies:
    - python=3.5
    - pip
    - pip:
        - numpy==1.10.1
        - pandas==0.17.0
        - pytz
        - nose
        - pytest
        - pytest-mock
        - pytest-timeout
        - coveralls

We should also specify a newer version of conda in the travis config. Latest is fine.

Only catch is that test_sun_rise_set_transit_spa claims it needs pandas 0.17, but it apparently needs 0.18.

@markcampanelli
Copy link
Contributor Author

@wholmgren One more question: There are four different environment.yml files remaining in addition to the setup.py. It looks like the dependencies have diverged a bit between them (e.g., versions for numpy and pandas). If I can get some "official" minimums for all the required packages, then I can try to bring these files in line and test out some "clean" installs for compatibility.

@wholmgren
Copy link
Member

If I can get some "official" minimums for all the required packages, then I can try to bring these files in line and test out some "clean" installs for compatibility.

Official minimums are in the setup.py file. The non-min ci/environment files intentionally don't specify versions so that we always pull the latest dependencies. The py27-min + travis.yml configuration is a workaround for some packaging issue that I don't fully recall. (Maybe conda previously iterated through the pip requirements instead specifying them simultaneously.) I think the workaround is no longer necessary and a py35-min with pinned minimum versions should be adequate. If it's not, let's address the min configuration in another issue/pr.

@markcampanelli markcampanelli mentioned this pull request May 19, 2019
8 tasks
@markcampanelli
Copy link
Contributor Author

@wholmgren I think I have all the build changes finished. I did have to update a test, which seemed to fail in strange ways in my Python 3.5 testing with the minimum numpy & pandas installations. The fix seems to make sense, but I'm not sure why it doesn't always fail.

My next (and hopefully final) step will be to remove the __future__ imports. However, can you provide some guidance on if/how I should update this? Also, can you think of any other Python 2 vs. 3 computations changes that might bite us?

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.

I suggest that we keep this PR focused on CI and we remove the python 2 compatibility code in later PRs.

- pandas
- pytz
- coveralls
- cython
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why cython?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I forgot it's in the setup.py extras section. I can't remember why it's there. I guess it should be here if it's in the setup.py file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tried to make all the non-min requirements files match the optional setup. You'll also notice that I moved everything I could to the conda install. Anaconda recommends minimizing the mixing of conda and pip.

- pytables
- pandas=0.22.0
- pytz
- coveralls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to change the docs environment? This has been a pain to test and debug on RTD in the past. I suggest addressing separately if there's a need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what to do here, but I'm fine reverting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, please do revert this change.

@@ -1,3 +1,10 @@
# First ensure proper Python version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would help people who need to upgrade, but I'm fine removing.

setup.py Outdated
EXTRAS_REQUIRE = {
'optional': ['scipy', 'tables', 'numba', 'siphon', 'netcdf4',
'ephem', 'cython', 'pvfactors'],
'ephem', 'cython', 'pvfactors == 1.0.1'],
Copy link
Member

@wholmgren wholmgren May 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not pin the dependency in our setup.py file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a minimum? It is pinned in the build environments?

setup.py Outdated
@@ -40,13 +40,12 @@
INSTALL_REQUIRES = ['numpy >= 1.10.1',
'pandas >= 0.16.0',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min version change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that got reverted in some of my testing.

@@ -216,7 +216,7 @@ environment) when you start a new shell or terminal.
Compatibility
-------------

pvlib-python is compatible with Python versions 2.7 and 3.4-3.7.
pvlib-python is compatible with Python 3.5-7.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest "3.5 and above".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also in readme and contributing.

@markcampanelli
Copy link
Contributor Author

Travis CI test statistics for 507428f:

  • CONDA_ENV=py35-min
    • 402 passed, 201 skipped, 2 xfailed, 1 xpassed, 2 warnings in 174.61 seconds- CONDA_ENV=py35
  • CONDA_ENV=py35
    • 604 passed, 3 skipped, 3 xfailed, 1 xpassed, 76 warnings in 244.82 seconds
  • CONDA_ENV=py36
    • 604 passed, 3 skipped, 2 xfailed, 2 xpassed, 2 warnings in 262.36 seconds
  • CONDA_ENV=py37
    • 605 passed, 2 skipped, 2 xfailed, 2 xpassed, 2 warnings in 132.43 seconds

@markcampanelli
Copy link
Contributor Author

@wholmgren Let me know if you have any other comments. Otherwise, this should be GTG if LGTM analysis passes.

Copy link
Member

@wholmgren wholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge tomorrow (Monday) unless there are objections.

from unittest.mock import ANY
except ImportError:
# python 2
from mock import ANY
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, this is not used.

setup.py Outdated
@@ -71,7 +67,8 @@
setuptools_kwargs = {
'zip_safe': False,
'scripts': [],
'include_package_data': True
'include_package_data': True,
'python_requires': '>=3.5, <4'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wholmgren I remembered that this is the more "proper" way to call this out. This way, pip install -e . won't work if the Python version is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

@cwhanse
Copy link
Member

cwhanse commented May 20, 2019

No objections to merge

@wholmgren wholmgren added this to the 0.7.0 milestone May 20, 2019
@wholmgren wholmgren added the api label May 20, 2019
@wholmgren wholmgren merged commit d68617c into pvlib:master May 20, 2019
@wholmgren
Copy link
Member

Thanks @markcampanelli!

@markcampanelli markcampanelli deleted the drop_python2_and_34 branch May 20, 2019 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants