Good afternoon :wave: , I just spent around two ho...
# general
s
Good afternoon πŸ‘‹ , I just spent around two hours on the Incremental Adoption page and the surrounding documentation trying to get an initial setup of pants for our mono-repo. I have some questions, I hope this is the correct channel to ask: Initially we’re driving the following structure:
Copy code
src/ - This is the django root folder
  api/
  core/
  another_module1/
  another_module2/
  setup_core.py - This is building a core-package we upload and use in apps/project-z
  manage.py
  ... etc

apps/
  project-x/ - TypeScript Project
  project-y/ - JavaScript Project
  project-z/ - Python Project
As I’m trying to get Pants setup only for the
src
directory. I configured
root_patterns
to only contain
'/src'
. I’m still wondering about the perfect configuration but this was my starting-point. My findings: 1.
./pants tailor
does not seem to respect
[source].root_patterns
. When I run
tailor
it prompts me with a `NoSourceRootError: No source root found for `apps/heka/manage.py`` . Why is that exactly? 2. Removing the
root_patterns
configuration
./pants tailor
runs successfully but quits with this warning: `164908.52 [INFO] Filesystem changed during run: retrying
TailorGoal
in 500ms...` . Since I did not change anything, but pants did, is it possible it is tripping over its own changes here? 3. Playing around with the setup for
fmt
and
lint
, I figured that pants trips over requirements that come from github, i.e. we are using a library
de_core_news_md
which is pulled by spaCy and cached by our CI using this url:
<https://github.com/explosion/spacy-models/releases/download/de_core_news_md-3.1.0/de_core_news_md-3.1.0.tar.gz#egg=de_core_news_md==3.1.0>
. After running
./pants tailor
every following command halts immediately with the following error:
Copy code
16:53:31.83 [ERROR] 1 Exception encountered:

  MappingError: Failed to parse ./apps/prometheus/BUILD:
Invalid requirement '<https://github.com/explosion/spacy-models/releases/download/de_core_news_md-3.1.0/de_core_news_md-3.1.0.tar.gz#egg=de_core_news_md==3.1.0>' in apps/prometheus/requirements.txt at line 37: Parse error at "'://githu'": Expected stringEnd
Maybe someone can give me a hint in the right direction for incremental adoption, any help is appreciated πŸ™‚.
h
Hi! Happy to help. Sorry for the confusion here: Source roots are not for restricting where Pants operates. They are for figuring out where the roots of the package hierarchy are (e.g., if your code under
src/foo/bar
is imported using
import foo.bar
then
src/
is a source root, but if it's imported using
import bar
then
src/foo
is a source root). So
tailor
is saying: "you asked me to operate on this source file, but it's not under any source root, so I don't know how to treat it". If you want to set up Pants to ignore part of your repo, you use the
pants_ignore
global option: https://www.pantsbuild.org/docs/reference-global#section-pants-ignore
So you can set that to ignore
apps/
for example
And re the github requirements, you might need to rewrite those to be PEP-440 compliant: https://www.pantsbuild.org/docs/python-third-party-dependencies#version-control-and-local-requirements
πŸ™Œ 1
s
Thank you for taking the time! I will try some more πŸ™Œ
Just a small thought that came while doing laundry: Maybe ignoring parts of the repository could be mentioned in some way in the Incremental adoption page?
e
@strong-toothbrush-37759 that sounds like a good idea. Do you want to take a crack at it while the experience is fresh? There is a suggest edits in the upper right hand corner you can use to send an edit up for review.
πŸ™Œ 2
πŸ‘Œ 1
s
Done βœ…
e
Excellent. Thank you. I applied that to 2.10 and 2.11 as well.
πŸ™Œ 1
b
Thank you for that contribution! This is a classic example of what @hundreds-father-404 and @rapid-bird-79300 were talking about this week on the Humans of Devops episode about the Curse of Knowledge and Beginniners Mind. Perfect.
πŸ‘Œ 2