Skip to content
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

Closed
Stefanhg opened this issue Jun 8, 2023 · 34 comments
Closed

Issue with 'hg was not found' #861

Stefanhg opened this issue Jun 8, 2023 · 34 comments

Comments

@Stefanhg
Copy link

Stefanhg commented Jun 8, 2023

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.

@RonnyPfannschmidt
Copy link
Contributor

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

@Stefanhg
Copy link
Author

Stefanhg commented Jun 8, 2023

@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.

@RonnyPfannschmidt
Copy link
Contributor

Then python should See it as well,does the build work from the cli?

What's the exact executable name

@Stefanhg
Copy link
Author

Stefanhg commented Jun 8, 2023

Yeah i tried running Python, import os lib and then os.system("hg help")
the name of the file is hg.exe
The hg help is what the require_commands function executes when it reaches last function in utils.py called _run

@RonnyPfannschmidt
Copy link
Contributor

Use subprocess.run("hg help“.split())

@RonnyPfannschmidt
Copy link
Contributor

There's a key difference between running with a shell like os.system and running a command directly

@RonnyPfannschmidt
Copy link
Contributor

For sanity also check shutil.which("hg")

@Stefanhg
Copy link
Author

Stefanhg commented Jun 8, 2023

subprocess.run is actually what it uses in utils.py -> _run method
cwd = "."
cmd = ["hg", "help"]
return subprocess.run( cmd, capture_output=True, cwd=str(cwd), env=dict( avoid_pip_isolation(no_git_env(os.environ)), # os.environ, # try to disable i18n LC_ALL="C", LANGUAGE="", HGPLAIN="1", ), text=True,
shutil.which("hg") does indeed return the correct path.

I tried to set cmd=['where', 'hg'] which got a really interesting result:
D:\Test\tester\xxxxxxxxxxx

and in the folder there is a .hg folder
And as mentioned above cwd = "."
So it actually found the ".hg" folder....
If i modify the cwd to "./" it does reach a new state in the function, but it is not happy that the cwd is "."

@RonnyPfannschmidt
Copy link
Contributor

Ok, then my impression is that for sanity a shutil.which needs to be added

@Stefanhg
Copy link
Author

Stefanhg commented Jun 8, 2023

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.

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

@RonnyPfannschmidt So you have no idea what i could try?
I have tried so many things and nothing solved it. I can't figure out where the paths that configuration.py is coming from. It just get them from somewhere else other than the config file

@RonnyPfannschmidt
Copy link
Contributor

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

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

@RonnyPfannschmidt I just don't see how it solves anything. It just shows the user what path it finds the function in
And in my case it finds the ".hg" folder and not where thg is actually placed on the computer.

@RonnyPfannschmidt
Copy link
Contributor

If shutil.which find's a folder instead of a command, then something is seriously wrong and some in depth debugging is needed

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

I Just tried again to validate things.
If i do shutil.which("hg") it does find C:\Program Files\TortoiseHg\hg.EXE

I tried to print out the cwd path on my other computer that works and it is also "."
Ad the shutil.which says: C:\Program Files\TortoiseHg\hg.EXE

So everything is the same there and my initial idea of what was wrong must be incorrect.. So it is something else causing this

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

I found an old .tox that used to work.
It was using an older version of virtualenv, i tried downgrading to tox==4.0.0 and virtualenv==20.17.1 but that was no success either.

@RonnyPfannschmidt
Copy link
Contributor

So My assessment is correct and shutil.which seems necessary to resolve the executable name

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

@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

@RonnyPfannschmidt
Copy link
Contributor

I checked The subprocess docs again,

Which is needed, I'll investigate caching

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

Ah yeah i get it now!
I tried modifying the path:
p = _run(cmd, os.path.dirname(shutil.which("hg")))

It did not solve.
I wonder if it actually is an issue with subprocess.run..

@RonnyPfannschmidt
Copy link
Contributor

What needs to happen is the first element of cmd going through shuttle.which,cwd is unrelated

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

I think that would yield the same result.
When subprocess.run executes i think the 2 commands would look something like this:

Modifying the cwd:
cd C:\Program Files\TortoiseHg
hg.EXE help
Modifying the cmd:
cd .
C:\Program Files\TortoiseHg\hg.EXE help

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.
Maybe the next i should do is try to fake that it executes the command properly and see if the test will run, i don't expect it to work tho as hg must have been used in other places too.

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

Yeah as expected:


cmd = C:\Program Files\TortoiseHg\hg.EXE, cwd = .
Backend: Wrote response {'code': 1, 'exc_type': 'OSError', 'exc_msg': "'hg' was not found"} to C:\Users\shg\AppData\Local\Temp\pep517_prepare_metadata_for_build_wheel-eiwtmbwb.json

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.
But still.. It points straight at the executable so it should be able to execute it

@RonnyPfannschmidt
Copy link
Contributor

What's the tox and python version

@Stefanhg
Copy link
Author

Stefanhg commented Jun 9, 2023

Tried a few versions
Mainly running 3.10.6 but also tested 3.10.10
Running newest version of tox, tried version 4.0.8 and a few others

@RonnyPfannschmidt
Copy link
Contributor

Also try tox 3.x if feasible

@Stefanhg
Copy link
Author

Stefanhg commented Jun 10, 2023

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
So now I am able to run with tox==4.0.0
And just to validate i tried to remove the use_scm_version from my setup file and then i can run my test.

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...

@sarnold
Copy link

sarnold commented Sep 25, 2023

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 hg bit somehow gets invoked because the error starts with the "pretending there aren't any (git files)" as shown here:

2023-09-25T01:02:02.5484407Z * Building wheel...
2023-09-25T01:02:03.6570094Z running bdist_wheel
2023-09-25T01:02:03.6576383Z running build
2023-09-25T01:02:03.6577376Z running build_py
2023-09-25T01:02:03.6577911Z creating build
2023-09-25T01:02:03.6579439Z creating build\lib
2023-09-25T01:02:03.6579835Z creating build\lib\procman
2023-09-25T01:02:03.6580611Z copying procman\procman.py -> build\lib\procman
2023-09-25T01:02:03.6581155Z copying procman\utils.py -> build\lib\procman
2023-09-25T01:02:03.6581677Z copying procman\__init__.py -> build\lib\procman
2023-09-25T01:02:03.6582670Z creating build\lib\procman\examples
2023-09-25T01:02:03.6583238Z copying procman\examples\app.py -> build\lib\procman\examples
2023-09-25T01:02:03.6583951Z copying procman\examples\run_redis.sh -> build\lib\procman\examples
2023-09-25T01:02:03.6584548Z installing to build\bdist.win-amd64\wheel
2023-09-25T01:02:03.6584956Z running install
2023-09-25T01:02:03.6585322Z running install_lib
2023-09-25T01:02:03.6585771Z creating build\bdist.win-amd64
2023-09-25T01:02:03.6586240Z creating build\bdist.win-amd64\wheel
2023-09-25T01:02:03.6586751Z creating build\bdist.win-amd64\wheel\procman
2023-09-25T01:02:03.6587289Z creating build\bdist.win-amd64\wheel\procman\examples
2023-09-25T01:02:03.6587931Z copying build\lib\procman\examples\app.py -> build\bdist.win-amd64\wheel\.\procman\examples
2023-09-25T01:02:03.6590479Z copying build\lib\procman\examples\run_redis.sh -> build\bdist.win-amd64\wheel\.\procman\examples
2023-09-25T01:02:03.6591686Z copying build\lib\procman\procman.py -> build\bdist.win-amd64\wheel\.\procman
2023-09-25T01:02:03.6592538Z copying build\lib\procman\utils.py -> build\bdist.win-amd64\wheel\.\procman
2023-09-25T01:02:03.6598494Z copying build\lib\procman\__init__.py -> build\bdist.win-amd64\wheel\.\procman
2023-09-25T01:02:03.6599333Z running install_egg_info
2023-09-25T01:02:03.6599860Z running egg_info
2023-09-25T01:02:03.6601340Z writing procman.egg-info\PKG-INFO
2023-09-25T01:02:03.6602090Z writing dependency_links to procman.egg-info\dependency_links.txt
2023-09-25T01:02:03.6602712Z writing entry points to procman.egg-info\entry_points.txt
2023-09-25T01:02:03.6603129Z writing requirements to procman.egg-info\requires.txt
2023-09-25T01:02:03.6603761Z writing top-level names to procman.egg-info\top_level.txt
2023-09-25T01:02:03.6730155Z ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any
2023-09-25T01:02:23.7857218Z Traceback (most recent call last):
2023-09-25T01:02:23.7868031Z   File "D:\a\procman\procman\.tox\build\Lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
2023-09-25T01:02:24.1541608Z     main()
2023-09-25T01:02:24.1547626Z   File "D:\a\procman\procman\.tox\build\Lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 335, in main
2023-09-25T01:02:24.1548414Z     json_out['return_val'] = hook(**hook_input['kwargs'])
2023-09-25T01:02:24.1548728Z                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1549384Z   File "D:\a\procman\procman\.tox\build\Lib\site-packages\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
2023-09-25T01:02:24.1549844Z     return _build_backend().build_wheel(wheel_directory, config_settings,
2023-09-25T01:02:24.1550159Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1550762Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\build_meta.py", line 434, in build_wheel
2023-09-25T01:02:24.1551209Z     return self._build_with_temp_dir(
2023-09-25T01:02:24.1551426Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1552013Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\build_meta.py", line 419, in _build_with_temp_dir
2023-09-25T01:02:24.1552427Z     self.run_setup()
2023-09-25T01:02:24.1553052Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
2023-09-25T01:02:24.1553436Z     exec(code, locals())
2023-09-25T01:02:24.1553741Z   File "<string>", line 3, in <module>
2023-09-25T01:02:24.1554315Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\__init__.py", line 103, in setup
2023-09-25T01:02:24.1554737Z     return distutils.core.setup(**attrs)
2023-09-25T01:02:24.1554970Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1555527Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
2023-09-25T01:02:24.1556103Z     return run_commands(dist)
2023-09-25T01:02:24.1556327Z            ^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1556864Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
2023-09-25T01:02:24.1557266Z     dist.run_commands()
2023-09-25T01:02:24.1557841Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
2023-09-25T01:02:24.1558265Z     self.run_command(cmd)
2023-09-25T01:02:24.1558804Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\dist.py", line 989, in run_command
2023-09-25T01:02:24.1559182Z     super().run_command(command)
2023-09-25T01:02:24.1559741Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
2023-09-25T01:02:24.1560127Z     cmd_obj.run()
2023-09-25T01:02:24.1560626Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\wheel\bdist_wheel.py", line 399, in run
2023-09-25T01:02:24.1560995Z     self.run_command("install")
2023-09-25T01:02:24.1561567Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
2023-09-25T01:02:24.1562013Z     self.distribution.run_command(command)
2023-09-25T01:02:24.1562585Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\dist.py", line 989, in run_command
2023-09-25T01:02:24.1562974Z     super().run_command(command)
2023-09-25T01:02:24.1563514Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
2023-09-25T01:02:24.1563895Z     cmd_obj.run()
2023-09-25T01:02:24.1564418Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\install.py", line 78, in run
2023-09-25T01:02:24.1564829Z     return orig.install.run(self)
2023-09-25T01:02:24.1565169Z            ^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1565721Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\command\install.py", line 708, in run
2023-09-25T01:02:24.1566133Z     self.run_command(cmd_name)
2023-09-25T01:02:24.1566682Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
2023-09-25T01:02:24.1567089Z     self.distribution.run_command(command)
2023-09-25T01:02:24.1567655Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\dist.py", line 989, in run_command
2023-09-25T01:02:24.1568047Z     super().run_command(command)
2023-09-25T01:02:24.1568614Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
2023-09-25T01:02:24.1568995Z     cmd_obj.run()
2023-09-25T01:02:24.1569516Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\install_egg_info.py", line 31, in run
2023-09-25T01:02:24.1569967Z     self.run_command('egg_info')
2023-09-25T01:02:24.1570518Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
2023-09-25T01:02:24.1570931Z     self.distribution.run_command(command)
2023-09-25T01:02:24.1571476Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\dist.py", line 989, in run_command
2023-09-25T01:02:24.1571839Z     super().run_command(command)
2023-09-25T01:02:24.1572384Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
2023-09-25T01:02:24.1572895Z     cmd_obj.run()
2023-09-25T01:02:24.1573417Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\egg_info.py", line 318, in run
2023-09-25T01:02:24.1573777Z     self.find_sources()
2023-09-25T01:02:24.1574330Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\egg_info.py", line 326, in find_sources
2023-09-25T01:02:24.1574711Z     mm.run()
2023-09-25T01:02:24.1575236Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\egg_info.py", line 548, in run
2023-09-25T01:02:24.1575606Z     self.add_defaults()
2023-09-25T01:02:24.1576163Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\egg_info.py", line 589, in add_defaults
2023-09-25T01:02:24.1576580Z     rcfiles = list(walk_revctrl())
2023-09-25T01:02:24.1576816Z               ^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1577428Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools\command\sdist.py", line 18, in walk_revctrl
2023-09-25T01:02:24.1577824Z     for item in ep.load()(dirname):
2023-09-25T01:02:24.1578064Z                 ^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1578633Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools_scm\_file_finders\__init__.py", line 103, in find_files
2023-09-25T01:02:24.1579514Z     res: list[str] = command(path)
2023-09-25T01:02:24.1579721Z                      ^^^^^^^^^^^^^
2023-09-25T01:02:24.1580282Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools_scm\_file_finders\hg.py", line 50, in hg_find_files
2023-09-25T01:02:24.1580708Z     toplevel = _hg_toplevel(path)
2023-09-25T01:02:24.1580937Z                ^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1581478Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools_scm\_file_finders\hg.py", line 18, in _hg_toplevel
2023-09-25T01:02:24.1581877Z     res = _run(
2023-09-25T01:02:24.1582067Z           ^^^^^
2023-09-25T01:02:24.1583823Z   File "C:\Users\runneradmin\AppData\Local\Temp\build-env-zwhhk0h8\Lib\site-packages\setuptools_scm\_run_cmd.py", line 138, in run
2023-09-25T01:02:24.1584229Z     res = subprocess.run(
2023-09-25T01:02:24.1584450Z           ^^^^^^^^^^^^^^^
2023-09-25T01:02:24.1584810Z   File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\subprocess.py", line 550, in run
2023-09-25T01:02:24.3704850Z     stdout, stderr = process.communicate(input, timeout=timeout)
2023-09-25T01:02:24.3708139Z                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.3709490Z   File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\subprocess.py", line 1209, in communicate
2023-09-25T01:02:24.7013136Z     stdout, stderr = self._communicate(input, endtime, timeout)
2023-09-25T01:02:24.7017840Z                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-09-25T01:02:24.7018809Z   File "C:\hostedtoolcache\windows\Python\3.11.5\x64\Lib\subprocess.py", line 1628, in _communicate
2023-09-25T01:02:24.7019565Z     raise TimeoutExpired(self.args, orig_timeout)
2023-09-25T01:02:24.7021415Z subprocess.TimeoutExpired: Command '['hg', 'root']' timed out after 20 seconds
2023-09-25T01:02:25.0871519Z 
2023-09-25T01:02:25.0876037Z ERROR Backend subprocess exited when trying to invoke build_wheel
2023-09-25T01:02:25.1138859Z build: exit 1 (125.58 seconds) D:\a\procman\procman> python -m build . pid=2308
2023-09-25T01:02:25.4099065Z ##[endgroup]
2023-09-25T01:02:25.4180425Z build: FAIL ✖ in 2 minutes 19.61 seconds

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.

@Stefanhg
Copy link
Author

Stefanhg commented Nov 8, 2023

Still able to reproduce this.
I have been debugging it again and FINALLY gotten somewhere.
The CompletedProcess method seems to have some issues:

printed the res returned from the res = subprocess.run() method
CompletedProcess(args=['C:\\Program Files\\TortoiseHg\\hg.exe'], returncode=255, stdout='', stderr='Traceback (most recent call last):\n File "hg", line 27, in <module>\n File "os.pyc", line 679, in __getitem__\nKeyError: \'APPDATA\'\n')

Still looking into what and why. I have hacked a few things so therefore the args look different than expected!

@Stefanhg
Copy link
Author

Stefanhg commented Nov 8, 2023

I did a hack that made a difference!
If i add os.environ["APPDATA"] = r"C:\Users\xxxxxxx\AppData\Roaming" inside of _run_cmd.run before it executes subprocess.run then it works!

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:

print("APPDATA" in avoid_pip_isolation(no_git_env(os.environ)))
print("APPDATA" in os.environ)

Both methods return False

but if i do it in cmd it returns True!

@Stefanhg
Copy link
Author

Stefanhg commented Nov 8, 2023

I can finally conclude something!

This issue IS related to tox!
For some reason tox removed APPDATA from os.environ.
If i make a completely separate tox project with bare-minimum items it fails with assert "APPDATA" in os.environ but if i run the pytest it passes!

I will move the issue to github tox soon and link the issue!

@RonnyPfannschmidt
Copy link
Contributor

Yikes most likely a oversight in the passed default

@Stefanhg
Copy link
Author

Exactly.
They have marked it as closed and told me to just ensure I pass required environment variables in pass_env correctly but i find it unacceptable as even PIP relies on AppData path.
I provided a few potential solutions where one of them may require a new commit here, but If a change is chosen I think solution two I provided may be chosen.
;TLDR solution two is environment variables are only cleared in the tox.ini->commands step and installing packages has all variables available

@Stefanhg
Copy link
Author

New release of Tox==4.11.4 now includes my fixes for Tox. Issue is now resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants