big-fall-51153
05/25/2021, 12:00 PMGet
not seeming to match on anything? When I try to get DigestContents
, there are no files coming backbig-fall-51153
05/25/2021, 12:02 PMGet(Digest, ...)
are what I'm expecting - e.g. ['.pants.d/tmpciy3o72m/**/module_name/*.py']
big-fall-51153
05/25/2021, 12:03 PMgoal_rule
big-fall-51153
05/25/2021, 12:37 PMbig-fall-51153
05/25/2021, 1:09 PMhundreds-father-404
05/25/2021, 3:56 PMpants_ignore
Are you able to share the use case for wanting to copy files out of the working directory?big-fall-51153
05/25/2021, 4:19 PMrun
(or a variant)big-fall-51153
05/25/2021, 4:20 PMbig-fall-51153
05/25/2021, 4:22 PMhundreds-father-404
05/25/2021, 4:24 PM./pants run
uses a tempdir is to support codegen without mutating the build root
If that isn't a concern for you, you could basically copy and paste run.py
and remove the tmpdir stuff, use a custom goal like django-run
. In your register.py
, add UnionRule(DjangoRunFieldSet, PexBinaryFieldSet)
(see run_pex_binary.py
)big-fall-51153
05/25/2021, 4:27 PMbig-fall-51153
05/25/2021, 4:27 PMhundreds-father-404
05/25/2021, 4:28 PMCan codegen utilize dependencies from my sources?I'm not following what you mean
big-fall-51153
05/25/2021, 4:29 PMbig-fall-51153
05/25/2021, 4:32 PMrun
goal plus some file copying code at the end, so it sounds like you're saying I could just drop the tempdir and do it right in the build root?hundreds-father-404
05/25/2021, 4:33 PM./pants run
loads the PYTHONPATH for you. In run_pex_binary.py
, this is via setting the env var PEX_EXTRA_SYS_PATH
on line 91
With my django-run
custom goal recommendation, Django should still be able to access all your dependencies correctly. The main thing that changes is it doesn't use a tmpdir anymore and any codegen you're using (e.g. Protobuf) will get written to the build root, which is irrelevant if not using Pants's codegenbig-fall-51153
05/25/2021, 4:33 PMhundreds-father-404
05/25/2021, 4:33 PM./pants run
big-fall-51153
05/25/2021, 4:36 PMdjango_app
target with an argument to specify globs that would be synced back to the build root on completion of the run. That way I can support arbitrary writes that applications and libraries may havebig-fall-51153
05/25/2021, 4:36 PMpex_binary
with some extra sugarbig-fall-51153
05/25/2021, 4:37 PMdjango_app(
name="testapp",
entry_point="testapp/manage.py",
dependencies=["tests:testapp-lib"],
mutable_files=[
"**/migrations/*.py",
]
)
happy-kitchen-89482
05/25/2021, 5:48 PM./pants run
for most manage.py
uses, but of course that is not very satisfactory.happy-kitchen-89482
05/25/2021, 5:48 PMrunserver
runs out of a tmpdir copy, so its autoreloader won't workhappy-kitchen-89482
05/25/2021, 5:48 PMhappy-kitchen-89482
05/25/2021, 5:49 PM./pants run
happy-kitchen-89482
05/25/2021, 5:49 PMhappy-kitchen-89482
05/25/2021, 5:50 PMhundreds-father-404
05/25/2021, 5:53 PMbig-fall-51153
05/25/2021, 5:58 PMhundreds-father-404
05/25/2021, 6:02 PMbig-fall-51153
05/25/2021, 6:33 PMbig-fall-51153
05/25/2021, 6:34 PMworkspace.write_digest
to accomplish the copyinghundreds-father-404
05/25/2021, 6:35 PMtmpdir
stuff?
https://pantsbuild.slack.com/archives/C01CQHVDMMW/p1621959890050900?thread_ts=1621944059.047500&cid=C01CQHVDMMWbig-fall-51153
05/25/2021, 6:37 PMλ › ./pants django-run tests:testapp odl/ol-django nl/pants-t2
13:30:47.17 [INFO] initializing scheduler...
13:30:47.43 [INFO] scheduler initialized.
/usr/bin/python3.8: can't open file './testapp.pex': [Errno 2] No such file or directory
hundreds-father-404
05/25/2021, 6:38 PMhundreds-father-404
05/25/2021, 6:44 PM./pants run
no longer uses a tmpdir:
Does Django now do what you want?hundreds-father-404
05/25/2021, 6:44 PMbig-fall-51153
05/25/2021, 6:48 PMdjango-run
goal similarly, it worksbig-fall-51153
05/25/2021, 6:49 PMchroot
big-fall-51153
05/25/2021, 6:50 PMwrite_digest
for RunRequest
, which is probably why it couldn't find the pexhundreds-father-404
05/25/2021, 7:00 PMrequirements.pex
. We cannot rely on Git because the user might have modified Git state before running ./pants run
@happy-kitchen-89482 what do you think about giving up on the chroot and running directly in the build root? It removes a lot of warts
I'm trying to figure out if we can always cleanup, e.g. behavior if you ctrl-c out of programhundreds-father-404
05/25/2021, 7:07 PM./pants
in another shell while ./pants run
is still executing, it will see those new temporary fileshundreds-father-404
05/25/2021, 8:28 PM