Search code examples
pythondistutils

Install python package into directory relative to site-packages


I have a Python package that is one of a collection of company Python packages. When I run

python setup.py install

I want the package to be installed to a common company directory, along with other company packages. I want this directory to be relative to the default Python install directory, e.g.,

/usr/lib/python2.7/site-packages/<company_name>/<python_package_name>

That is, I want to insert <company_name> into the installation path at install time.

I've seen ways to prefix this path, but can't seem to work out how to do what I've described.


Solution

  • Unfortunately Python packaging doesn't work like that. You could probably bend it to work like that but that would be quite an effort for a person without experience in Python packaging and even for experienced persons the amount/output tradeoff would not make sense. You do not mention any motive to do this besides your personal preference.

    Instead, to have well-managed and human-navigable package installation folder, I recommend you to study the following resources