On a Mac, check if xcode installed before requiring watchdog#91
On a Mac, check if xcode installed before requiring watchdog#91jrhone merged 6 commits intostreamlit:developfrom
Conversation
lib/streamlit/config.py
Outdated
| 'global.disableWatchdogWarning', | ||
| description=''' | ||
| If False, will show a warning if the watchdog module is not available | ||
| on the user's system and we fall back to the polling file watcher. |
There was a problem hiding this comment.
To avoid double negatives, change to:
By default, Streamlit checks if the Python watchdog module is available and, if not, prints a warning asking for you to install it. The watchdog module is not required, but highly recommended. It improves Streamlit's ability to detect changes to files in your filesystem.
If you'd like to turn off this warning, set this to
True.
lib/tests/streamlit/config_test.py
Outdated
| u'client.caching', | ||
| u'client.displayEnabled', | ||
| u'global.developmentMode', | ||
| u'global.disableWatchdogWarning', |
There was a problem hiding this comment.
I guess this is not easy to test, huh? Any ideas what we could do here?
There was a problem hiding this comment.
Hmm maybe import LocalSourcesWatcher and see if the output is captured by capsys?
There was a problem hiding this comment.
That would work, but you'd have to also:
- Remove
LocalSourcesWatcherfromsys.modulesbefore running the test, so the module gets imported at test time (in case it had previously been imported by another test) - Mock a bunch of things, like the function that tells you whether you're on a Mac
lib/setup.py
Outdated
| # Check whether xcode tools are available before making watchdog a | ||
| # dependency (only if the current system is a Mac). | ||
| if (platform.system() == 'Darwin' and | ||
| subprocess.call('xcode-select --version', shell=True) != 0): |
There was a problem hiding this comment.
can we use shell=False
https://stackoverflow.com/questions/3172470/actual-meaning-of-shell-true-in-subprocess
shell=True is usually deemed unsecure.
There was a problem hiding this comment.
shell=True is insecure if you're executing user generated input, as far as I understand. It also wasn't working without it, unless I was doing something incorrectly.
Warning Executing shell commands that incorporate unsanitized input from an untrusted source makes a program vulnerable to shell injection, a serious security flaw which can result in arbitrary command execution. For this reason, the use of shell=True is strongly discouraged in cases where the command string is constructed from external input:
There was a problem hiding this comment.
I think you can use shell=False by changing the first argument to ('xcode-select', '--version')
lib/streamlit/config.py
Outdated
| 'global.disableWatchdogWarning', | ||
| description=''' | ||
| If False, will show a warning if the watchdog module is not available | ||
| on the user's system and we fall back to the polling file watcher. |
There was a problem hiding this comment.
Does this option causes to fall back on the 'polling'? I think it does not, maybe we could reword this?
There was a problem hiding this comment.
reworded with Thiago's suggestion
|
|
||
| from streamlit.logger import get_logger | ||
| LOGGER = get_logger(__name__) | ||
| $ xcode-select --install |
There was a problem hiding this comment.
Will this be shown on Linux as well if the option is true and the watchdog is not installed? Is the watchdog always installed on Linux?
There was a problem hiding this comment.
Watchdog is in the requirements and will be installed when the user installs Streamlit. I suppose they could uninstall watchdog afterwards and this message would be displayed.
lib/setup.py
Outdated
| # Check whether xcode tools are available before making watchdog a | ||
| # dependency (only if the current system is a Mac). | ||
| if (platform.system() == 'Darwin' and | ||
| subprocess.call('xcode-select --version', shell=True) != 0): |
There was a problem hiding this comment.
I think you can use shell=False by changing the first argument to ('xcode-select', '--version')
lib/tests/streamlit/config_test.py
Outdated
| u'client.caching', | ||
| u'client.displayEnabled', | ||
| u'global.developmentMode', | ||
| u'global.disableWatchdogWarning', |
There was a problem hiding this comment.
That would work, but you'd have to also:
- Remove
LocalSourcesWatcherfromsys.modulesbefore running the test, so the module gets imported at test time (in case it had previously been imported by another test) - Mock a bunch of things, like the function that tells you whether you're on a Mac
|
|
||
| # Check whether xcode tools are available before making watchdog a | ||
| # dependency (only if the current system is a Mac). | ||
| if (platform.system() == 'Darwin' and |
There was a problem hiding this comment.
Maybe we should pull this into util.py, since it seems we'll need to do this check in a few different places.
* develop: (54 commits) Removing uber demo from streamlit repo (streamlit#159) Release 0.46.0 (streamlit#170) Magic fixes (streamlit#138) [docs] Add analytics; redirect /secret/docs; fix compilation problem (streamlit#149) Fix bug for startup under windows (streamlit#144) Responsive layout (streamlit#104) Add basic PR template Better method signatures (streamlit#88) Publish docs to both /docs and /secret/docs, until we deprecate /secret/docs in January. (streamlit#141) Rename/report2app (streamlit#126) Test running streamlit commands "bare" (streamlit#133) Updates to LP and sidebar. (streamlit#134) tests for z-index of date input popover in sidebar (streamlit#131) cypress test for escaping html in markdown (streamlit#125) On a Mac, check if xcode installed before requiring watchdog (streamlit#91) [Docs] Fix st.slider API in tutorial (streamlit#98) Sidebar exceptions (streamlit#107) Fixing unbound local variable (streamlit#110) Support hashing dataframes with unhashable objects. Gracefully f… (streamlit#118) Fix hashing if the object has a name but the name is not a string. (streamlit#117) ...
Issue #66