-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Allow opencv-python as requirement if alread present #586
Conversation
…cv-python` if `opencv-python` is already installed
Codecov Report
@@ Coverage Diff @@
## master #586 +/- ##
=======================================
Coverage 96.48% 96.48%
=======================================
Files 40 40
Lines 14549 14549
=======================================
Hits 14037 14037
Misses 512 512 |
Note: I disabled C0114 for setup.py 391d71b Writing """The setup file""" would be easier, but technically, is "setup.py" a module ? I can resubmit the PR with the module docstring if preferred |
Hey, thanks for the patch. I suspect that having such a check in The patch looks good to me. It would be great if it would be extended a bit to provide a list of alternative packages, instead of only a single one. That way Oh and you can ignore |
setup.py
Outdated
@@ -1,27 +1,64 @@ | |||
# pylint: disable=C0114 |
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.
You could change this to # pylint: disable=missing-module-docstring
setup.py
Outdated
"Shapely", | ||
] | ||
|
||
ALT_INSTALL_REQUIRES = {"opencv-python-headless": "opencv-python"} |
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.
["opencv-python", "opencv-contrib-python", "opencv-contrib-python-headless"]
here instead of just "opencv-python"
.
setup.py
Outdated
try: | ||
alternative_pkg_name = re.split(r"[!<>=]", alternative_install_require)[0] | ||
get_distribution(alternative_pkg_name) | ||
except DistributionNotFound: | ||
return install_require |
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.
This should then expect alternative_install_require
to be a list and iterate over it via a for loop.
If an alternative name in a loop iteration is found, return that name. Otherwise return install_require
at the end.
setup.py
Outdated
If that is the case, replace the install require by the alternative to not install dual package""" | ||
new_install_requires = [] | ||
for main_require in main_requires: | ||
if main_require in alternative_requires.keys(): |
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.
I think the .keys()
here is not necessary
…python, opencv-python instead of opencv-python-headless)
Hello, The PR was updated to account for multiple alternatives |
This is now merged into master. |
Referencing #473
This is a proposal, heavily inspired by a similar solution in albumentations that checks if
opencv-python
is installed when listing requirements and replacesopencv-python-headless
if this is the case.This is not the most "elegant" alternative, however I don't know any solution without resorting to extra requires and mandating the installation of imgaug with
pip install imgaug[opencv-python]
orpip install imgaug[opencv-python-headless]
Maybe extra_require installation would be preferred ? If so I can submit the PR again