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

Generate module version file at build #859

Merged
merged 2 commits into from Dec 22, 2023
Merged

Conversation

4383
Copy link
Member

@4383 4383 commented Dec 21, 2023

Gunicore rely on eventlet.__version__ [1], however this data have been removed during our modernization of the continuous deployment mechanisms [2].

People reported problem with gunicore after 0.34.1 [3][4], so, it could be worth to reintroduce similar version info, to avoid side effects.

This patch propose to use a hatch-vcs hook [5] to generate dynamically, at build, the missing data. Other solutions exists but each of them have their own problems [6].

Indeed, considering "footgun" described in [6] I choose the hatch-vcs approach, because, retrieving a wrong version number during development when the lib is installed in editable mode, is not, I think, something horrible. I prefer this side effect rather than relying on another additional underlying library just to print a version number when eventlet is installed in editable mode. A new additional requirement which would be installed anytime at runtime and production.

Moreover, sometimes you want to import a package from a development repository tarball you just downloaded (where
there's no metadata or Git tags present). So, Using setuptools_scm or importlib.metadata.version won't works in that context.

Fix benoitc/gunicorn#3120

[1] benoitc/gunicorn#3120
[2] #845
[3] #845 (comment)
[4] #842 (comment)
[5] https://github.com/ofek/hatch-vcs#build-hook
[6] https://github.com/maresb/hatch-vcs-footgun-example

Copy link

codecov bot commented Dec 21, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (b738b0a) 53% compared to head (44fee01) 53%.
Report is 3 commits behind head on master.

Files Patch % Lines
eventlet/__init__.py 50% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##           master   #859   +/-   ##
=====================================
- Coverage      53%    53%   -1%     
=====================================
  Files          88     88           
  Lines        9887   9891    +4     
  Branches     1854   1854           
=====================================
+ Hits         5337   5338    +1     
- Misses       4160   4163    +3     
  Partials      390    390           
Flag Coverage Δ
ipv6 22% <50%> (+<1%) ⬆️
py310epolls 52% <50%> (-1%) ⬇️
py310poll 52% <50%> (-1%) ⬇️
py310selects 52% <50%> (-1%) ⬇️
py311epolls 52% <50%> (-1%) ⬇️
py312epolls 50% <50%> (-1%) ⬇️
py37epolls 50% <50%> (-1%) ⬇️
py38epolls 52% <50%> (-1%) ⬇️
py38openssl 51% <50%> (-1%) ⬇️
py38poll 52% <50%> (-1%) ⬇️
py38selects 52% <50%> (-1%) ⬇️
py39dnspython1 50% <50%> (-1%) ⬇️
py39epolls 52% <50%> (-1%) ⬇️
py39poll 52% <50%> (-1%) ⬇️
py39selects 52% <50%> (-1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@4383 4383 force-pushed the fix-version branch 3 times, most recently from 410ddcf to f892fc3 Compare December 21, 2023 13:09
@pajod
Copy link

pajod commented Dec 21, 2023

@4383 Thanks.
And yes, these version checks should really be left for apt/setuptools to worry about, and where they stood there should be assertions about using the intended stdlib/patched modules.. but even the prerequisite patch series for modernize efforts like that still need work, so I appreciate the API stability until there is a clear upgrade path for incompatible versions.

Copy link
Contributor

@itamarst itamarst left a comment

Choose a reason for hiding this comment

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

I tested python -m build and it doesn't actually include a _version.py file, probably because of the config issue noted in the review comments.

eventlet/__init__.py Outdated Show resolved Hide resolved
eventlet/__init__.py Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@4383
Copy link
Member Author

4383 commented Dec 21, 2023

I tested python -m build and it doesn't actually include a _version.py file, probably because of the config issue noted in the review comments.

Successfully tested locally. Thanks

warnings.warn(
"Support for your Python version is deprecated and will be removed in the future",
"Your Python version is no longer supported by eventlet",
"Please consider upgrading to minimal supported Python version",

Choose a reason for hiding this comment

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

this raises an error for me, you'll have to make the warning a single str arg

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

>>> import eventlet
>>> eventlet.__version__
'0.34.2.dev1+gc2236b8.d20231222'

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me know if you still face the error.

Choose a reason for hiding this comment

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

I must admit that originally I didn't actually test with python3.6, but just ran the warn() statement in py3.10, because I wanted to see how the multiline message would look like. With your original code, the issue would only be triggered when running with py3.6 or older. Now actually testing with py3.6, the error is gone, but also the deprecation warning actually isn't actually shown by default, since https://peps.python.org/pep-0565/ was only implemented for py3.7. So one would have to set something like PYTHONWARNINGS=error for the warning to actually take effect. This may just be the expected behavior and maybe I'm worrying too much about historic python versions, but maybe the alternative option of changing the warning to be a real error immediately might be a better solution?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your verification, and for your advices, they are really relevant.

Let's remove, from this pull request, the changes related to this warning. We can handle it in a separated pull request to more isolate the topics. I prefer to keep this pull request more focused on the sole topic of python version. I should have treated them separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

And anyway, this warning will be removed by https://github.com/eventlet/eventlet/pull/853/files
So, I suggest we do not waste time on it anywhere else.

# hatch have a build hook who generate version file, however,
# if the project is installed in editable mode then the _version.py file
# will not be updated unless the package is reinstalled (or locally rebuilt).
# for further details, please read:

Choose a reason for hiding this comment

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

Suggestion to fix grammar and spelling:

# NOTE(hberaud): Versions are now managed by hatch and control version.
# hatch has a build hook which generates the version file, however,
# if the project is installed in editable mode then the _version.py file
# will not be updated unless the package is reinstalled (or locally rebuilt).
# For further details, please read:

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to your proposal.

Gunicore rely on `eventlet.__version__` [1], however
this data have been removed during our modernization
of the continuous deployment mechanisms [2].

People reported problem with gunicore after 0.34.1 [3][4],
so, it could be worth to reintroduce similar version info,
to avoid side effects.

This patch propose to use a `hatch-vcs` hook [5] to generate
dynamically, at build, the missing data. Other solutions exists
but each of them have their own problems [6].

Indeed, considering "footgun" described in [6] I choose the
hatch-vcs approach, because, retrieving a wrong version number
during development when the lib is installed in editable mode,
is not, I think, something horrible. I prefer this side effect
rather than relying on another additional underlying library
just to print a version number when eventlet is installed in
editable mode. A new additional requirement which would be
installed anytime at runtime and production.

Moreover, sometimes you want to import a package from a
development repository tarball you just downloaded (where
there's no metadata or Git tags present). So, Using
`setuptools_scm` or `importlib.metadata.version` won't
works in that context.

Fix benoitc/gunicorn#3120

[1] benoitc/gunicorn#3120
[2] eventlet#845
[3] eventlet#845 (comment)
[4] eventlet#842 (comment)
[5] https://github.com/ofek/hatch-vcs#build-hook
[6] https://github.com/maresb/hatch-vcs-footgun-example
Copy link
Contributor

@itamarst itamarst left a comment

Choose a reason for hiding this comment

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

Thank you!

@itamarst
Copy link
Contributor

I added a .gitignore entry for _version.py. Looks good to merge.

@4383 4383 merged commit c85bd19 into eventlet:master Dec 22, 2023
19 of 20 checks passed
openstack-mirroring pushed a commit to openstack/requirements that referenced this pull request Jan 16, 2024
Several important and urgent fixes are released there.

0.34.3
======

eventlet/eventlet#875

* Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
* Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
* greendns: fix getaddrinfo parameter name eventlet/eventlet#809
* Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
* Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
* Skip test which uses Py cgi module eventlet/eventlet#865
* Drop old code based on python < 3.7.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Jan 16, 2024
* Update requirements from branch 'master'
  to 827a86739e66ffb537b5ea7a65a3cc74eb3fabf1
  - Merge "Update eventlet to 0.34.3"
  - Update eventlet to 0.34.3
    
    Several important and urgent fixes are released there.
    
    0.34.3
    ======
    
    eventlet/eventlet#875
    
    * Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
    * Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
    * greendns: fix getaddrinfo parameter name eventlet/eventlet#809
    * Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
    * Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
    * Skip test which uses Py cgi module eventlet/eventlet#865
    * Drop old code based on python < 3.7.34.2
    ======
    
    eventlet/eventlet#861
    
    * Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
    * [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
    * [doc] Fix pypi broken link eventlet/eventlet#857
    
    0.34.1
    ======
    
    eventlet/eventlet#842
    
    * [bug] Fix memory leak in greendns eventlet/eventlet#810
    * [infra] Fix OIDC authentication failure eventlet/eventlet#855
    * [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804
    
    0.34.0 (Not released on Pypi but landed with 0.34.1)
    ====================================================
    
    * Dropped support for Python 3.6 and earlier.
    * Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
    * Add support of Python 3.12 eventlet/eventlet#817
    * Drop unmaintained and unused stdlib tests eventlet/eventlet#820
    * Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
    * Stop claiming to create universal wheels eventlet/eventlet#841
    * Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754
    
    Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Jan 30, 2024
* Update requirements from branch 'master'
  to 08f829d8375b4059af365191e0907069be9fb739
  - Update eventlet to 0.35.0
    
    0.35.0
    ======
    
    eventlet/eventlet#897
    
    * [fix] fix truncate size nullable eventlet/eventlet#789
    * [fix] Handle transport endpoint shutdown in conditions eventlet/eventlet#884
    * [fix] Rework reject_bad_requests option eventlet/eventlet#890
    * [fix] Fix NameError introduced by #826 eventlet/eventlet#890
    * [feature] Support awaiting GreenThread in an `async def` context eventlet/eventlet#889
    * [feature] Asyncio hub support for Python 3.7 to 3.9 eventlet/eventlet#886
    * [fix] Fix bad exceptions handlings eventlet/eventlet#883
    * [feature] Support using asyncio coroutines from inside greenlets eventlet/eventlet#877
    * [removal] Remove deprecated CGIHTTPServer and SimpleHTTPServer eventlet/eventlet#881
    * [feature] Add an asyncio hub for eventlet eventlet/eventlet#870
    
    0.34.3
    ======
    
    eventlet/eventlet#875
    
    * Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
    * Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
    * greendns: fix getaddrinfo parameter name eventlet/eventlet#809
    * Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
    * Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
    * Skip test which uses Py cgi module eventlet/eventlet#865
    * Drop old code based on python < 3.7.34.2
    ======
    
    eventlet/eventlet#861
    
    * Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
    * [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
    * [doc] Fix pypi broken link eventlet/eventlet#857
    
    0.34.1
    ======
    
    eventlet/eventlet#842
    
    * [bug] Fix memory leak in greendns eventlet/eventlet#810
    * [infra] Fix OIDC authentication failure eventlet/eventlet#855
    * [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804
    
    0.34.0 (Not released on Pypi but landed with 0.34.1)
    ====================================================
    
    * Dropped support for Python 3.6 and earlier.
    * Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
    * Add support of Python 3.12 eventlet/eventlet#817
    * Drop unmaintained and unused stdlib tests eventlet/eventlet#820
    * Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
    * Stop claiming to create universal wheels eventlet/eventlet#841
    * Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754
    
    Change-Id: I909be1d1812eaed574525866dbc123083684571d
openstack-mirroring pushed a commit to openstack/requirements that referenced this pull request Jan 30, 2024
0.35.0
======

eventlet/eventlet#897

* [fix] fix truncate size nullable eventlet/eventlet#789
* [fix] Handle transport endpoint shutdown in conditions eventlet/eventlet#884
* [fix] Rework reject_bad_requests option eventlet/eventlet#890
* [fix] Fix NameError introduced by #826 eventlet/eventlet#890
* [feature] Support awaiting GreenThread in an `async def` context eventlet/eventlet#889
* [feature] Asyncio hub support for Python 3.7 to 3.9 eventlet/eventlet#886
* [fix] Fix bad exceptions handlings eventlet/eventlet#883
* [feature] Support using asyncio coroutines from inside greenlets eventlet/eventlet#877
* [removal] Remove deprecated CGIHTTPServer and SimpleHTTPServer eventlet/eventlet#881
* [feature] Add an asyncio hub for eventlet eventlet/eventlet#870

0.34.3
======

eventlet/eventlet#875

* Fix security issue in the wsgi module related to RFC 9112 eventlet/eventlet#826
* Fix segfault, a new approach for greening existing locks eventlet/eventlet#866
* greendns: fix getaddrinfo parameter name eventlet/eventlet#809
* Fix deprecation warning on ssl.PROTOCOL_TLS eventlet/eventlet#872
* Pytests, fix error at teardown of TestGreenSocket.test_full_duplex eventlet/eventlet#871
* Skip test which uses Py cgi module eventlet/eventlet#865
* Drop old code based on python < 3.7.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: I909be1d1812eaed574525866dbc123083684571d
tanaypf9 pushed a commit to tanaypf9/pf9-requirements that referenced this pull request May 20, 2024
Several important and urgent fixes are released there.

0.34.2
======

eventlet/eventlet#861

* Allowing inheritance of GreenSSLSocket without overriding the __new_ method eventlet/eventlet#796
* [bug] Fix broken API related to `__version__` removal eventlet/eventlet#859
* [doc] Fix pypi broken link eventlet/eventlet#857

0.34.1
======

eventlet/eventlet#842

* [bug] Fix memory leak in greendns eventlet/eventlet#810
* [infra] Fix OIDC authentication failure eventlet/eventlet#855
* [bug] Ignore asyncore and asynchat for Python 3.12+ eventlet/eventlet#804

0.34.0 (Not released on Pypi but landed with 0.34.1)
====================================================

* Dropped support for Python 3.6 and earlier.
* Fix Python 3.13 compat by adding missing attibute '_is_main_interpreter' eventlet/eventlet#847
* Add support of Python 3.12 eventlet/eventlet#817
* Drop unmaintained and unused stdlib tests eventlet/eventlet#820
* Fix tests and CI for Python 3.7 and higher eventlet/eventlet#831 and eventlet/eventlet#832
* Stop claiming to create universal wheels eventlet/eventlet#841
* Fix green logging locks for Python versions <= 3.10 eventlet/eventlet#754

Change-Id: Ib2e59a207b86ae90fa391bf1dff7819851dc9c9b
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.

eventlet 0.34.1 doesnt work with gunicorn 21.2.0
5 participants