creamy-truck-92790
05/06/2021, 11:40 AMhappy-kitchen-89482
05/06/2021, 2:33 PMcreamy-truck-92790
05/06/2021, 2:51 PMhappy-kitchen-89482
05/06/2021, 4:18 PMhappy-kitchen-89482
05/06/2021, 4:18 PMhappy-kitchen-89482
05/06/2021, 4:18 PMhappy-kitchen-89482
05/06/2021, 4:18 PMhappy-kitchen-89482
05/06/2021, 4:19 PMhappy-kitchen-89482
05/06/2021, 4:19 PMhappy-kitchen-89482
05/06/2021, 4:20 PMhappy-kitchen-89482
05/06/2021, 4:20 PMhappy-kitchen-89482
05/06/2021, 4:20 PMhappy-kitchen-89482
05/06/2021, 5:12 PMsettings.py
.)creamy-truck-92790
05/07/2021, 6:16 AMcreamy-truck-92790
05/07/2021, 6:20 AMhundreds-father-404
05/07/2021, 6:28 AMHow do I integrate the dependencies in my IDE?You can use something like this https://www.pantsbuild.org/docs/python-third-party-dependencies#tip-set-up-a-virtual-environment-optional to generate a virtualenv, then load it same as you're doing now. Or continue to use the venv from Poetry, which works unless you start adding
python_requirement_library
targets inlined in BUILD files (usually no need to)
Note that this 3rd party dependency handling is going to be improved very very soon. I have a design doc out to redesign several things (https://docs.google.com/document/d/1bCYb0UQZx9a-9tAagydCN_z3826QRvz_3aVnXKSNTJw/edit if you're curious)
where to put the settings, where to put the manage.py, do i create a pex_executable out of the project?I wish we had an example repo already and that I understood Django better. But looking at Toolchain's code, we have several distinct Django projects, and each gets its own
manage.py
and settings.py
, e.g. projectA/manage.py
and projectA/settings.py
. Then yeah, a pex_binary
for the mangage.py
like this:
pex_binary(
name="manage",
entry_point="manage.py",
execution_mode="unzip",
)
I can try to dig more what happens from there, and @polite-garden-50641 has more experience. (Benjy too, but sounds like something came up that he might not get to this right away)creamy-truck-92790
05/07/2021, 6:34 AMcreamy-truck-92790
05/07/2021, 6:35 AMpython_requirement_library
right?happy-kitchen-89482
05/07/2021, 6:36 AMhappy-kitchen-89482
05/07/2021, 6:37 AMrequirements.txt
for the entire monorepo (with a BUILD file containing a python_requirements()
macro call that wraps that requirements.txt
file)happy-kitchen-89482
05/07/2021, 6:37 AMhappy-kitchen-89482
05/07/2021, 6:38 AMpython_library()
targets for each package (./pants tailor
will generate these for you).hundreds-father-404
05/07/2021, 6:38 AMIf every library has its own set of dependenciesPants calculates this for you via dependency inference, picked from the universe of requirements knows about from things like your requirements.txt (or soon, from reading pyproject.toml). Run
./pants dependencies --transitive path/to/file.py
for example
we are packaging them to our private Pypi,You can set a custom repository: https://www.pantsbuild.org/docs/python-third-party-dependencies#using-custom-repositories
happy-kitchen-89482
05/07/2021, 6:39 AMpython_distribution()
target which tells Pants how to generate a dist for it that you can publish to your internal PyPI, or to real PyPI.happy-kitchen-89482
05/07/2021, 6:40 AM./pants package
on that python_distribution
Pants will knit together the correct dependencies for you, and inject them into the setup()
call.happy-kitchen-89482
05/07/2021, 6:40 AMhappy-kitchen-89482
05/07/2021, 6:41 AMdist/
and you have to publish them outside of Pants.happy-kitchen-89482
05/07/2021, 6:41 AMcreamy-truck-92790
05/07/2021, 6:42 AMcreamy-truck-92790
05/07/2021, 6:42 AMhappy-kitchen-89482
05/07/2021, 6:42 AM.pex
files, via pex_binary
. But it sounds like you want them to be wheels, so you'd use python_distribution
.creamy-truck-92790
05/07/2021, 6:43 AMhappy-kitchen-89482
05/07/2021, 6:44 AMhappy-kitchen-89482
05/07/2021, 6:44 AMhappy-kitchen-89482
05/07/2021, 6:44 AMcreamy-truck-92790
05/07/2021, 6:45 AMhappy-kitchen-89482
05/07/2021, 6:45 AMhappy-kitchen-89482
05/07/2021, 6:47 AMpython_requirements()
represents the 3rdparty deps. Typically you only need one of those in the entire repo, to wrap your requirements.txt
. You do not put references to the published versions of in-repo code in that requirements.txt. All dependencies between code in the repo are expressed as internal deps.happy-kitchen-89482
05/07/2021, 6:47 AMhappy-kitchen-89482
05/07/2021, 6:47 AMpython_library()
represents internal code, usually one per directoryhappy-kitchen-89482
05/07/2021, 6:47 AMpython_tests()
represents tests, also usually one per directoryhappy-kitchen-89482
05/07/2021, 6:47 AM./pants tailor
will generate these for you, mostly correctly...happy-kitchen-89482
05/07/2021, 6:48 AMhappy-kitchen-89482
05/07/2021, 6:48 AMhappy-kitchen-89482
05/07/2021, 6:48 AMhappy-kitchen-89482
05/07/2021, 6:48 AMhappy-kitchen-89482
05/07/2021, 6:48 AMhappy-kitchen-89482
05/07/2021, 6:48 AMpython_distribution()
targethappy-kitchen-89482
05/07/2021, 6:49 AM./pants package
on that target, under the covers Pants runs setuptools.setup()
on it, like you're probably used to.happy-kitchen-89482
05/07/2021, 6:49 AMhappy-kitchen-89482
05/07/2021, 6:50 AMpython_distribution()
target.happy-kitchen-89482
05/07/2021, 6:50 AMhappy-kitchen-89482
05/07/2021, 6:51 AMpython_library
to the wheel that publishes that codehappy-kitchen-89482
05/07/2021, 6:52 AMhappy-kitchen-89482
05/07/2021, 6:52 AMcreamy-truck-92790
05/07/2021, 6:52 AMhappy-kitchen-89482
05/07/2021, 6:53 AMhappy-kitchen-89482
05/07/2021, 6:53 AMcreamy-truck-92790
05/07/2021, 6:53 AMhundreds-father-404
05/07/2021, 6:54 AM./pants dependencies path/to/file.py
and ./pants dependencies --transitive path/to/file.py
)creamy-truck-92790
05/07/2021, 6:54 AMhappy-kitchen-89482
05/07/2021, 6:54 AMhappy-kitchen-89482
05/07/2021, 6:55 AMpython_requirements()
macro essentially takes your requirements.txt
and turns each req into a target, so if it sees Django>=3.0.0
it turns that into a target called django
in the same directory.creamy-truck-92790
05/07/2021, 6:55 AMhappy-kitchen-89482
05/07/2021, 6:55 AMpython_library
happy-kitchen-89482
05/07/2021, 6:55 AMpython_distribution
is just "how do I publish code", dependency information for some code lives on the python_library
for that code.creamy-truck-92790
05/07/2021, 6:56 AMcreamy-truck-92790
05/07/2021, 6:56 AMhappy-kitchen-89482
05/07/2021, 6:56 AMhappy-kitchen-89482
05/07/2021, 6:57 AMDjango
in your requirements.txt for Pants to be able to infer a dep on it if it sees from django import...
somewhere.creamy-truck-92790
05/07/2021, 6:57 AMcreamy-truck-92790
05/07/2021, 6:57 AMhappy-kitchen-89482
05/07/2021, 6:57 AMpython_library
of the importing codehappy-kitchen-89482
05/07/2021, 6:57 AMcreamy-truck-92790
05/07/2021, 6:57 AMhappy-kitchen-89482
05/07/2021, 6:58 AMhappy-kitchen-89482
05/07/2021, 6:58 AMhappy-kitchen-89482
05/07/2021, 6:59 AMhappy-kitchen-89482
05/07/2021, 6:59 AMcreamy-truck-92790
05/07/2021, 6:59 AMhappy-kitchen-89482
05/07/2021, 6:59 AMcreamy-truck-92790
05/07/2021, 7:00 AMhappy-kitchen-89482
05/07/2021, 7:00 AMcreamy-truck-92790
05/07/2021, 7:00 AMcreamy-truck-92790
05/07/2021, 7:00 AMhappy-kitchen-89482
05/07/2021, 7:00 AMhappy-kitchen-89482
05/07/2021, 7:01 AMhappy-kitchen-89482
05/07/2021, 7:01 AMhappy-kitchen-89482
05/07/2021, 7:01 AMhappy-kitchen-89482
05/07/2021, 7:01 AMcreamy-truck-92790
05/07/2021, 7:01 AMhappy-kitchen-89482
05/07/2021, 7:01 AMhappy-kitchen-89482
05/07/2021, 7:02 AMcreamy-truck-92790
05/07/2021, 7:02 AMhappy-kitchen-89482
05/07/2021, 7:02 AMcreamy-truck-92790
05/07/2021, 7:02 AMhappy-kitchen-89482
05/07/2021, 7:02 AMhappy-kitchen-89482
05/07/2021, 7:02 AMhappy-kitchen-89482
05/07/2021, 7:02 AMhappy-kitchen-89482
05/07/2021, 7:05 AMhappy-kitchen-89482
05/07/2021, 7:05 AMcreamy-truck-92790
05/07/2021, 7:05 AM