freezing-photographer-88553
02/14/2022, 11:05 AMsrc
├── projects
│ └── one_shot
│ ├── one_shot <------- source code
│ ├── requirements.txt
│ └── test_one_shot <------- test code, requires one_shot and sail to be installed
└── sail <------- old source code
Running ./pants test ./src/projects/one_shot/test_one_shot/test_file.py will fail because the sail package is not installed. How can I specify this dependency on first-party code in a BUILD file ?curved-television-6568
02/14/2022, 11:23 AMsail using normal imports, you should not have to specify that dependency, it will be inferred.curved-television-6568
02/14/2022, 11:25 AMfreezing-photographer-88553
02/14/2022, 11:34 AM>> ./pants roots
src/projects/one_shot/one_shot
src/projects/one_shot/test_one_shot
src/sail
But sail is not detected.freezing-photographer-88553
02/14/2022, 11:34 AMtest_one_shot
src/projects/one_shot/test_one_shot/test_anchor.py:7: in <module>
from sail.one_shot import something
E ModuleNotFoundError: No module named 'sail'curved-television-6568
02/14/2022, 11:35 AMsail to be picked up as a module, I think you want one of your source roots to be src there..freezing-photographer-88553
02/14/2022, 11:38 AMsrc/ as root and not src/sail .freezing-photographer-88553
02/14/2022, 11:38 AMsrc that I do not wish to use as source codecurved-television-6568
02/14/2022, 11:39 AMsrc/sail then the files in that folder won’t know they belong to sail (as that is not part of the package/module name)curved-television-6568
02/14/2022, 11:40 AMfreezing-photographer-88553
02/14/2022, 11:40 AMsail/BUILD file would be enough to specify the module name.freezing-photographer-88553
02/14/2022, 11:40 AMcurved-television-6568
02/14/2022, 11:40 AMcurved-television-6568
02/14/2022, 11:41 AMname of your python_sources is just to give your target an address to refer to in the Pants world. And for python_distribution the name in the python_artifact (if you use that) is for the python distribution name, and does not affect the runtime characteristics either.curved-television-6568
02/14/2022, 11:43 AMsrc that you don’t want to include, and tell tailor to skip them (if you use Tailor to setup BUILD files for you), Pants should not pick up any sources from those folders. So should be ok, I think.freezing-photographer-88553
02/14/2022, 11:43 AMcurved-television-6568
02/14/2022, 11:44 AMfreezing-photographer-88553
02/14/2022, 12:08 PMhappy-kitchen-89482
02/14/2022, 4:45 PMfrom sail.one_shot import something then you want the parent of sail to be a source roothappy-kitchen-89482
02/14/2022, 4:45 PMhappy-kitchen-89482
02/14/2022, 4:46 PMhundreds-father-404
02/14/2022, 4:46 PMWe should probably attempt to auto-detect thoseAt least via
./pants tailor and update pants.tomlhappy-kitchen-89482
02/14/2022, 4:46 PMhappy-kitchen-89482
02/14/2022, 4:47 PMcurved-television-6568
02/14/2022, 5:01 PM$ ./pants tell-me-my-module-name src/sail/one_shot.py
one_shot # using source root `src/sail`