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

Only import future for py2 #343

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

NathanielRN
Copy link
Contributor

Issue #, if available: #212

Description of changes:

If we only import future when the SDK is run on Python 2, then we don't need to import it for Python 3 systems. This will prevent conflicts with people downloading conflicting versions of the future package.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Fixes: #212

@NathanielRN NathanielRN requested a review from a team as a code owner June 23, 2022 19:50
@NathanielRN NathanielRN requested a review from srprash June 23, 2022 19:51
@NathanielRN NathanielRN marked this pull request as draft June 23, 2022 20:02
@NathanielRN NathanielRN force-pushed the only-import-future-for-py2 branch from 2db7bbf to c45c8e6 Compare June 23, 2022 20:06
@NathanielRN NathanielRN marked this pull request as ready for review June 23, 2022 21:14
Comment on lines 3 to 7
try:
from future.standard_library import install_aliases
install_aliases()
except ImportError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using try-except, can we reuse the PY2 variable from compat.py?

Then this could be something like:

from aws_xray_sdk.core.utils.compat import PY2
    
if PY2:
    from future.standard_library import install_aliases
    install_aliases()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh interesting! I took this path because StackOverflow says it was the status quo and I saw it used in OpenTelemetry Python Contrib, but this PY2 looks super useful so I'll change it to that :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. That's good to know. :)
Since we already have the other mechanism, I think it would be better to just reuse for the sake of consistency.

@NathanielRN NathanielRN force-pushed the only-import-future-for-py2 branch from c45c8e6 to 245c9c6 Compare June 24, 2022 17:51
@NathanielRN NathanielRN requested a review from srprash June 24, 2022 17:51
@srprash srprash merged commit c6d1f06 into aws:master Jun 24, 2022
@NathanielRN NathanielRN deleted the only-import-future-for-py2 branch June 24, 2022 18:00
This was referenced Jun 24, 2022
michael-k added a commit to michael-k/aws-xray-sdk-python that referenced this pull request Nov 4, 2022
An environment marker is already used for `enum34` so why do it
differently for `future`?
https://peps.python.org/pep-0508/#environment-markers

ref aws#343
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.

future dependency should be scoped to python 2 in setup.py
2 participants