watchman: watchman-make not working on python3
Hello! According to your docs pywatchman now supports python3. However I’m running into a python 2/3 compat issue.
$ watchman-make -p '**/*.py' -t unittest
Traceback (most recent call last):
  File "/Users/schrockn/code/venvs/clarify/bin/watchman-make", line 168, in <module>
    args = parser.parse_args()
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1730, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1762, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1968, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1908, in consume_optional
    take_action(action, args, option_string)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1836, in take_action
    action(self, namespace, argument_values, option_string)
  File "/Users/schrockn/code/venvs/clarify/bin/watchman-make", line 103, in __call__
    if isinstance(values, basestring):
NameError: name 'basestring' is not defined
Watchman version 4.9.0
$ watchman --version
4.9.0
Python version 3.6.4
$ python3 --version
Python 3.6.4
pywatchman 1.4.1 (from pip list)
pywatchman          1.4.1
Thanks again for open sourcing this awesome project.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (4 by maintainers)
Commits related to this issue
- fixup py2 vs py3 compat issue with watchman-make Summary: Copied and pasted our logic from WatchmanTestCase.py Fixes: https://github.com/facebook/watchman/issues/631 Reviewed By: chadaustin Differ... — committed to ip4368/docker-watchman by wez 6 years ago
- fixup py2 vs py3 compat issue with watchman-make Summary: Copied and pasted our logic from WatchmanTestCase.py Fixes: https://github.com/facebook/watchman/issues/631 Reviewed By: chadaustin Differ... — committed to ip4368/docker-watchman by wez 6 years ago
if you’re being roadblocked by this, open line
103of/usr/local/Cellar/watchman/4.9.0_2/libexec/bin/watchman-makeand changefrom
if isinstance(values, basestring):to
if isinstance(values, str):hold over until patch goes through
Would like to see a release of this.
Homebrew version
4.9.0works ok, but if you have a fresh install you’ll get the latest one which is broken (4.9.0_2). And homebrew doesn’t allow installing older versions, only switching to an older already locally available version. So you are screwed if you don’t have the older4.9.0…It looks like a fix was merged into this project over a year ago, but when I run
brew install watchmantoday, it seems to still have the issue. Has this patch not shipped to Homebrew yet? Or am I doing something wrong?EDIT: for the next lost soul,
pip install pywatchmanfixed this issue for me.@wez when will this be available in a public form?
This issue is closed by accident it should be reopened. As its still present.
I had to modify
/usr/local/Cellar/watchman/4.9.0_4/libexec/bin/watchman-makefor this to work on MacOS.basestring -> str.Apparently this affects the Nixpkgs version as well which directly pulls from PyPI which still has the broken version. I could submit a patch to Nixpkgs but it would be much better to fix the root cause @wez
@wez actually I now see that
watchman-makeis installed by the PyPI package here: https://pypi.org/project/pywatchman/The PyPI record shows you as the publisher and that package does still contain the old code. Could you publish a newer version on PyPI?
watchman on Homebrew (4.9.0_3) is still unpatched. In
class DefineTargetthere is aisinstance(values, basestring)which has clearly been fixed source but perhaps whoever maintains the Homebrew package needs to create a new release.Github fails to show history or blame on https://github.com/Homebrew/homebrew-core/blob/master/Formula/watchman.rb so I’m not sure who to poke, but I’m guessing that the Homebrew maintainer is also active in this repo.
Hey Nick 😃 It’s always fun to see folks using our opensource stuff in their lives after FB 😃
Thanks for looking into this! Also, Hi Wez!
Ah, the problem there is that watchman-make isn’t py3 compatible, but the underlying library is.
This is the diff I have queued up internally: