Python setup.py develop vs install
Codemia Knowledge Hub ·
When working with Python projects, particularly those containing external or internal dependencies, understanding the differences between `setup.py develop` and `setup.py install` is crucial. These commands, part of the Python setuptools module, offer distinct methods of installing a package. This article explores their functions, use cases, and differences to help you decide which to use for your projects.
setup.py Develop
The `setup.py develop` command is designed to install a package in a development mode. This approach allows you to modify your source code and have the changes immediately reflected in your environment without the need to reinstall the package.
How It Works
- Symbolic Link: When you run `setup.py develop`, setuptools creates a symbolic link to your project directory in the site-packages directory. This means that the Python interpreter directly references your project files.
- Editable Mode: As changes are made in the source files of your project, they are instantly available as part of your Python environment without requiring reinstallation.
Use Cases
- Active Development: Ideal for when you're building or contributing to a package and you want to frequently test changes.
- Library Maintenance: Useful for maintaining a library because updates can be tested immediately.
- Dependency Management: Helpful when you need dependencies in development mode, particularly in complex environments with multiple interdependent projects.
Example
If you are developing a package named `mypackage`, and you've cloned its source, navigate into the directory and run:
- Copying Files: This method copies files from your project's source directory into the site-packages directory, making them accessible to the Python environment.
- Standard Installation: The copied files are static, and any subsequent changes in the project directory require reinstallation to reflect the changes.
- Production Environment: Suitable for deploying applications in a production environment where stability is crucial.
- Non-Development Usage: When simply using a package without plans to modify or develop it further.
- Package Distribution: For users receiving a formally released package version meant for consumption rather than development.
Related reading
- python setup.py uninstall
- Python sklearn fit_transform does not work for GridSearchCV
- python sklearn multiple linear regression display r-squared
- Python Spacy similarity without loop?
- Python strftime - date without leading 0?
- Python String clustering with scikit-learn''s dbscan, using Levenshtein distance as metric
- Python string 'in' operator implementation algorithm and time complexity
- Python string.replace regular expression
System design interview problems on this topic
- Design a Web Crawler: solution and walkthrough
- Design a Task Scheduler: solution and walkthrough
- Design a URL Shortener (TinyURL): solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.