[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pydistutils.cfg injection


I'm trying to build a Python application in Launchpad and I'm currently
having some issues with distutils.

The build on Launchpad is constrained by 2 things:
1) the builder is isolated from network.
2) must be fully open source (can't ship pre-built binaries).

I vendored in my PyPI dependencies in form of source packages and I
pip install them:

pip instal --find-links=/my/own/vendored/pypi/packages

This works like a charm until pip tries to build a package that has
build-time dependencies and does not conform to PEP 518:


(which is majority of packages, sadly).

Then, easy_install kicks in and it tries to fetch from network, as it
does not use pip's --find-links option.

Thanks to some earlier answer on this group, I found pydistutils.cfg
workaround for this issue, but this approach has some very annoying
limitation - cfg file is read from 3 pre-defined locations:

1) ${PWD}
2) distutils directory (which is inside system installed Python
3) ${HOME}

All 3 are no-go in most automated environments.

I checked distutils source code and I have a proposal.

In ${PYTHON_INSTALL}/distutils/dist.py there is a function:

class Distribution:
    def find_config_files(self):
        if self.want_user_cfg:
            user_file = os.path.join(os.path.expanduser('~'), user_filename)
            if os.path.isfile(user_file):

        return files

How about adding an environment variable, let's say
DISTUTILS_CONFIG_PATH, and resolving it alongside ~?

For now, I need to re-define my ${HOME} to simulate this behaviour. This
hack might however break some other code that depends on proper ${HOME}
value, so while working for me, could still be an issue for somebody else.

What do you think? Is such change feasible? I can make a patch - how to
submit it?

Best regards,
Chris Narkiewicz

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20190311/6ef6efa1/attachment.sig>