Switch configobj from bundled dependency to PyPI package - #20172
Switch configobj from bundled dependency to PyPI package#20172Andrej730 wants to merge 21 commits into
configobj from bundled dependency to PyPI package#20172Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
pllim
left a comment
There was a problem hiding this comment.
Sorry. We do accept patches to extern. Packages in that directory are bundled as-is.
@pllim But I just bumped bundled version of configobj, code comes completely from upstream. It's not acceptable too? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
OK looks like at some point things got moved around and upgrade became non-trivial. Looks like you attempted to account for that, so I will re-open this for review but I cannot promise when someone can get to it. Thanks. |
|
|
||
| from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE | ||
|
|
||
| from ._version import __version__ |
There was a problem hiding this comment.
Why is this needed though. It is not used.
There was a problem hiding this comment.
It's just a convention to quickly retrieve package version. It's not really needed, just kept everything exactly as it is upstream, so the next person bumping dependency wouldn't need to think about whether to keep this diff or not.
>>> import configobj
>>> configobj.__version__
'5.0.9'
pllim
left a comment
There was a problem hiding this comment.
I wonder if it would be easier on us in this repo if we undo the renaming stuff from upstream and keep the original filenames here. Then add a note about that for the next upgrade in the future.
|
Would need a change log under "other" as well. |
7395348 to
745b7a6
Compare
From the current packaging mechanism it seems to bundle everything it can find in Lines 213 to 216 in c586ab9 But it's really up to you, whatever seems more convenient from your perspective. From my point of view, ideally, is to keep differences with upstream minimal, so bumping bundled dependency can be -
So any difference from upstream requires the next person maintaining this to reason it through - whether moving files is okay or it should be undone, they will also need to clean up whitespace changes each time, etc. But this dependency had 70 LOC updated in 12 years, so any solution will work 😄
Added it. |
|
@astrofrog or @neutrinoceros , any preference on how we want to bundle this going forward? Now that I dig more, we seem to have patched some important stuff over the years without renaming files. 🤷♀️ I will wait to run CI until we figure out the file organization. Thanks! |
neutrinoceros
left a comment
There was a problem hiding this comment.
From my point of view, ideally, is to keep differences with upstream minimal
strong +1
if we can, we shouldn't rename anything. Though I reckon I don't know the history here, does anyone know what we did so far and why ?
There was a problem hiding this comment.
Not sure porting this file as is makes sense.
import validatewill not work- we don't need a backward compatible layer since this module is only meant for internal use
There was a problem hiding this comment.
But then removing this shim means we also need to skip rename and keep validate.py as astropy/extern/configobj/validate.py, so it's an extra thing to remember when bumping this dependency in the future. Any harm in keeping the shim as-is?
There was a problem hiding this comment.
You're right, better keep everything close to source
|
Can anyone remember why we are even bundling this in the first place? Does this date back to when we could only have numpy as a dependency? Could we just not bundle it anymore? |
|
Good point. I'd be in favour of just depending on the original third party package and found no argument against it: it has (pure Python) wheels on PyPI and is available through conda-forge too. |
|
Can someone check the commit history and maybe issue/PR history for why it was bundled, to double check I am not missing something? |
|
Ha, it's been a while since 6560e0c Don't know the reasoning, but there is this sentence in the code guide: astropy/docs/development/codeguide.rst Lines 20 to 23 in 02f3328 But it seems to be stale now, since repo has pyyaml, pyerfa and packaging. So, time to move on from it? Lines 45 to 51 in 02f3328 A heads up - another bundled dependency, |
|
Thanks! If configobj is a well maintained dependency, I don't see any reason to not just have it as a regular dependency. |
|
I have an old note somewhere that said it was unmaintained. Or maybe I was just confused... or someone took it up? |
configobj from bundled dependency to PyPI package
| from warnings import warn | ||
|
|
||
| import configobj | ||
| import configobj as validate |
There was a problem hiding this comment.
I'd rather we just use a single alias for every namespace.
| "pyerfa>=2.0.1.3", | ||
| "configobj>=5.0.9"] |
There was a problem hiding this comment.
I don't understand why this would be needed. Could you show me where is configobj used at build time ?
There was a problem hiding this comment.
Sure, it's needed because of install_stubs in setup.py, which triggers astropy import and then astropy.config.configuration import.
Lines 19 to 27 in 345a338
Here's the traceback when trying to uv pip install -e . without configobj as a build dependency (when running uv build traceback is similar)
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/build_meta.py", line 410, in _build_with_temp_dir
self.run_setup()
~~~~~~~~~~~~~~^^
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/build_meta.py", line 317, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 52, in <module>
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/__init__.py", line 117, in setup
return distutils.core.setup(**attrs) # type: ignore[return-value]
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/_distutils/core.py", line 186, in setup
return run_commands(dist)
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
dist.run_commands()
~~~~~~~~~~~~~~~~~^^
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1001, in run_commands
self.run_command(cmd)
~~~~~~~~~~~~~~~~^^^^^
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
super().run_command(command)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "~/.cache/uv/builds-v0/.tmpnRSaPV/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1020, in run_command
cmd_obj.run()
~~~~~~~~~~~^^
File "<string>", line 43, in run
File "<string>", line 22, in install_stubs
File "~/astropy/astropy/__init__.py", line 64, in <module>
from . import config as _config
File "~/astropy/astropy/__init__.py", line 55, in __getattr__
return import_module("astropy." + attr)
File "~/.local/share/uv/python/cpython-3.14.4-linux-x86_64-gnu/lib/python3.14/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "~/astropy/astropy/config/__init__.py", line 8, in <module>
from .configuration import *
File "~/astropy/astropy/config/configuration.py", line 31, in <module>
import configobj.validate
ModuleNotFoundError: No module named 'configobj'
There was a problem hiding this comment.
Makes sense. I forgot these stubs were so involved to generate... well, that's more dependencies to trim for me, but clearly out of scope for this PR. Thanks !
There was a problem hiding this comment.
In 84b08f9 found that one of the CIs is building astropy manually, so it will need configobj too to succeed.
| from warnings import warn | ||
|
|
||
| import configobj | ||
| import configobj.validate as validate |
There was a problem hiding this comment.
Non-aliasing as imports tend to be used, by convention, to indicate an intentional re-export, which I don't think we want here
| import configobj.validate as validate | |
| from configobj import validate |
On Ubuntu 24.04 configobj is available as 5.0.8, we have 5.0.9 pinned. There's no critical difference between 5.0.8 and 5.0.9, but 5.0.9 is already almost 2 years old, so it's probably the better one to pin.
|
Ah, tried to cherry-pick |
|
The way to fix it is to checkout the file from |
|
Should be complete now, remaining CI failures are unrelated. |
| "extension-helpers>=1.4,<2", | ||
| "pyerfa>=2.0.1.3"] | ||
| "pyerfa>=2.0.1.3", | ||
| "configobj>=5.0.9"] |
There was a problem hiding this comment.
Nit: this makes it so that next time we need to add something there, we won't loose the ability to use git blame for this one
| "configobj>=5.0.9"] | |
| "configobj>=5.0.9", | |
| ] |
Co-authored-by: Clément Robert <cr52@protonmail.com>
|
Are we sure we don't want to wait till v9.0 for such things? This has real downstream impact: |
|
AFAIC I think we better bite the bullet in the next feature release. We could easily add a backwards compatibility layer in the form of a (deprecated) re-export if necessary |
Description
Hi, noticed Python 2 workaround still present on the repo and wanted to help to get rid of them.
astropy/astropy/extern/configobj/validate.py
Lines 167 to 185 in 55da6b4
Checked the code upstream and it's already resolved there.
https://github.com/DiffSK/configobj/blob/b7707c94c0317b8f89b704a01525a68eb6c72521/src/configobj/validate.py#L164-L169
So submitting in this PR the latest package for configobj (https://pypi.org/project/configobj/5.0.9/, nvm typo in branch name)) without any Python 2 symbols involved.
configobjrestructured code a little bit, so in the future the won't globalvalidatemodule available so some files were moved around / renamed.I've made two changes that deviate from the actual published package:
I've dropped the whitespaces that were cleaned up on this repo in ecaa91c just to keep diff minimal and more readable. This whitespace undo in a separate commit 1f8820d. Maybe makes sense to undo this commit to keep diff with upstream absolutely minimal, but upstream is not very active, so it's up to you - what do you prefer?
I've replaced
from configobj.validate import VdtMissingValuewith relative pathsfrom ..validate import VdtMissingValue, similar patch already exists on this repo (e5ce1e3) and without itfrom astropy.extern.configobj import configobj, validatewas failing withModuleNotFoundError: No module named 'configobj'since it was assumingconfigobjto be available as a package globally. I've addedASTROPY PATCHcomments to make to make these patches nature easily recognizable.