Use config file for pip within build

Question:

I am building a package from source files.

If I run with the argument

--no-isolation

It successfully builds. However, if I try to build in an isolated environment it fails trying to install packages [SSLCertVerificationError]. I have solved in my normal environment by adding the following to pip.ini

[global]
trusted-host = pypi.org
               files.pythonhosted.org
               pypi.python.org

What can I add to the command so that PIP within the Build process will use this config file.

python -m build [WHAT GOES HERE]

The particular line that it is failing at is:

subprocess.CalledProcessError: 
Command '['\Temp\build-env-zu51awtu\Scripts\python.exe', '-Im', 'pip', 'install', '--use-pep517', '--no-warn-script-location', '-r', '\Local\Temp\build-reqs-7xyim3xs.txt']' returned non-zero exit status 1.
Asked By: user157545

||

Answers:

There doesn’t appear to be a direct way to apply a config file to pip in this process.

Looking at the source code in build/env, line 228-238

cmd = [
                self.executable,
                '-Im',
                'pip',
                'install',
                '--use-pep517',
                '--no-warn-script-location',
                '-r',
                os.path.abspath(req_file.name),
            ]
            _subprocess(cmd)

This could either be modified directly by adding additional arguments to this list, or, by executing earlier in the program

        popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
        for stdout_line in iter(popen.stdout.readline, ""):
            print(stdout_line)

you will be able to see where pip is looking for config files and save a config file with the required options there.

Answered By: user157545
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.