Skip to content

Fix windows bug when using pytailwindcss.run directly #15

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Zwork101
Copy link

Right now, when pytailwind is ran via pytailwind.run, the env parameter that gets provided to subprocess.run is an empty dict. For example when I modified the pytailwind.__init__ file I got the following output:

print([str(bin_path)] + tailwindcss_cli_args, kwargs)
output = subprocess.run([str(bin_path)] + tailwindcss_cli_args, **kwargs)
['D:\\Programming Projects\\brim\\.venv\\Lib\\site-packages\\pytailwindcss\\bin\\latest\\tailwindcss', '--input', 'D:\\Programming Projects\\brim\\brimstone\\static\\_src\\input.css', '--output', 'D:\\Programming Projects\\brim\\brimstone\\static\\dist\\css\\output.css', '--minify', '--optimize', '--cwd', 'D:\\Programming Projects\\brim\\brimstone\\templates'] {'cwd': 'D:\\Programming Projects\\brim\\brimstone', 'env': {}, 'capture_output': True, 'check': True}

Because env is an empty dict, it causes the following error on Windows, and maybe Linux and Mac but I did not test it:

  File "D:\Programming Projects\brim\.venv\lib\site-packages\pytailwindcss\__init__.py", line 50, in run
    output = subprocess.run([str(bin_path)] + tailwindcss_cli_args, **kwargs)
  File "AppData\Roaming\uv\python\cpython-3.9.22-windows-x86_64-none\lib\subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Zwork\AppData\Roaming\uv\python\cpython-3.9.22-windows-x86_64-none\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "AppData\Roaming\uv\python\cpython-3.9.22-windows-x86_64-none\lib\subprocess.py", line 1436, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 87] The parameter is incorrect

The solution is very simple, just leave env as None, and everything works correctly.

@Zwork101
Copy link
Author

For additional context, I'm using Python 3.9, and I'm on Windows 10.

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.

1 participant