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
Internalize jaraco.classes code to replace dependency #1671
Internalize jaraco.classes code to replace dependency #1671
Conversation
68cb569
to
eb59db7
Compare
Codecov Report
@@ Coverage Diff @@
## master #1671 +/- ##
==========================================
- Coverage 78.1% 78.09% -0.01%
==========================================
Files 106 106
Lines 13790 13802 +12
==========================================
+ Hits 10771 10779 +8
- Misses 3019 3023 +4 |
eb59db7
to
1ab2155
Compare
…es when environment doesnt support namespaced packages - see jaraco/jaraco.classes#2
1ab2155
to
7920822
Compare
In order to retain coverage, I decided only to copy over the essential bits. The There was a fair bit of linting to adhere to :) So I also had added in some docstrings that weren't in the original code. |
Hoping this can be merged, because we had to revert to CherryPy 11. We can patch up code by doing something that amounts to this:
I think since there's errors coming in from py2exe and Celery, you should really consider this carefully as it can take many hours of debugging for this error to be understood. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the parent ticket, I don't want to accept this copy/paste until there is a ticket (or tickets) upstream (pex, celery, py2exe, pip) capturing the inability to support this use-case. This change also implies that CherryPy cannot depend on any package that contains namespace packages, so the comment linking to the offending ticket(s) should probably also be referenced in the setup.py to prevent other developers from adding dependencies on other namespace packages.
Please please please @jaraco skip to standard reviewing practice and take the fight for namespaced packages somewhere else. I haven't said anything bad about namespaced packages as a concept, and this dependency could be removed even if it didn't have the namespacing issues attached to it. You already have 3 people who searched out a repo with 0 stars complaining about it in 3 days, do you need more evidence? Also, this is a security issue. You could inject any sort of malicious code into this dependency and release it to PyPi without anyone noticing. Not that you're a bad guy, but do you see the problem in this practice? |
Just to be clear here: This was mentioned after the PR was opened, and this PR didn't happen in spite of something mentioned. |
If we accept this change as-is, it could be readily optimized away, replaced by another developer (or my future self) with the implementation from jaraco.classes again. And there's nothing preventing CherryPy from accepting dependencies in other namespaced packages. What happens when the bit of functionality needed is supplied in another namespace package? Then CherryPy breaks again for an entirely different reason. It's possible, though I haven't looked, that there are already pending changes with additional namespace package dependencies. But what this PR does is ask to make what seems like a minor change while implying a much bigger design decision - that CherryPy should not accept dependencies on namespace packages unless they provide a sufficiently high value (and where that threshold is subjective). I'm willing to accept the PR as long as the tradeoffs are acknowledged, the risks mitigated, and the underlying cause captured so the restriction can be lifted when appropriate. If we only treat the symptom, then the underlying cause will continue to affect CherryPy and likely other projects. If on the other hand we capture the upstream failure and link that in comments proximate to the dependencies and to this inlined code, that protects against other packages bringing this same condition, documents the technical debt, presents a pattern for similar situations, and provides a mechanism to remove the duplication after a fix becomes available. |
In 52682a7 and 8b0e8a0, I illustrate two changes that I might consider to re-use constructs from packages in the Another library that I commonly use is backports.functools_lru_cache, which provides a backport of a popular standard library function lru_cache. Should CherryPy find that function helpful, it also would conflict (implicitly) with this proposed change. Or looking at cherrypy.lib.lockfile, it appears to be copied from zc.lockfile, so it may make sense now that CherryPy allows for dependencies to depend on zc.lockfile rather than maintaining its own implementation. |
I just noticed #1654 also conflicts with this change. My plan before I noticed that ticket was to go ahead and accept this PR, restoring support for environments that reject or fail on namespace packages, but to set a window (probably 6 months) for when CherryPy would once again allow dependencies on namespace packages. And now I'm conflicted. Still, I think it's best to acknowledge the regression and address it... and we can debate over what is the appropriate window for adding this constraint. |
|
||
|
||
#### | ||
# Inlined from jaraco.classes 1.4.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaraco I think, better place for such code vendoring would be some lib/vendor
folder, which is a git submodule (or a subtree, but I don't have real experience with latter), which is easier to keep in sync. Also it would be easy to embed them into distribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I don't want to vendor the whole package. I also see this as a very temporary pattern until #1673 lands, so probably not worth too much extra effort. But if you'd like to take a stab at it, you're welcome to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not that hard to implement, I'll probably find time for this
This is released as v13.0.1. (well, releasing...) |
Oh wow that's fantastic, and thanks so much for a fruitful discussions, too! I will make sure we upgrade back to CherryPy 13.0.1 ASAP and report back here. |
Resolves a bug when environment doesn't support namespaced packages
#
)jaraco/jaraco.classes#2
jaraco/jaraco.classes#3
Will happen in an environment that doesn't understand namespaced packages. For instance just do:
The above will not happen. CherryPy will be more portable.
AFAIK this is a problem with Pex and Celery.