Mystery running pip in destroot phase

René J.V. Bertin rjvbertin at gmail.com
Sun Aug 13 13:53:13 UTC 2023


Hi,

I'm running into a mystery trying to install from a python source tarball using pip, in the destroot phase of a port. That sounds like a question for the -dev ML; I'm posting it here because I think it's really a question about python.

I have this snippet of portfile code:

{{{
    destroot.cmd    ${prefix}/bin/pip-${python.branch}
    destroot.args   --no-deps --no-cache-dir -I --root ${destroot} \
                    ${distpath}/${distfiles}
    destroot.post_args
    pre-destroot {
        system "printenv"
        system "${destroot.cmd} install --user setuptools"
    }
}}}

The first few lines ensure that pip is run with `--no-deps --no-cache-dir -I` on the source tarball, installing under the $destroot "distribution" dir. The `pre-destroot` step prints out the environment and  then attempts to make certain that a copy of the setuptools are available (redundant, but see below).

I get this output, omitting the output from `printenv`:

{{{
Requirement already satisfied: setuptools in /opt/local/lib/python3.9/site-packages (60.2.0)
Processing /opt/local/var/lnxports/distfiles/py-dbusmock/python-dbusmock-0.29.1.tar.gz
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      ERROR: Could not find a version that satisfies the requirement setuptools>=45 (from versions: none)
      ERROR: No matching distribution found for setuptools>=45
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
}}}

The 1st line indicates that pip finds `setuptools`, in a new-enough version. Yet when the actual install is attempted an error is raised that this very package cannot be found.

This seems to hinge on the fact that "base" sets the $HOME directory to a temporary (sandboxed) one under the port's work directory.

Any experienced Python users on this list who have an idea what's going on? I get the same error when I omit `--no-deps`.

Thanks,
R.


More information about the macports-users mailing list