Source

Setting up dev environment for SciPy

Hi everyone! πŸ‘‹

I got an email from someone pretty recently who wanted to setup a dev environment for SciPy. He had made changes to the source code of SciPy and now wanted to test if his changes were working or not. He had gotten so far without actually testing the code. In this post I will share details on how to setup a dev environment the right way. I will focus mainly on Mac OS.

Firstly, go to the GitHub repo and try to figure out the dependencies for the project. Normally they are listed in the readme file. If they are not listed there then you just try installing the package/libary and the errors in the terminal will give you a clue as to what you are missing. I did that and figured out that I needed Fortran compiler, Cython and NumPy.

Installing dependencies:

Let’s start with Fortran:

brew install gcc

Now create a new folder and setup a virtualenv there:

mkdir ~/dev
cd ~/dev
python -m venv env

Activate the virtualenv:

source env/bin/activate

Now install Cython and NumPy:

pip install cython
pip install numpy

Now clone SciPy:

git clone git@github.com:scipy/scipy.git

And finally install SciPy in development mode:

cd scipy
python setup.py develop

Normally if you are installing a Python package using the setup.py file, you use python setup.py install. This copies the code into the site-packages directory. After that if you make any changes to the source code of the package, you need to run python setup.py install each time.

The difference between that and python setup.py develop is that in the later case Python does not copy the code to site-packages. It uses the code from that development folder directly whenever you import the package. This way if you make any changes to the package you don’t need to run python setup.py install or python setup.py develop.

After you are done with the development you can safely type deactivate and this will turn off the virtualenv.

You can read more about virtualenv on Real Python. I hope someone out there in the same boat as one of my other readers finds this helpful.

Have a good day! ❀️

Newsletter

Γ—

If you liked what you read then I am sure you will enjoy a newsletter of the content I create. I send it out every other month. It contains new stuff that I make, links I find interesting on the web, and occasional discount coupons for my book. Join the 5000+ other people who receive my newsletter:

I send out the newsletter once every other month. No spam, I promise + you can unsubscribe at anytime

✍️ Comments

Be the first to leave a comment! πŸŽ‰

Say something

Send me an email when someone comments on this post.

Thank you!

Your comment has been submitted and will be published once it has been approved. 😊

OK