manugarg / pacparser

A library to parse proxy auto-config (PAC) files
http://pacparser.manugarg.com
GNU Lesser General Public License v3.0
506 stars 116 forks source link

PIP package for Python 3.6 #139

Closed hecko closed 5 months ago

hecko commented 2 years ago

RHEL 8 and its forks like AlmaLinux release 8.6 (Sky Tiger) have Python 3.6.8 as a defaut install. Would be great to have an opportunity to install pacparser directly from pip.

Currently the attempt to install the package fails with

Using legacy 'setup.py install' for pacparser, since package 'wheel' is not installed.
Installing collected packages: pacparser
    Running setup.py install for pacparser ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-smuw_sj5/pacparser_67e1950c40114cc683e8c5b55c8dcf97/setup.py'"'"'; __file__='"'"'/tmp/pip-install-smuw_sj5/pacparser_67e1950c40114cc683e8c5b55c8dcf97/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7jq_ttik/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/pacparser
         cwd: /tmp/pip-install-smuw_sj5/pacparser_67e1950c40114cc683e8c5b55c8dcf97/
    Complete output (16 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/pacparser
    copying pacparser/__init__.py -> build/lib.linux-x86_64-3.6/pacparser
    running build_ext
    building '_pacparser' extension
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../spidermonkey/js/src -I.. -I/usr/include/python3.6m -c pacparser_py.c -o build/temp.linux-x86_64-3.6/pacparser_py.o
    pacparser_py.c:22:10: fatal error: pacparser.h: No such file or directory
     #include "pacparser.h"
              ^~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-smuw_sj5/pacparser_67e1950c40114cc683e8c5b55c8dcf97/setup.py'"'"'; __file__='"'"'/tmp/pip-install-smuw_sj5/pacparser_67e1950c40114cc683e8c5b55c8dcf97/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7jq_ttik/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/pacparser Check the logs for full command output.

and the compilation returns this:

[root@f7fccebbe896 pacparser]# make -C src pymod
make: Entering directory '/root/git/pacparser/src'
cd pymod && ARCHFLAGS="" python3 setup.py build
/root/git/pacparser/.git
Traceback (most recent call last):
  File "setup.py", line 156, in <module>
    main()
  File "/usr/lib64/python3.6/unittest/mock.py", line 1183, in patched
    return func(*args, **keywargs)
  File "setup.py", line 143, in main
    version = pacparser_version(),
  File "setup.py", line 67, in pacparser_version
    return git_version()
  File "setup.py", line 61, in git_version
    text=True
  File "/usr/lib64/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib64/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'text'
make: *** [Makefile:130: pymod] Error 1
make: Leaving directory '/root/git/pacparser/src'

That can be fixed (in my environment) by replacing text=True in setup.py to encoding='utf8' and recompiling and installing and the pacparser seems to work without an issue.

Marcel

manugarg commented 5 months ago

Closing this as 3.6 has been end of life for very long now. https://devguide.python.org/versions/