For python libs, is there a good way to alias a li...
# general
p
For python libs, is there a good way to alias a library into a package?
h
I’m not following what you mean. Do you mean something like creating an alias for a
python_library
target?
p
like if i create a python library for sources of “libs/*.py” but i want to be able to import files from there as deploy.libs.name_here, prefixing deploy in front of the directory structure
h
Something like this? https://www.pantsbuild.org/docs/resources#relocated_files It probably can’t be used here, but the general idea of relocating things at runtime rather than build time
p
iiinteresting, is this only v2?
h
Yes, v2 only
But I'm not sure that works for importable code
h
Yes, and it also only works with
files()
. While you can put Python files in a
files()
target, it has some implications: - dependency inference won’t work for imports of those files - formatters/linters won’t work when running on them - Pants won’t add the “source root” to PYTHONPATH, which means it’s possible imports will fail. While Pants won’t want to add something like
relocated_python_library
, we could help you write a plugin for that if y’all were able to upgrade to 2.0.
h
importable files are resources
but yeah, this would be an easy custom plugin to write
h
Otherwise, you’d need to physically move the files to have the directory structure you want
p
ill try moving directories, i was just being lazy
👍 1