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

Removed Python2 support #7031

Merged
merged 7 commits into from
Jun 10, 2020
Merged

Removed Python2 support #7031

merged 7 commits into from
Jun 10, 2020

Conversation

venthur
Copy link
Contributor

@venthur venthur commented Nov 19, 2019

This PR removes Python2 support and removes all traces of six.

Closes: #6890

Signed-off-by: Bastian Venthur [email protected]

Resolves #6890
Resolves #7503

@ndeloof
Copy link
Contributor

ndeloof commented Nov 19, 2019

build failure is expected as the Jenkinsfile being built is the one from target branch, not the one modified by PR.
@ulyssessouza are you ok I remove py27 from Jenkinsfile (which we plan to replace by #6932 anyway) so this PR can be tested by CI?

@venthur
Copy link
Contributor Author

venthur commented Nov 19, 2019

Yes please :)
I was desperately searching for any py27 occurrences in the code.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 19, 2019

I was expecting so, so my comment :) I had such issue myself in the past and started getting crazy.

@ulyssessouza
Copy link
Collaborator

Hello @venthur ! Thank you for the PR!

@ndeloof Is right about the Jenkinsfile.

My problem with this PR landing now is that Python2 is not in the EOL. Sorry, but it's too early to merge it. That would break people's code without having the Python2.7 EOL to back our move.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 19, 2019

Python 2 will be EOL in a few weeks, and this would only impact people who consider docker-compose as a library to build third party products, which we know exists but never aknowledge we want to support. We should be free to refactor our codebase and drop python 2 support as long as the CLI tool is available to our end-user base.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 19, 2019

see #7034

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

@venthur could you please reconfigure your PR to target py2 branch ?
I've disabled 2.7 as a target on this one, so we will get a real CI to prepare this move.

@venthur venthur changed the base branch from master to py2 November 20, 2019 13:36
@venthur
Copy link
Contributor Author

venthur commented Nov 20, 2019

@ndeloof Did I do something wrong?

@docker docker deleted a comment from GordonTheTurtle Nov 20, 2019
@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

nope, I just missed the reference to python 2.7 by .tox.

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

No module named 'requests' seems the build script goes way beyond my understanding...

@venthur
Copy link
Contributor Author

venthur commented Nov 20, 2019

I don't know what's going on either, I double-checked the diff, requests does not even show up in them.

I did however remove python2(-dev) from the Dockerfile w/o replacing it with python3, I can try again with adding python3...

EDIT: also you can see requests was actually installed

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

please give me some time to get py2 branch fixed ;)

@ndeloof
Copy link
Contributor

ndeloof commented Nov 20, 2019

I was able to fix the py2 branch (https://ci.docker.com/public/blue/organizations/jenkins/compose/detail/py2/3/pipeline/) and rebased your PR on top (I had to force push, so if you need to make some changes, be carreful to re-create your local branch from https://github.com/venthur/compose/tree/remove_python2)

@venthur
Copy link
Contributor Author

venthur commented Nov 21, 2019

Nice!

With respect to the merge, I also tend to agree that it should not matter if we merge it now, as long as the CLI has a major version bump. If people consume directly from master and still depend on Python2, well that's dangerous anyways these days.

On the other hand, if the patch itself looks good to you and is likely to be merged at some point, I don't have a problem maintaining it for a while.

@venthur
Copy link
Contributor Author

venthur commented Jan 3, 2020

Python2 reached its EOL, can we merge now?

compose/utils.py Outdated Show resolved Hide resolved
tests/__init__.py Outdated Show resolved Hide resolved
tests/__init__.py Outdated Show resolved Hide resolved
Copy link

@graingert graingert left a comment

Choose a reason for hiding this comment

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

Please merge #6623 first

@venthur
Copy link
Contributor Author

venthur commented Feb 11, 2020

So, it's mid-February. Any chance we can drop Py2 support by merging? :)

@ulyssessouza
Copy link
Collaborator

@venthur Sorry for the late reply, but we got to the conclusion (based on pypi downloads data) that it would be more prudent to sync that with the next Ubuntu release. That new release will eliminate Python2.

@alexrecuenco
Copy link

I was working on a branch before I noticed you had already done most of the same things I did @venthur . Is it ok if I add to it? In my branch I also changed dictionary comprehensions and other details that are cleaner in python3. (Like format strings)

@graingert
Copy link

graingert commented Mar 10, 2020 via email

@alexrecuenco
Copy link

alexrecuenco commented Mar 11, 2020

You might want to run and add pyupgrade as a pre-commit hook

I noticed we are on this branch far behind master, can we rebase?

After all, this change affects almost all files, it should probably be done close to the tip.

We can rebase from 1.26.x, since this is a 1.26 goal anyway.

Is that ok?

alex-ubitec pushed a commit to alex-ubitec/compose that referenced this pull request Mar 11, 2020
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <[email protected]>

Removed Python2 support

Closes: docker#6890

Signed-off-by: Bastian Venthur <[email protected]>

Removed six

Signed-off-by: Bastian Venthur <[email protected]>
alex-ubitec pushed a commit to alex-ubitec/compose that referenced this pull request Mar 11, 2020
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <[email protected]>

Removed Python2 support

Closes: docker#6890

Signed-off-by: Bastian Venthur <[email protected]>

Removed six

Signed-off-by: Bastian Venthur <[email protected]>

Removed now useless check for version_info >= 2.7

Signed-off-by: Bastian Venthur <[email protected]>

Removed now unused get_output_stream method

Signed-off-by: Bastian Venthur <[email protected]>

Import unittest.mock directly.

We don't need to support Python2 anymore.

Signed-off-by: Bastian Venthur <[email protected]>
alex-ubitec pushed a commit to alex-ubitec/compose that referenced this pull request Mar 11, 2020
----

Downgrade gitpython to 2.1.15 and idna to 2.8

Signed-off-by: Ulysses Souza <[email protected]>

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

How we removed six from docker-compose

We expect this to happen in a couple steps,

1. Remove six entirely, and remove python2.7 from requirements, setup, etc.
2. cleanup code that is left (All the conditionals that are now always True or False)
3. Remove all unnecessary `__future__` commands, by modifying the pre-commit-hook of python sourts to be `--py3-plus`

After removing all occurrances, we made sure `six` wasn't used anymore running a search for

```txt
six\.\w+\(([^()]+)\)
```
- We replaced all types for their corresponding python3 types. Note how
  six returns a tuple for the isinstance (since in python2 there are
  more than one type, but that isn't necessary in python3, so we removed
  the tuple and instead used the class directly)

We then searched for all instances where code could be pruned. (i.e., if/else clauses that now where always `True` or `False`)

After that,

- Removed inheritinng from `object` super class, it isn't necessary in python3
- `# coding ... utf-8` statements are not needed
- `super(ClassName, self)` can now be replaced with `super()`
alex-ubitec pushed a commit to alex-ubitec/compose that referenced this pull request Mar 12, 2020
----

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

How we removed six from docker-compose

We expect this to happen in a couple steps,

1. Remove six entirely, and remove python2.7 from requirements, setup, etc.
2. cleanup code that is left (All the conditionals that are now always True or False)
3. Remove all unnecessary `__future__` commands, by modifying the pre-commit-hook of python sourts to be `--py3-plus`

After removing all occurrances, we made sure `six` wasn't used anymore running a search for

```txt
six\.\w+\(([^()]+)\)
```
- We replaced all types for their corresponding python3 types. Note how
  six returns a tuple for the isinstance (since in python2 there are
  more than one type, but that isn't necessary in python3, so we removed
  the tuple and instead used the class directly)

We then searched for all instances where code could be pruned. (i.e., if/else clauses that now where always `True` or `False`)

After that,

- Removed inheritinng from `object` super class, it isn't necessary in python3
- `# coding ... utf-8` statements are not needed
- `super(ClassName, self)` can now be replaced with `super()`

Signed-off-by: Alejandro G. Recuenco <[email protected]>
alexrecuenco pushed a commit to alexrecuenco/compose that referenced this pull request Mar 14, 2020
----

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

How we removed six from docker-compose

We expect this to happen in a couple steps,

1. Remove six entirely, and remove python2.7 from requirements, setup, etc.
2. cleanup code that is left (All the conditionals that are now always True or False)
3. Remove all unnecessary `__future__` commands, by modifying the pre-commit-hook of python sourts to be `--py3-plus`

After removing all occurrances, we made sure `six` wasn't used anymore running a search for

```txt
six\.\w+\(([^()]+)\)
```
- We replaced all types for their corresponding python3 types. Note how
  six returns a tuple for the isinstance (since in python2 there are
  more than one type, but that isn't necessary in python3, so we removed
  the tuple and instead used the class directly)

We then searched for all instances where code could be pruned. (i.e., if/else clauses that now where always `True` or `False`)

After that,

- Removed inheritinng from `object` super class, it isn't necessary in python3
- `# coding ... utf-8` statements are not needed
- `super(ClassName, self)` can now be replaced with `super()`

Signed-off-by: alexrecuenco <[email protected]>
alexrecuenco pushed a commit to alexrecuenco/compose that referenced this pull request Mar 14, 2020
----

Removed Python2 support

Closes: docker#6890

- Removed six
- Removed now useless check for version_info >= 2.7
- Removed now unused get_output_stream method
- Import unittest.mock directly.

Signed-off-by: Ulysses Souza <[email protected]>
@ulyssessouza
Copy link
Collaborator

@venthur Can you rebase this PR pls? We are finally ready to merge

venthur added 6 commits June 3, 2020 17:37
Closes: docker#6890

Signed-off-by: Bastian Venthur <[email protected]>
Signed-off-by: Bastian Venthur <[email protected]>
We don't need to support Python2 anymore.

Signed-off-by: Bastian Venthur <[email protected]>
@venthur venthur changed the base branch from py2 to master June 3, 2020 16:14
@venthur venthur requested review from ndeloof and rumpl as code owners June 3, 2020 16:23
@venthur
Copy link
Contributor Author

venthur commented Jun 3, 2020

Done, re-based onto current master.

Copy link
Collaborator

@ulyssessouza ulyssessouza left a comment

Choose a reason for hiding this comment

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

LGTM

@ulyssessouza ulyssessouza merged commit 854c14a into docker:master Jun 10, 2020
@ulyssessouza
Copy link
Collaborator

Thank you @venthur !
And sorry for the delay

@remram44
Copy link

remram44 commented Aug 5, 2020

This removed release.py script completely? Was that intended?

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.

[master|1.26.0] Test "test_container_attach_event" produces unhealthy output Remove Python2
7 participants