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

Output rye version to stdout #307

Closed
zztkm opened this issue Jun 11, 2023 · 7 comments · Fixed by #342
Closed

Output rye version to stdout #307

zztkm opened this issue Jun 11, 2023 · 7 comments · Fixed by #342

Comments

@zztkm
Copy link

zztkm commented Jun 11, 2023

I have created the following Makefile and am trying to tag it using rye version.

VERSION := $$(make -s show-version)

.PHONY: show-version
show-version:
	@rye version 2>&1

.PHONY: tag
tag:
	@echo "Tagging version $(VERSION)"
	@git tag $(VERSION)

However, with the current output method, the rye version is output to stderr and needs to be redirected to stdout (as in 2>&1)..

[IMO] It is more intuitive to output rye version to stdout.

@mitsuhiko
Copy link
Collaborator

I'm not opposed but I think a lot of the output of rye is currently going to stderr, this is not an exception. Might require some rethinking of what should go where.

@jeanas
Copy link

jeanas commented Jun 11, 2023

I think it is common practice to output versions to stdout.

~ $ cp --version 2> /dev/null
cp (GNU coreutils) 9.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
~ $ python --version 2> /dev/null
Python 3.11.3
~ $ git --version 2> /dev/null
git version 2.40.1
~ $ pip --version 2> /dev/null
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11) 

@zztkm
Copy link
Author

zztkm commented Jun 12, 2023

Might require some rethinking of what should go where.

My personal opinion is that a simple policy of basically outputting to stdout and errors to stderr is fine.

Also, if there is information that outputting to stdout would result in noise, I think it is better to output to stderr.

@mitsuhiko
Copy link
Collaborator

The reason this is not the policy today is that rye does a bunch of things as a byproduct of running commands. For instance it can sync as part of just running python via the shim, and when it does you don't want this to show up on stdout.

@zztkm
Copy link
Author

zztkm commented Jun 12, 2023

For instance it can sync as part of just running python via the shim, and when it does you don't want this to show up on stdout.

Agreed.

So how about using println only in specific cases where it is desirable to output to stdout? In my case, it is version cmd.

@zztkm
Copy link
Author

zztkm commented Jun 21, 2023

I want the discussion to move forward, so I'll add to it.

I want rye version to output results like 0.1.0 to stdout. This is the main execution result of rye version, and there should be no problem to output it to stdout.

On the other hand, messages to the user and command progress should be output to stderr.

Example

> rye sync
Initializing new virtualenv in /Users/zztkm/dev/sandbox/pydev/rye-version/.venv
Python version: [email protected]
Generating production lockfile: /Users/zztkm/dev/sandbox/pydev/rye-version/requirements.lock
Generating dev lockfile: /Users/zztkm/dev/sandbox/pydev/rye-version/requirements-dev.lock
Installing dependencies
Looking in indexes: https://pypi.org/simple/
Obtaining file:///. (from -r /var/folders/jf/ppd8_ywn5j94k064g559vgq00000gp/T/tmp8o_qi2pr (line 1))
  Installing build dependencies ... done
```

@zztkm
Copy link
Author

zztkm commented Jun 21, 2023

@mitsuhiko Thank you so much for your support!

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 a pull request may close this issue.

3 participants