Python has ability to "pseudoinstall" a package by running it's setup.py
script with develop
instead of install
. This modifies python environment so package can be imported from it's current location (it's not copied into site-package
directory). This allows to develop packages that are used by other packages: source code is modified in place and changes are available to rest of python code via simple import
.
All works fine except that setup.py develop
command creates an .egg-info
folder with metadata at same level as setup.py
. Mixing source code and temporary files is not very good idea - this folder need to be added into "ignore" lists of multiple tools starting from vcs and ending backup systems.
Is it possible to use setup.py develop
but create .egg-info
directory in some other place, so original source code is not polluted by temporary directory and files?
egg-info format: a file or directory placed adjacent to the project's code and resources, that directly contains the project's metadata.
The . egg file is a distribution format for Python packages. It's just an alternative to a source code distribution or Windows exe .
Rule of thumb: do not commit generated information. Check in the source only. If you are using eggs from VC, then you have already installed these as development eggs; just re-run setup.py after updating the working copy.
setup.py develop
creates a python egg, in-place; it does not [modify the] python environment so package can be imported from it's current location. You still have to either add it's location to the python search path or use the directory it is placed in as the current directory.
It is the job of the develop
command to create an in-place egg, which may include compiling C extensions, running the 2to3 python conversion process to create Python3 compatible code, and to provide metadata other python code may be relying on. When you install the package as an egg in your site-packages
directory, the same metadata is included there as well. The data is certainly not temporary (it is extracted from your setup.py
file for easy parsing by other tools).
The intent is that you can then rely on that metadata when using your package in a wider system that relies on the metadata being present, while still developing the package. For example, in a buildout development deployment, we often use mr.developer
to automate the process of fetching the source code for a given package when we need to work on it, which builds it as a develop egg and ties it into the deployment while we work on the code.
Note that the .egg-info
directory serves a specific purpose: to signal to other tools in the setuptools eco-system that your package is installed and available. If your package is a dependency of another egg in your setup, then that dependency is satisfied. pip
and easy_install
and buildout will not try and fetch the egg from somewhere else instead.
Apart from creating the .egg-info
directory, the only other thing the command does, is to build extensions, in-place. So the command you are looking for instead is:
setup.py build_ext --inplace
This will do the exact same thing as setup.py develop
but leave out the .egg-info
directory. It also won't generate the .pth
file.
There is no way of generating only the .pth
file and leave out the .egg-info
directory generation.
Technically speaking, setup.py develop
will also check if you have the setuptools site.py
file installed to support namespaced packages, but that's not relevant here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With