fatiando / boule

Reference ellipsoids for geodesy and geophysics
https://www.fatiando.org/boule
BSD 3-Clause "New" or "Revised" License
38 stars 17 forks source link

Use nox to manage development #59

Closed leouieda closed 4 years ago

leouieda commented 4 years ago

Nox is a tool that automates setting up virtual environments and running tasks inside them. It's a combination of make and virtual environments. Replace the machinery in our Makefile (which wouldn't work on Windows) with a cross-platform noxfile.py. Since nox handles the virtual environments, the environment.yml only needs to have python and nox. Plus, the environment creation code in the CI is no necessary anymore and we can run tests on multiple python versions locally as well.

Reminders:

leouieda commented 4 years ago

I'm keeping the Makefile so that most instructions on the CONTRIBUTING.md still work but it's just a wrapper of the nox commands. We could remove it entirely and run nox instead.

leouieda commented 4 years ago

Now that I think about it, I would probably organize the CI workflows differently:

This way we avoid having multiple duplicate builds of the docs. We could still build on all systems but I think it would be fine to only run it on ubuntu.

santisoler commented 4 years ago

This looks great @leouieda! It's awesome to be capable of running tests on multiple Python versions locally without too much hassle.

For some reason my computer is skipping the py3.6 test:

nox > Session test-3.6 skipped: Python interpreter 3.6 not found.

Do you know why?

I did notice that even if you set up your conda environment, if you try to run nox without internet connection it fails because cannot install the dependencies. Is there a way to preinstall everything that nox needs beforehand so we don't depend on an internet connection for running the tests?

santisoler commented 4 years ago

I did notice that even if you set up your conda environment, if you try to run nox without internet connection it fails because cannot install the dependencies. Is there a way to preinstall everything that nox needs beforehand so we don't depend on an internet connection for running the tests?

Actually there is:

nox --install-only

https://nox.thea.codes/en/stable/usage.html?highlight=offline#skipping-everything-but-install-commands

Buuuut be very careful. If you run nox without the -r option you will undone the previous step and end up with no preinstalled environments. If we remove the Makefile in the future I can certainly see myself breaking my preinstalled environments very often, which will be a pain if I'm a on a place with bad internet connection, or no connection at all.

Maybe we can open an Issue on their repository for this.

leouieda commented 4 years ago

About running offline:

The default is making fresh environments but we can reverse that by setting nox.options.reuse_existing_virtualenvs=True. We can always disable on the command line with --no-reuse-existing-virtualenvs. I'll set this on and then we can skip the -r without much fear of nuking the environments.

leouieda commented 4 years ago

Alright, with the new file after 08e23c4 you can now:

Need to add these instructions to the docstring still.

leouieda commented 4 years ago

@santisoler if you could give this a try locally that would be very helpful. See if you like it and if there are any other pain points we can try to resolve

leouieda commented 4 years ago

@santisoler I made a few changes:

What do you think?

santisoler commented 4 years ago

This is looking great!

* Added instructions to the noxfile.py docstring

I like that we can list all the available targets with nox -l. We definitely should add this to the Contributing instructions once we ditch the make instructions.

* Added a `show` option to the docs build that opens the HTML in a web browser. I opted for this instead of serving since it would block the process and the noxfile would just hang. This works just as well and is easily cross-platform using `import webbrowser`.

Much better than before!

* Added rules to the Makefile for `nox-clean` and `nox-install`. The update command is not needed since it would be a clean and install anyway.

Sure, I was thinking to add the nox-update target calling the nox-clean and then nox-install, but we don't actually need another target to do so, we can use make nox-clean nox-update on a single line.

I think this is ready to go! Nice work @leouieda !

leouieda commented 4 years ago

Thanks @santisoler! Merging this in. I'll work on a follow up to organize the CIs a bit. Only thing I changed is that setuptools_scm doesn't need to be a run time dependency.