indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.48k stars 239 forks source link

Set PYTHONPATH for pip packaging rules #162

Open jayvdb opened 5 years ago

jayvdb commented 5 years ago

The following fails:

[[packaging_rule]]
type = "pip-install-simple"
package = "storyscript<0.26.0"
...
    Running setup.py install for storyscript: started
    Running setup.py install for storyscript: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /path/to/project/build/target/x86_64-unknown-linux-gnu/debug/pyoxidizer/python.608871543e6d/python/install/bin/python3.7m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h0rudgt_/storyscript/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h0rudgt_/storyscript/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-b6xa8xr1/install-record.txt --single-version-externally-managed --compile --home=/tmp/pip-target-t8k9ny8u
         cwd: /tmp/pip-install-h0rudgt_/storyscript/
    Complete output (33 lines):
    running install
    Checking .pth file support in /tmp/pip-target-t8k9ny8u/lib/python/
    /path/to/project/build/target/x86_64-unknown-linux-gnu/debug/pyoxidizer/python.608871543e6d/python/install/bin/python3.7m -E -c pass
    TEST FAILED: /tmp/pip-target-t8k9ny8u/lib/python/ does NOT support .pth files
    error: bad install directory or PYTHONPATH

    You are attempting to install a package to a directory that is not
    on PYTHONPATH and which Python does not read ".pth" files from.  The
    installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:

        /tmp/pip-target-t8k9ny8u/lib/python/

    and your PYTHONPATH environment variable currently contains:

        '/tmp/pyoxidizer-pip-install.R2XWB5qBRAW1/packages'

    Here are some of your options for correcting the problem:

    * You can choose a different installation directory, i.e., one that is
      on PYTHONPATH or supports .pth files

    * You can add the installation directory to the PYTHONPATH environment
      variable.  (It must then also be on PYTHONPATH whenever you run
      Python and want to use the package(s) you are installing.)

    * You can set up the installation directory to support ".pth" files by
      using one of the approaches described here:

      https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations

    Please make the appropriate changes for your system and try again.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /path/to/project/build/target/x86_64-unknown-linux-gnu/debug/pyoxidizer/python.608871543e6d/python/install/bin/python3.7m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-h0rudgt_/storyscript/setup.py'"'"'; __file__='"'"'/tmp/pip-install-h0rudgt_/storyscript/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-b6xa8xr1/install-record.txt --single-version-externally-managed --compile --home=/tmp/pip-target-t8k9ny8u Check the logs for full command output.

The cause is a hack in the setup.py (fixed but not released https://github.com/storyscript/storyscript/issues/1178).

The workaround is to use a virtualenv packaging rule, which uses the wheel.

It wont be very common, but it is solvable by setting PYTHONPATH in the subprocess invoking pip.

jayvdb commented 5 years ago

This is the same as https://github.com/indygreg/PyOxidizer/issues/70 , but for the different packaging rules.

jayvdb commented 4 years ago

Note with SetupPyInstall for storyscript<0.26.0, it fails with EasyInstall/Setuptools SandboxViolation while installing peewee because of the writes outside of the target dir.

error: Setup script exited with error: SandboxViolation: open('/tmp/pyoxidizer-temp-venv.0DMXAsCvpktT/venv/pyoxidizer/build_state/playhouse._sqlite_udf.0.o', 'wb') {}

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.

thread 'main' panicked at 'error running setup.py', pyoxidizer/src/app_packaging/packaging_rule.rs:734:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Also this is happening in a subprocess, so not easy to hack around, and not able to be disabled https://github.com/pypa/setuptools/issues/1151