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

Be able to find chia command without activating the env #80

Open
altendky opened this issue Apr 3, 2021 · 6 comments · May be fixed by #106
Open

Be able to find chia command without activating the env #80

altendky opened this issue Apr 3, 2021 · 6 comments · May be fixed by #106
Labels
enhancement New feature or request

Comments

@altendky
Copy link
Collaborator

altendky commented Apr 3, 2021

I'm not really sure what the priority should be in the case where there's a chia on the $PATH and also in the same env as plotman, but at least in the case where chia is not on the on the $PATH and is available in the env, it seems like it should be used? Or maybe it must be configured? At a high level this relates to being able to run plotman without activating the environment.

sysconfig.get_path() can get us the scripts (bin) path.

$ venv/bin/python -c 'import sysconfig; print(sysconfig.get_path("scripts"))'
/farm/venv/bin

Or, maybe we can get the executable path from psutil when there are existing plots and if they all match then we can presume that's the chia to use?

Here are some issues that are at least in part related to chia-finding.

@altendky
Copy link
Collaborator Author

altendky commented Apr 9, 2021

Will probably need to tweak the $PATHfor the subprocess to include the scripts path so chia itself can still subprocess as needed. I'm not sure if they are consistently using sys.executable or the scripts path or such for their own needs.

@altendky altendky linked a pull request Apr 10, 2021 that will close this issue
3 tasks
@13thProgression
Copy link
Contributor

It seems dangerous to try to modify the requirements of chia to make plotman more approachable. I understand the intent, but if chia changes how they initialize their software it could leave plotman broken. Perhaps a more verbose error if the env isn't activated?

@altendky
Copy link
Collaborator Author

There's no need to modify chia. And it is entirely proper for Python programs to be usable without activating the environment. Basically all activating the virtual environment does is add the env/bin/ directory to your PATH so that the Python and other programs there will be found.

@altendky
Copy link
Collaborator Author

Oh, and chia already works fine in my experience without activating the environment.

@13thProgression
Copy link
Contributor

At the moment, this is true. My point was more that the chia project provides guidelines for how to start plots. Circumventing those guidelines might work at the moment, but any change on the chia project side can break this in the future. Conforming to their current guidelines is like conforming to an API: no guarantee of future compatibility, but higher likelihood.

I don't think this change will reduce confusion for new users. This may be convenient for experienced users that always update chia in the same location. However, could cause issues for users that update chia in a new path before deleting the old one (to reduce downtime in the event that something goes wrong with the new version.)

Don't mean for this to sound negative about the potential change, just trying to enumerate a few possible unintended consequences.

@altendky
Copy link
Collaborator Author

Perhaps you have opinions about priorities and configurability of this? I think configurability could be good including allowing hardcoding a path to the chia to use. For defaults, at the moment it seems like searching PATH first is reasonable for backwards compatibility and allowance of env activation, when the user chooses to do it, to have the (theoretically) intended effect and take priority. Then second, look in the plotman env.

Note that plotman is going to be importing chia to use the chia code to parse plot command lines. Yes, this increases the coupling between the two. But, we've had numerous people having lots of different issues with this and rewriting a command line parsing isn't obviously a good choice. Yes, we may also end up copying the chia cli definition code into plotman to change the coupling (reduced in some ways, increased in others). At the end of the day, they are coupled and chia doesn't presently provide an api. Anyways, env/bin/pip install plotman[chia] will be a reasonable option for simple startup in many cases (never all) without git cloning anything etc. It seems useful for the result to work with or without activation.

@BasilHorowt BasilHorowt added the enhancement New feature or request label May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants