This script compares two Python environments (Conda or virtualenv) and lists all top-level packages, highlighting unique packages for each environment. It also compares environment variables and startup scripts. Additionally, it compares packages listed by Conda and Pip within the same environment.
To set up the environment for running this script, use the provided environment.yml
file.
-
Create the Conda environment:
conda env create -f environment.yml
-
Activate the environment:
conda activate compare-envs
Run the script to compare two environments. It lists all top-level packages and highlights the unique ones in bright red, packages with different versions in bright yellow, and packages common to both environments in green. It also compares environment variables and startup scripts if they exist. Additionally, it compares packages listed by Conda and Pip within the same environment.
python compare_envs.py
-
Environment Type: Enter the environment type (c for Conda, v for virtualenv). The default is Conda.
-
Environment Selection: The script lists available environments. Enter the number corresponding to the environments you want to compare.
The script will display:
- All packages in each environment, with unique packages highlighted in bright red, packages with different versions in bright yellow, and packages common to both environments in green.
- Environment variables specific to each environment.
- Startup scripts specific to each environment.
- Comparison of packages listed by Conda and Pip within the same environment.
The results will also be saved in './results/ with a file named <env1 name>_vs_<env2 name>.txt
.
- If
pipdeptree
is not installed in the target environments, the script will automatically install it. - Ensure you have the necessary permissions to activate and modify the target environments.
- Detailed logs are available in the
compare-envs.log
file.
This project is licensed under the Apache 2.0 License.