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

Python: further trim dependencies #2401

Closed
2 tasks
matrey opened this issue Oct 8, 2024 · 3 comments · Fixed by #2415
Closed
2 tasks

Python: further trim dependencies #2401

matrey opened this issue Oct 8, 2024 · 3 comments · Fixed by #2415

Comments

@matrey
Copy link

matrey commented Oct 8, 2024

Describe the feature

Once the change from #2298 is released, the deps should be:

dependencies = [
    "async-timeout>=4.0.2",
    "typing-extensions>=4.8.0",
    "protobuf>=3.20"
]

This could be further optimized, with async-timeout and typing-extensions (which is only used so far for Self) not being needed for Python 3.11+

1/
https://github.com/aio-libs/async-timeout reads:

DEPRECATED

This library has effectively been upstreamed into Python 3.11+. Therefore this library is considered deprecated and no longer supported. We'll keep the project open in the unlikely case of security issues until Python 3.10 is officially unsupported.

To migrate a project that needs to support multiple Python versions, we suggest using this code (used in our other projects, such as aiohttp):

if sys.version_info >= (3, 11):
    import asyncio as async_timeout
else:
    import async_timeout

Then in your dependencies, use:

async-timeout >= 4; python_version < "3.11"

2/
Looking for typing_extensions in the codebase on main, only 1 match came up:

from typing_extensions import Self

Same here, Self is available from typing starting with Python 3.11 so the requirement could be narrowed to ; python_version < "3.11"

Then adapt the code:

Potential approach from https://github.com/SimplyPrint/printer-ws-client/pull/4/files

try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

Potential approach from https://github.com/stac-utils/stac-geoparquet/pull/67/files

if sys.version_info >= (3, 11):
    from typing import Self
else:
    from typing_extensions import Self

Use Case

Less unneeded deps for Python 3.11+

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Client version used

1.1.0

Environment details (OS name and version, etc.)

python 3.11 on linux amd64

@avifenesh
Copy link
Collaborator

avifenesh commented Oct 8, 2024

@matrey
Thanks for opening the issue!
Putting conditional package management solution here for later use.

We will take a look at it and will implement, understand the importance, and your examples of implementation are helpful.

Can you elaborate on your reasons for caring about it from your side? We would like to have a better grasp on users needs.
If you can share your general use case, even better.
We can talk directly if you want here.

@matrey
Copy link
Author

matrey commented Oct 9, 2024

We have a list of "pre-approved" open source licenses at work (to make sure we don't inadvertently infringe on some clauses), so I made some scripts that force me to vet any new dependency (by referencing a link to its LICENSE file, which requires me to go look at the source repo for each package). This is how I ended up discovering that 2 dependencies could actually be omitted altogether for the Python version I use (3.11).

It's very minor and not a blocker for me, especially compared to #2298

@avifenesh
Copy link
Collaborator

avifenesh commented Oct 9, 2024

We have a list of "pre-approved" open source licenses at work (to make sure we don't inadvertently infringe on some clauses), so I made some scripts that force me to vet any new dependency (by referencing a link to its LICENSE file, which requires me to go look at the source repo for each package). This is how I ended up discovering that 2 dependencies could actually be omitted altogether for the Python version I use (3.11).

It's very minor and not a blocker for me, especially compared to #2298

I see, thanks for the details!
We also deliver non-blocking requests :) I didn't mean to measure importance, apologizing if this how it sounds.
My intention was to get some general picture of needs and use cases so we can further learn and improve.

The request seems simple enough to be added to the close release.

avifenesh pushed a commit that referenced this issue Oct 10, 2024
#2415)

Python: remove `async_timeout` and `typing_extensions` dependencies for Python 3.11 and higher (#2401)

Signed-off-by: Jakob Keller <57402305+jakob-keller@users.noreply.github.com>
Muhammad-awawdi-amazon pushed a commit that referenced this issue Oct 14, 2024
#2415)

Python: remove `async_timeout` and `typing_extensions` dependencies for Python 3.11 and higher (#2401)

Signed-off-by: Jakob Keller <57402305+jakob-keller@users.noreply.github.com>
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 a pull request may close this issue.

2 participants