-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
language/python: add types #16799
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
language/python: add types #16799
Conversation
Also add `Virtualenv` getters to get `Pathname`s to the virtualenv's `root` and `site_packages`. Signed-off-by: Michael Cho <michael@michaelcho.dev>
f0f430a
to
383d774
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I tried installing a Python package locally and it seems happy.
sig { returns(Pathname) } | ||
def root | ||
@venv_root | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this getting used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally used it in this file before adding site_packages
.
I was thinking it could be used in homebrew-core
rather than hardcoding path again later on, e.g. uhdm
: https://github.com/Homebrew/homebrew-core/blob/master/Formula/u/uhdm.rb#L49
- "-DPython3_EXECUTABLE=#{buildpath}/venv/bin/python", *std_cmake_args
+ "-DPython3_EXECUTABLE=#{venv.root}/bin/python", *std_cmake_args
Though I can remove it if preferred as most cleanup is handled by using site_packages
, e.g. qt
- venv_root = buildpath/"venv"
- venv = virtualenv_create(venv_root, python)
+ venv = virtualenv_create(buildpath/"venv", python)
venv.pip_install resources
- ENV.prepend_path "PYTHONPATH", venv_root/Language::Python.site_packages(python)
+ ENV.prepend_path "PYTHONPATH", venv.site_packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it makes sense in that case. I was only thinking about it in the context of this file but if it can simplify the code in core then I'm all for it.
if t.respond_to? :stage | ||
if t.is_a?(Resource) | ||
t.stage { do_install(Pathname.pwd, build_isolation: build_isolation) } | ||
else | ||
t = t.lines.map(&:strip) if t.respond_to?(:lines) && t.include?("\n") | ||
t = t.lines.map(&:strip) if t.is_a?(String) && t.include?("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks out.
brew(main):004:0> [String, Pathname, Resource].select { _1.instance_methods.include? :lines }
=> [String]
brew(main):005:0> [String, Pathname, Resource].select { _1.instance_methods.include? :stage }
=> [Resource]
Thanks again |
Also add
Virtualenv
getters to getPathname
s to the virtualenv'sroot
andsite_packages
.brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?