saghul / pycares

Python interface for c-ares
https://pypi.org/project/pycares/
MIT License
165 stars 73 forks source link

Pip installation fails (sandbox violation) #107

Closed MarcelBeining closed 4 years ago

MarcelBeining commented 4 years ago

During installation I get the following error on Windows server 2008, python 3.8

Collecting pycares>=1.0.0
  Using cached https://files.pythonhosted.org/packages/85/de/cd46a73e43e206a6ad1e9cf9cc893c3ed1b21caf57f1e0a8d9a119d290eb/pycares-3.0.0.tar.gz
    ERROR: Command errored out with exit status 1:
     command: 'C:\Program Files (x86)\Python\Python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator
\\AppData\\Local\\Temp\\3\\pip-install-hgmj57cc\\pycares\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\3\\pip-install-
hgmj57cc\\pycares\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exe
c(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Administrator\AppData\Local\Temp\3\pip-install-hgmj57cc\pycares\pip-egg-info
'
         cwd: C:\Users\Administrator\AppData\Local\Temp\3\pip-install-hgmj57cc\pycares\
    Complete output (106 lines):
    Traceback (most recent call last):
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
        yield saved
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
        yield
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "C:\Users\ADMINI~1\AppData\Local\Temp\3\easy_install-iej8409z\cffi-1.13.2\setup.py", line 127, in <module>
      File "C:\Users\ADMINI~1\AppData\Local\Temp\3\easy_install-iej8409z\cffi-1.13.2\setup.py", line 105, in uses_msvc
      File "C:\Program Files (x86)\Python\Python38-32\lib\distutils\command\config.py", line 225, in try_compile
        self._compile(body, headers, include_dirs, lang)
      File "C:\Program Files (x86)\Python\Python38-32\lib\distutils\command\config.py", line 127, in _compile
        src = self._gen_temp_sourcefile(body, headers, lang)
      File "C:\Program Files (x86)\Python\Python38-32\lib\distutils\command\config.py", line 109, in _gen_temp_sourcefile
        with open(filename, "w") as file:
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 418, in _open
        self._violation("open", path, mode, *args, **kw)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 407, in _violation
        raise SandboxViolation(operation, args, kw)
    setuptools.sandbox.SandboxViolation: SandboxViolation: open('_configtest.c', 'w') {}

    The package setup script has attempted to modify files on your system
    that are not within the EasyInstall build area, and has been aborted.

    This package cannot be safely installed by EasyInstall, and may not
    support alternate installation locations even if you run its setup
    script by hand.  Please inform the package's author and the EasyInstall
    maintainers to find out if a fix or workaround is available.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Administrator\AppData\Local\Temp\3\pip-install-hgmj57cc\pycares\setup.py", line 15, in <module>
        setup(name             = 'pycares',
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\__init__.py", line 139, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\dist.py", line 716, in fetch_build_eggs
        resolved_dists = pkg_resources.working_set.resolve(
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 780, in resolve
        dist = best[req.key] = env.best_match(
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 1065, in best_match
        return self.obtain(req, installer)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 1077, in obtain
        return installer(requirement)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\dist.py", line 786, in fetch_build_egg
        return cmd.easy_install(req)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\command\easy_install.py", line 679, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\command\easy_install.py", line 705, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\command\easy_install.py", line 890, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\command\easy_install.py", line 1158, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\command\easy_install.py", line 1144, in run_setup
        run_setup(setup_script, args)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 253, in run_setup
        raise
      File "C:\Program Files (x86)\Python\Python38-32\lib\contextlib.py", line 131, in __exit__
        self.gen.throw(type, value, traceback)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
        yield
      File "C:\Program Files (x86)\Python\Python38-32\lib\contextlib.py", line 131, in __exit__
        self.gen.throw(type, value, traceback)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\_vendor\six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
        yield saved
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
        yield
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "C:\Users\ADMINI~1\AppData\Local\Temp\3\easy_install-iej8409z\cffi-1.13.2\setup.py", line 127, in <module>
      File "C:\Users\ADMINI~1\AppData\Local\Temp\3\easy_install-iej8409z\cffi-1.13.2\setup.py", line 105, in uses_msvc
      File "C:\Program Files (x86)\Python\Python38-32\lib\distutils\command\config.py", line 225, in try_compile
        self._compile(body, headers, include_dirs, lang)
      File "C:\Program Files (x86)\Python\Python38-32\lib\distutils\command\config.py", line 127, in _compile
        src = self._gen_temp_sourcefile(body, headers, lang)
      File "C:\Program Files (x86)\Python\Python38-32\lib\distutils\command\config.py", line 109, in _gen_temp_sourcefile
        with open(filename, "w") as file:
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 418, in _open
        self._violation("open", path, mode, *args, **kw)
      File "C:\Program Files (x86)\Python\Python38-32\lib\site-packages\setuptools\sandbox.py", line 407, in _violation
        raise SandboxViolation(operation, args, kw)
    setuptools.sandbox.SandboxViolation: SandboxViolation: open('_configtest.c', 'w') {}

    The package setup script has attempted to modify files on your system
    that are not within the EasyInstall build area, and has been aborted.

    This package cannot be safely installed by EasyInstall, and may not
    support alternate installation locations even if you run its setup
    script by hand.  Please inform the package's author and the EasyInstall
    maintainers to find out if a fix or workaround is available.

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
robertoea commented 4 years ago

I think you need to update your setuptools to version 42.0.0.

MarcelBeining commented 4 years ago

Thanks @robertoea, that at least changed the error message :-D I then got the error that no wheel is available for my environment (Win Server 2008, Python 3.8). I then switched to Python 3.6 which finally did the job. However it would be cool if you could add a wheel for this configuration, so that I don't need to exclude this environment from the supported environments of my software :-)

arifardiasmono commented 4 years ago

Hi, I got the same error ,, after updating setuptools to 42.0.0 it ask me to install Build tools for visual studio then when finish installing I try to pip install pycares but got another error it says
"c:\users\big data lab\appdata\local\programs\python\python38\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory"

any solutive idea ?? error pycares 2

saghul commented 4 years ago

Do you have the necessary build tools installed?

arifardiasmono commented 4 years ago

I think yes ,, I've installed microsoft visual studio because it required microsoft visual c++ 14.0 or later and that error I got after install VS

robertoea commented 4 years ago

You might be missing Windows 10 SDK.

(If it takes too much effort to collect all build dependencies and you just want to use pycares, you might want to consider downloading prebuilt wheel somebody else already built, e.g. http://www.lfd.uci.edu/~gohlke/pythonlibs/)

arifardiasmono commented 4 years ago

Thanks @robertoea ,, I've tried to install prebuilt wheel and it has installed successfully. But is it the right/safe way to install?

robertoea commented 4 years ago

As I said earlier, it’s probably better/easier for you to simply get the prebuilt wheel as the Windows 10 SDK might not be the only dependency you’re missing. I could build pycares just fine on my Windows 10 with python 3.8 so I think if you have all the dependencies it should work as well for you.

Functionally the prebuilt wheel should do equally fine. As for security, it’s a matter of trust. The one I linked earlier is pretty well known in the community so the risk isn’t too high for normal usage. Of course having anything prebuilt is not as “safe” as auditing and building everything yourself from source, but given that you seem to have difficulties in doing so yourself, I would argue that getting it prebuilt is a reasonable choice.

saghul commented 4 years ago

Pycares 3.1.0 is now availablw with wheels also for Python 3.8: https://pypi.org/project/pycares/3.1.0/#files