SystemRDL / PeakRDL-ipxact

Import and export IP-XACT XML register models
http://peakrdl-ipxact.readthedocs.io
GNU General Public License v3.0
32 stars 11 forks source link

Use optional dependencies to avoid breaking older versions of peakrdl #16

Closed mpriestleyidex closed 1 year ago

mpriestleyidex commented 1 year ago

I've had a bit of a dependency nightmare this morning. In our project we've got peakrdl == 0.4.0 pinned in a pip requirements.txt. But we've not (until now) pinned the version of peakrdl-ipxact as we don't use it. This morning, a fresh install pulled in peakrdl-ipxact 3.4.0. But this breaks with peakrdl 0.4.0. Now, I see why peakrdl isn't in the list of install_requires, as you don't actually require it in all cases. And peakrdl doesn't set a max version of peakrdl-ipxact as it can't tell the future.

This appears to be what "optional dependencies" (or extra_requires) is for: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies

So plugins' setup.pys would say e.g.

extra_requires = {
  "PeakRDL" : ["peakrdl >= 0.7.0"],
}

and in PeakRDL's setup.py:

install_requires = [
  "peakrdl-ipxact[PeakRDL] >= 3.4.0",
  ...
]

giving you the two-way dependency checking that's currently missing.

amykyta3 commented 1 year ago

Thanks. I wasn't aware of the optional dependencies mechanism - seems interesting.

In your situation, I don't think it would have changed the outcome since you'd still be pinning peakrdl == 0.4.0. At best, perhaps pip would show a warning about the PeakRDL-ipxact --> PeakRDL reverse dependency being violated, but I don't think it would have prevented the upgrade of PeakRDL-ipxact. I'll do some experiments.

Regarding the compatibility change, my apologies. Since the PeakRDL command-line tool is still in pre-production beta, I am still working out the finer details in how it is structured. Parts of the plugin API needed some improvements to help this scale better and be more flexible.

mpriestleyidex commented 1 year ago

I don't see why pip wouldn't solve the dependency constraints. But either way, an error/warning from pip is better than peakrdl falling over.

BTW, this will apply to all the "built in" plugins (html, regblock, uvm etc) - ipxact was just the one that happened to generate the error message.

I appreciate these tools are still in development (especially those that haven't reached a 1.x.x version), and that breaking changes will happen. We're very grateful that you develop them!