Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve justfile to manage virtualenv #102

Closed
wants to merge 1 commit into from

Conversation

induane
Copy link

@induane induane commented Aug 22, 2024

Improve the justfile by adding a target to build the virtual environment for you

  • Added just target: setup-env
  • Test commands are automatically run within the virtual environment without it needing to be activated locally
  • setup-env target is parameterized for optional dependencies such as postgres and mysql
  • Updated CONTRIBUTING.md accordingly
  • Pip commands are run with options to disable some annoying output, avoid waiting for user input, and to fail faster when the upstream repository cannot be reached
  • The virtual environment folder is setup to contain the Python version number so that if[when] the default Python version changes it won't try to use an outdated env and yield obtuse confusing errors

…nt for you

- Added just target: ``setup-env``
- Test commands are automatically run within the virtual environment without it needing to be activated locally
- ``setup-env`` target is parameterized for optional dependencies such as *postgres* and *mysql*
- Updated ``CONTRIBUTING.md`` accordingly
- Pip commands are run with options to disable some annoying output, avoid waiting for user input, and to fail faster when the upstream repository cannot be reached
- The virtual environment folder is setup to contain the python version number so that if the default python version changes it won't try to use an outdated env
# Recipes
@default:
just --list

setup-env *args:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there's a need to be so prescriptive on the virtualenv location. The CONTRIBUTING.md simply shows it as an example. This adds a lot of additional complexity to the project, for the sake of saving a single commad.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit, though I do appreciate that the abstraction is general enough that if there is a switch to say, uv over pip in order to provide faster dependency resolution and such, that the switch could be made seamlessly without disturbing or changing any development workflow.

@@ -1,29 +1,42 @@
# Variables
PYTHON_VERSION := shell("python -c \"import sys;v=f'{sys.version_info.major}.{sys.version_info.minor}';sys.stdout.write(v)\"")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: If the system version updates, then the virtualenv disappears without warning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also a good point; coming from Makefiles, the venv would normally just be recreated automatically (but only if it didn't already exist); here there is a need to run the setup command once. I'm not aware of a builtin mechanism for building something only if it doesn't exist.

Do you know if just supports something to that effect?

@induane
Copy link
Author

induane commented Aug 22, 2024

Closing PR as unlikely to be merged. Thanks for the quick feedback!

@induane induane closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants