-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Issue with 'hg was not found' #861
Comments
This seems to me like an environment issues How's does hg end up in PATH on your system I'm unfamiliar with Windows and practically haven't used it for more than a decade |
@RonnyPfannschmidt I have added C:\Program Files\TortoiseHg to both system path and the user path so it should be able to see it. I can execute "hg help" in command prompt and it can see it. |
Then python should See it as well,does the build work from the cli? What's the exact executable name |
Yeah i tried running Python, import os lib and then os.system("hg help") |
Use |
There's a key difference between running with a shell like os.system and running a command directly |
For sanity also check |
subprocess.run is actually what it uses in utils.py -> _run method I tried to set cmd=['where', 'hg'] which got a really interesting result: and in the folder there is a .hg folder |
Ok, then my impression is that for sanity a shutil.which needs to be added |
Yeah, except that this does not solve the issue. Weirdly enough it is normal to have a .hg folder and I don't think they have modified the path recently. |
@RonnyPfannschmidt So you have no idea what i could try? |
I believe the Bugfix would be to do a shutil.which for the commands I'm currently unable to do this in a timely manner |
@RonnyPfannschmidt I just don't see how it solves anything. It just shows the user what path it finds the function in |
If shutil.which find's a folder instead of a command, then something is seriously wrong and some in depth debugging is needed |
I Just tried again to validate things. I tried to print out the cwd path on my other computer that works and it is also "." So everything is the same there and my initial idea of what was wrong must be incorrect.. So it is something else causing this |
I found an old .tox that used to work. |
So My assessment is correct and shutil.which seems necessary to resolve the executable name |
@RonnyPfannschmidt Yes it does find the path to THG. but it does not solve the issue, the issue is that _run in utils.py cannot execute as it cannot find hg for some reason |
I checked The subprocess docs again, Which is needed, I'll investigate caching |
Ah yeah i get it now! It did not solve. |
What needs to happen is the first element of cmd going through shuttle.which,cwd is unrelated |
I think that would yield the same result. Modifying the cwd: I think it is more correct to change the path to the correct folder rather than saying cwd = "." and then the cmd = ["C:\Program Files\TortoiseHg\hg.EXE", "help] I don't think this issue is related to this since it works just fine for many other people and since shuttle.which does find hg in the path it should be available. But i am surely out of ideas. |
Yeah as expected:
It is really weird. I have a feeling that it might not be caused by setuptools-scm but more like something tox wraps around the execution. |
What's the tox and python version |
Tried a few versions |
Also try tox 3.x if feasible |
I initially tried 3.x but i thought i made a mistake since it worked but after playing around more i managed to get it working with last release of tox3 (3.28.0), then if i upgrade to 4.0.0 it fails A thing that i can also try on my side is to try and convert our old setup.py to a pyproject.toml instead. I don't think it is the problem since i can execute the tox on other computers but as the package specifies setup.py is deprecated EDIT: It didn't solve anything running a pyproject.toml project, remembered the template i got uses that instead of setup.py... |
I'm making a stab here, except my project has nothing to with HG whatsoever (other than the error message at the end of the traceback). I'm assuming the
The above error is sporadic and only happens on Windows in Github CI. If I go re-run the failed job in the Github GUI it will almost certainly succeed. The above failed job is here: https://github.com/sarnold/procman/actions/runs/6293550384/job/17084214891?pr=3 I don't have an answer but hopefully this adds another piece to the picture. |
Still able to reproduce this. printed the res returned from the res = subprocess.run() method Still looking into what and why. I have hacked a few things so therefore the args look different than expected! |
I did a hack that made a difference! So now it is just about figuring out why tf it does this and where it depend on the AppData folder. If i try this inside the _run_cmd.run method:
Both methods return False but if i do it in cmd it returns True! |
I can finally conclude something! This issue IS related to tox! I will move the issue to github tox soon and link the issue! |
Yikes most likely a oversight in the passed default |
Exactly. |
New release of Tox==4.11.4 now includes my fixes for Tox. Issue is now resolved! |
Hello, I'm getting this error:
docs: packaging backend failed (code=1), with OSError: 'hg' was not found Traceback (most recent call last): File "C:\Users\yyyyyy\AppData\Roaming\Python\Python310\site-packages\pyproject_api\_backend.py", line 90, in run outcome = backend_proxy(parsed_message["cmd"], **parsed_message["kwargs"]) File "C:\Users\yyyyyy\AppData\Roaming\Python\Python310\site-packages\pyproject_api\_backend.py", line 32, in __call__ return getattr(on_object, name)(*args, **kwargs) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\build_meta.py", line 380, in prepare_metadata_for_build_wheel self.run_setup() File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\build_meta.py", line 487, in run_setup super(_BuildMetaLegacyBackend, File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\build_meta.py", line 338, in run_setup exec(code, locals()) File "<string>", line 18, in <module> File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\__init__.py", line 107, in setup return distutils.core.setup(**attrs) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\_distutils\core.py", line 147, in setup _setup_distribution = dist = klass(attrs) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\dist.py", line 496, in __init__ _Distribution.__init__( File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\_distutils\dist.py", line 283, in __init__ self.finalize_options() File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\dist.py", line 935, in finalize_options ep(self) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools\dist.py", line 955, in _finalize_setup_keywords ep.load()(self, ep.name, value) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\integration.py", line 91, in version_keyword _assign_version(dist, config) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\integration.py", line 60, in _assign_version maybe_version = _get_version(config) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\__init__.py", line 153, in _get_version parsed_version = _do_parse(config) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\__init__.py", line 100, in _do_parse version = _version_from_entrypoints(config) or _version_from_entrypoints( File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\_entrypoints.py", line 66, in _version_from_entrypoints version: ScmVersion | None = _call_entrypoint_fn(root, config, ep.load()) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\_entrypoints.py", line 40, in _call_entrypoint_fn return fn(root, config=config) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\hg.py", line 164, in parse wd = HgWorkdir.from_potential_worktree(config.absolute_root) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\hg.py", line 29, in from_potential_worktree require_command(cls.COMMAND) File "D:\Test\tester\xxxxxxxxxxx\.tox\.pkg\lib\site-packages\setuptools_scm\utils.py", line 171, in require_command raise OSError("%r was not found" % name) OSError: 'hg' was not found Backend: run command prepare_metadata_for_build_wheel with args {'metadata_directory': 'D:\\Test\\tester\\xxxxxxxxxxx\\.tox\\.pkg\\.meta', 'config_settings': {'--build-option': []}} Backend: Wrote response {'code': 1, 'exc_type': 'OSError', 'exc_msg': "'hg' was not found"} to C:\Users\yyyyyy\AppData\Local\Temp\pep517_prepare_metadata_for_build_wheel-on2nznbh.json
Notes:
Python 3.10.6
hg is installed at C:\Program Files\TortoiseHg
Tried cloning project again
Reinstalling python
Reinstalling all dependencies to tox
Removed .tox folder in users folder
Tried reinstalling THG
If i separate the require_comman from the package and run it in pycharm scratch file it finds hg without a problem.
Anyone have any idea what could be wrong? I've seen the same issue in other packages so it is not related to the package. Even got collogues with the same issue. I sadly cannot remember what i did to cause the issue.
The text was updated successfully, but these errors were encountered: