LordGolias/sqf

pip install seems to be broken

Closed this issue · 7 comments

It seems like something funky is going on when installing sqflint via:
pip install sqflint
If you then try to run sqflint (the exe or the .py file) you get a bunch of errors about the module not existing and import commands failing.

I'm running windows 10 and only have python 3.6 installed. I managed to fix the issue by installing the git version:
pip install git+https://github.com/LordGolias/sqf.git

Interesting. Yesterday I installed the pip version and it was working. could you post here the traceback (the errors)

Here's an example with a fresh install

PS C:\Windows\system32> pip install sqflint --no-cache-dir
Collecting sqflint
  Downloading sqflint-0.3.0-py3-none-any.whl (52kB)
    100% |████████████████████████████████| 61kB 983kB/s
Installing collected packages: sqflint
Successfully installed sqflint-0.3.0
PS C:\Windows\system32> sqflint "G:\Code\Arma Projects\ACE3\addons\spectator\functions\fnc_cam.sqf"
Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\sqflint.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'sqflint'

you are right, I confirm I can reproduce it in my computer. Thanks a lot!

I found a potential solution:

  1. on the search bar from windows, search "edit environment variables", and select edit environment variables for your account.
  2. Add a new variable PYTHONPATH with value C:\Program Files (x86)\Python36-32\Scripts
  3. restart Atom or console.

The root cause is that pip installs scripts on the directory Scripts, but Python installation does not add that dir to its env variables (test using python -c "import sys; print(sys.path))". As a consequence, sqflint.exe does not find the appropriate sqflint.py script. The steps above fix this by adding the variable accordingly.

I do not know what caused the pip install sqflint to change this behavior from 0.2 to 0.3.

@SilentSpike could you reproduce the steps above and check that it solves the problem in your computer?

My python install does look to have added the scripts folder to my system Path, sadly looks like adding an additional PYTHONPATH pointed to the same directory does not fix the issue for me

@LordGolias your fix worked for me, thanks!

This is still an issue, and I also can not seem to fix it with the given way.

It works when installing with pip install git+https://github.com/LordGolias/sqf.git as in the OP. I checked what the difference is:
pip install sqflint:

Scripts\sqflint.exe
Scripts\sqflint.py

pip install git+https://github.com/LordGolias/sqf.git:

Scripts\sqflint.exe
Scripts\sqflint.py
Scripts\sqflint-script.py

New file sqflint-script.py contains:

#!"c:\program files\python37\python.exe"
# EASY-INSTALL-ENTRY-SCRIPT: 'sqflint==0.3.2','console_scripts','sqflint'
__requires__ = 'sqflint==0.3.2'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('sqflint==0.3.2', 'console_scripts', 'sqflint')()
    )