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

CI: Fix Windows builds #38

Merged
merged 1 commit into from Dec 6, 2022
Merged

Conversation

jktjkt
Copy link
Contributor

@jktjkt jktjkt commented Dec 3, 2022

On Windows, one cannot overwrite an executable file which is currently executing. That's, however, exactly what pip-sync might try to do at some points, and indeed the CI runs were failing due to that:

   Attempting uninstall: pip-tools
     Found existing installation: pip-tools 6.10.0
     Uninstalling pip-tools-6.10.0:
       Successfully uninstalled pip-tools-6.10.0
 ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pip-uninstall-8ii4ro6b\\pip-sync.exe'
 Consider using the `--user` option or check the permissions.

 Traceback (most recent call last):
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 194, in _run_module_as_main
     return _run_code(code, main_globals, None,
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 87, in _run_code
     exec(code, run_globals)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\Scripts\pip-sync.exe\__main__.py", line 7, in <module>
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 1130, in __call__
     return self.main(*args, **kwargs)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 1055, in main
     rv = self.invoke(ctx)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 1404, in invoke
     return ctx.invoke(self.callback, **ctx.params)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 760, in invoke
     return __callback(*args, **kwargs)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\piptools\scripts\sync.py", line 177, in cli
     to_uninstall,
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\piptools\sync.py", line 240, in sync
     req_lines.append(format_requirement(ireq, hashes=ireq_hashes))
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\subprocess.py", line 516, in run
     raise CalledProcessError(retcode, process.args,
 subprocess.CalledProcessError: Command '['C:\\hostedtoolcache\\windows\\Python\\3.8.10\\x64\\python.exe', '-m', 'pip', 'install', '-r', 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpbe8tk3qm']' returned non-zero exit status 1.

Solve this by not executing pip-sync directly, but instead going through the Python interpreter and invoking the module from there.

I think this used to work previously because there was (probably) no version change to take care of. Now there's apparently some discrepancy.

Bug: jazzband/pip-tools#478

On Windows, one cannot overwrite an executable file which is currently
executing. That's, however, exactly what `pip-sync` might try to do at
some points, and indeed the CI runs were failing due to that:

   Attempting uninstall: pip-tools
     Found existing installation: pip-tools 6.10.0
     Uninstalling pip-tools-6.10.0:
       Successfully uninstalled pip-tools-6.10.0
 ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\pip-uninstall-8ii4ro6b\\pip-sync.exe'
 Consider using the `--user` option or check the permissions.

 Traceback (most recent call last):
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 194, in _run_module_as_main
     return _run_code(code, main_globals, None,
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 87, in _run_code
     exec(code, run_globals)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\Scripts\pip-sync.exe\__main__.py", line 7, in <module>
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 1130, in __call__
     return self.main(*args, **kwargs)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 1055, in main
     rv = self.invoke(ctx)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 1404, in invoke
     return ctx.invoke(self.callback, **ctx.params)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\click\core.py", line 760, in invoke
     return __callback(*args, **kwargs)
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\piptools\scripts\sync.py", line 177, in cli
     to_uninstall,
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\piptools\sync.py", line 240, in sync
     req_lines.append(format_requirement(ireq, hashes=ireq_hashes))
   File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\subprocess.py", line 516, in run
     raise CalledProcessError(retcode, process.args,
 subprocess.CalledProcessError: Command '['C:\\hostedtoolcache\\windows\\Python\\3.8.10\\x64\\python.exe', '-m', 'pip', 'install', '-r', 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpbe8tk3qm']' returned non-zero exit status 1.

Solve this by not executing `pip-sync` directly, but instead going
through the Python interpreter and invoking the module from there.

I think this used to work previously because there was (probably) no
version change to take care of. Now there's apparently some discrepancy.

Bug: jazzband/pip-tools#478
@lordmauve lordmauve merged commit 621e14a into lordmauve:main Dec 6, 2022
@jktjkt jktjkt deleted the fix-windows-ci branch January 18, 2023 11:48
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

Successfully merging this pull request may close these issues.

None yet

2 participants