Skip to content
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

Drop support for Python 2 #709

Merged
merged 5 commits into from
Jun 6, 2020
Merged

Drop support for Python 2 #709

merged 5 commits into from
Jun 6, 2020

Conversation

jdufresne
Copy link
Contributor

@jdufresne jdufresne commented May 25, 2019

Python 2 support is nearing end of life. At the end of this year, it will no longer be supported, including for security issues.

Django has already dropped support for Python 2 in Django 2.0. Follow upstream to be more compatible with the master branch as tests now pass.

For more details, see https://pythonclock.org/

All code changes and clean ups that were noticed were done. Changes include:

  • Remove str/unicode compatibility shims.
  • Remove encoding cookies from source files. Python 3 interprets all files as utf-8 by default.
  • Remove unnecessary __future__ imports. The features are now built-in.
  • Use modern and simpler super() syntax.
  • Update the wheel configuration to reflect it is no longer universal.
  • Update trove classifiers.
  • And more …

Also remove supported for end of life Python 3.4. It went end of life 2019-03-18.

@jdufresne
Copy link
Contributor Author

I have rebased to resolve merge conflicts.

@jschneier What do you think about this change? It would be nice to get the project compatible with the Django master branch again.

@jdufresne
Copy link
Contributor Author

jdufresne commented Oct 13, 2019

Another reason this would be nice, Django 3.0 deprecated forct_text() in favor of force_str(). Using django-storages with Django 3.0 writes lots of deprecation warnings the consoles:

RemovedInDjango40Warning: force_text() is deprecated in favor of force_str().

By moving to Python3-only, we can safely use force_str() or str() and avoid the warnings.

@debdolph
Copy link

Any progress on this?

@jdufresne
Copy link
Contributor Author

Now that Python 2.7 is end-of-life and no longer receiving security updates, maybe now is the time? FWIW, here are the download statistics for django-storages for the last month. These where gathered using pypinfo:

python_version percent download_count
3.6 39.35% 246,135
3.7 31.29% 195,718
2.7 18.60% 116,308
3.5 5.42% 33,898
3.8 4.87% 30,483
3.4 0.46% 2,907
3.9 0.00% 12
2.6 0.00% 5
Total 625,466

Python 2.7 is less than 20% of all downloads.

@jschneier
Copy link
Owner

@jdufresne I would like to drop Python 2 support this weekend. At minimum I would like to release a version with the features in master. I think I would also be remiss not to enforce the security updates on Python 2 as well.

Then another bump for the dropping.

@jdufresne
Copy link
Contributor Author

🎉 Sounds like a good plan to me. Let me know if you need any PR rebased or other work done to assist in the effort.

Thanks for maintaining such an important project!

@jdufresne
Copy link
Contributor Author

Hi @jschneier, hope you're doing well.

What do you think about moving ahead with the outlined plan above to release the next versions of django-storages? It has now been a month. It would be great to get the Django deprecation messages cleaned up. Let me know if there is anything I can do to help: changes, rebase, new fixes, or anything else. Cheers.

jdufresne added 5 commits May 4, 2020 07:43
Python 2 support is nearing end of life. At the end of this year, it
will no longer be supported, including for security issues.

Django has already dropped support for Python 2 in Django 2.0. Follow
upstream to be more compatible with the master branch as tests now pass.

For more details, see https://pythonclock.org/

All code changes and clean ups that were noticed were done. Changes
include:

- Remove str/unicode compatibility shims.
- Remove encoding cookies from source files. Python 3 interprets all
  files as utf-8 by default.
- Remove unnecessary __future__ imports. The features are now built-in.
- Use modern and simpler super() syntax.
- Update the wheel configuration to reflect it is no longer universal.
- Update trove classifiers.
- And more …

Also remove supported for end of life Python 3.4. It went end of life
2019-03-18.

Fixes #849
In Python3, these methods default to UTF-8.
Since Python 3.3, IOError has been merged into OSError.
FileNotFoundError is a subclass, so its use is fully backwards
compatible.
Django deprecated force_text() and smart_text() in favor of force_str()
and smart_str() in:

django/django@d55e882

Fixes #806
As django-storages is now Python 3 only, handling both bytes & string
paths is now unnecessary. In Python 3 with Django, paths are always
a string.
@jdufresne
Copy link
Contributor Author

Hi @jschneier What do you think about moving ahead with the plan outlined in March. It would be really great to get rid of the emitted deprecation warnings.

Please let me know if I can help out in anyway. Either with this PR or with the release.

Here are the latest statistics from pypinfo. It shows a drop in the use of Python 2 as a percentage of downloads, now just 12.00%.

python_version percent download_count
3.6 35.79% 372,748
3.7 30.90% 321,836
3.8 14.18% 147,632
2.7 12.00% 125,003
3.5 6.44% 67,111
3.4 0.68% 7,088
3.9 0.00% 51
3.3 0.00% 9
2.6 0.00% 3
Total 1,041,481

@WhyNotHugo
Copy link
Contributor

FWIW, users of Python2 can just use an older version of the library.

They're already forced to used old versions of pretty much everything else, including Django.

I don't feel like they'd really be affected by this library dropping support for them.

@jschneier
Copy link
Owner

Let's do it.

@jschneier jschneier merged commit 2dac7b8 into jschneier:master Jun 6, 2020
@jdufresne jdufresne deleted the drop-py2 branch June 6, 2020 02:00
@jdufresne jdufresne mentioned this pull request Jul 7, 2020
mlazowik pushed a commit to qedsoftware/django-storages that referenced this pull request Mar 9, 2022
* Drop support for Python 2

Python 2 support is nearing end of life. At the end of this year, it
will no longer be supported, including for security issues.

Django has already dropped support for Python 2 in Django 2.0. Follow
upstream to be more compatible with the master branch as tests now pass.

For more details, see https://pythonclock.org/

All code changes and clean ups that were noticed were done. Changes
include:

- Remove str/unicode compatibility shims.
- Remove encoding cookies from source files. Python 3 interprets all
  files as utf-8 by default.
- Remove unnecessary __future__ imports. The features are now built-in.
- Use modern and simpler super() syntax.
- Update the wheel configuration to reflect it is no longer universal.
- Update trove classifiers.
- And more …

Also remove supported for end of life Python 3.4. It went end of life
2019-03-18.

Fixes jschneier#849

* Update uses of force_text → force_str to avoid deprecation warnings

Django deprecated force_text() and smart_text() in favor of force_str()
and smart_str() in:

django/django@d55e882

Fixes jschneier#806

* Remove unnecessary uses of (force|smart)_str

As django-storages is now Python 3 only, handling both bytes & string
paths is now unnecessary. In Python 3 with Django, paths are always
a string.

* Replace deprecated IOError with more specific FileNotFoundError

Since Python 3.3, IOError has been merged into OSError.
FileNotFoundError is a subclass, so its use is fully backwards
compatible.

* Remove unnecessary 'utf-8' from .encode()/.decode()

In Python3, these methods default to UTF-8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants