Python setup.py develop vs install
python setup.py install
is used to install (typically third party) packages that you're not going to develop/modify/debug yourself.
For your own stuff, you want to first install your package and then be able to frequently edit the code without having to re-install the package every time — and that is exactly what python setup.py develop
does: it installs the package (typically just a source folder) in a way that allows you to conveniently edit your code after it’s installed to the (virtual) environment, and have the changes take effect immediately.
Note: It is highly recommended to use pip install .
(regular install) and pip install -e .
(developer install) to install packages, as invoking setup.py
directly will do the wrong things for many dependencies, such as pull prereleases and incompatible package versions, or make the package hard to uninstall with pip
.
Update:
The develop
counterpart for the latest python -m build
approach is as follows (as per):
Use Python setup.py to install different dependencies with develop vs install
One way I know of is to use pip, for example:
$ pip install --editable .[dev]
Difference between setup.py install and setup.py develop
develop
creates an .egg-link
file in the site-packages
directory, which points back to the location of the project files. The same path is also added to the easy-install.pth
file in the same location. Uninstalling with setup.py develop -u
removes that link file again.
Do note that any install_requires
dependencies not yet present are also installed, as regular eggs (they are easy_install
-ed). Those dependencies are not uninstalled when uninstalling the development egg.
pip install --editable ./ vs python setup.py develop
Try to avoid calling setup.py
directly, it will not properly tell pip that you've installed your package.
With pip install -e
:
For local projects, the “SomeProject.egg-info” directory is created
relative to the project path. This is one advantage over just usingsetup.py develop
, which creates the “egg-info” directly relative the
current working directory.
More: docs
Also read the setuptools' docs.
When would the -e, --editable option be useful with pip install?
As the man page says it:
-e,--editable <path/url>
Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url.
So you would use this when trying to install a package locally, most often in the case when you are developing it on your system. It will just link the package to the original location, basically meaning any changes to the original package would reflect directly in your environment.
Some nuggets around the same here and here.
An example run can be:
pip install -e .
or
pip install -e ~/ultimate-utils/ultimate-utils-proj-src/
note the second is the full path to where the setup.py
would be at.
Installing more files with `python setup.py develop`
I found it reading the source for setuptools.command.develop
: develop
runs the build_ext
command with the inplace
parameter, which tells build_ext
to save the build output to the source tree. This parameter can predictably be tested with self.inplace
from the build_ext
subclass. From there, it's only a matter of changing where the files are copied.
It's handled in a different way in Python 3, which I have not explored.
Related Topics
Matplotlib Plots: Removing Axis, Legends and White Spaces
Python's Most Efficient Way to Choose Longest String in List
How to Get a Value of Datetime.Today() in Python That Is "Timezone Aware"
Pandas Dataframe: Replace Nan Values with Average of Columns
Does Python Support Multithreading? Can It Speed Up Execution Time
Importerror: No Module Named Pil
Difference Between Subprocess.Popen and Os.System
Django Filter Queryset _In for *Every* Item in List
How to Split Elements of a List
What's the Function Like Sum() But for Multiplication? Product()
Python: Get a Frequency Count Based on Two Columns (Variables) in Pandas Dataframe Some Row Appers
Find the Max of Two or More Columns with Pandas
How to Include Third Party Python Libraries in Google App Engine
Python Nltk Pos_Tag Not Returning the Correct Part-Of-Speech Tag
Grouping Python Dictionary Keys as a List and Create a New Dictionary with This List as a Value