pants: Tailor Command not detecting new python_sources with top-level dependencies files
Describe the bug
We are facing an issue with the tailor command, it is not generating BUILD files correctly from the new Python package inside any projects if I have a files target with generic import all files for Docker image targeting which appears to make tailor ignore all-new package files and don’t create BUILD files with tailor ::
I have a small fresh repo that I have created to reproduce this so you can test (link in additional info and more detail in Readme)
Pants version 2.15.0rc4 (tested with 2.14.1 also)
OS WSL 2, Ubuntu 20.04 LTS
Additional info
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (10 by maintainers)
After doing some tests, I went with the alternative to add a sed command in my build script that will add a
#to ignore one line per BUILD file at the top of each microservices.So my BUILD file will look like this in the repo, so all tailor commands work perfectly and all tests load all the files like json, ini and anything that could be in any project.
and the sed command in my build script replace the line
"!*/**/*.py",for# "!*/**/*.py",which import all python file before doing thepublishcommand. So far so good! If you have a better idea, please tell me. This is a workaround and if there is another possibility using Pants to do the most hermetic approach between testing and packaging, that would be sweet.Just to give you more background on us, we have 20+ microservices with libraries that we migrated to a mono repo pattern. We started using pants to bring standardization on the Linting, Unit Testing and a generic solution to Package and Publish our Containers. I tried the PEX way first and realize that some of our projects are old or not implemented in a “standards” way which was resulting in a lot of conflicts, missing imports, missing files and broken entry points (since some projects had up to 4 entry points for stuff like migrations, management, etc) So I changed our approach by keeping everything like Formatting, Linting and Testing in a pure Pants approach but the Packaging and Publishing process to a kind of Hybrid style (load all files and Build all Dockerfile the way we were doing before but asking pants to do it) that’s why I need all the files and python files loaded up ONLY on the packaging.
I know this is not the “pants way” but this is the solution we found that was working the best currently. Right now, all the tests are working great and the full pipeline is using Toolchain to remote cache, the publishing is working great and nothing broke on the end.
The issue is bugging us at the moment when developers are creating new packages, the BUILD files are not generated along the new package and cause conflicts since the Unit tests are not picking the package without BUILD files at their root. Currently, they add manually the BUILD files every time but we would like to use the tailor command to save us time.
Sorry for the long text but I think this will help the issue to have more context on our current state.
To answer your question: When I remove completely the
filesand thedocker_imagefrom my BUILD file, the tailor and everything else continue to work correctly. Since I only need those on thepackagegoal if there is a possibility to ignore them for everything else and only add on thepackagecommand (using something like environment or tags) this would be great.For this:
if there is no need to have the files dependencies target and this will make pants to see all the new Python files unowned correctly so tailor can create the BUILD file, yes this would be perfect and this would clear all my project directory BUILD files clean.
Just tested on the pants-issue Repo with the following
and tailor only added a new
python_sources()insrc/services/project/BUILDand nothing insrc/services/project/package/not_workingAm I missing something ? (running
./pants tailor ::)Sorry for the late reply, I will test that ASAP and update the issue if this solve our needs