enough-postman-51783
10/16/2020, 5:32 PMSome example plugins that users have written:
Custom setup.py logic to compute the version dynamically
It can help me a lot. Does maybe someone have this plugin with setup.py and could share? I will be grateful. Thank You in advance.hundreds-father-404
10/16/2020, 5:35 PMversion
from a VERSION
file. I believe @narrow-activity-17405 wrote a plugin that behaves similarly.
@full-oyster-41619 wrote a plugin that runs Git, but it uses lots of Git utilities they already had, so I’m not sure how shareable it would be.
--
What are you hoping to achieve with your plugin?enough-postman-51783
10/16/2020, 5:53 PMversion
in setup.py in every package from some package file like __init__.py
defined on package level. The same with long_description
for example from README.rst
. I've just started with Pants I read almost all docs here. This solution contains global README
not individual for each package. I will try maybe I will handle it and create something. Thanks :)enough-postman-51783
10/16/2020, 5:55 PMpython_requirements()
.enough-postman-51783
10/16/2020, 5:57 PMhundreds-father-404
10/16/2020, 5:58 PMtarget_type
to be able to locate which README and __init__.py
to use.
For example, you could look at the “address” for the python_distribution
target and compute the files to read from there.
Do you know what assumptions you’d be able to make for where those two files will live for each distinct python_distribution
you have? For example:
Thevswill always in the same directory of the `python_distribution`’s BUILD fileREADME
I have two top-level READMEs in my organization, and each project decides which of the two they wantI’m trying to figure out the best way to model what you’re after in your plugin.
enough-postman-51783
10/16/2020, 6:06 PMtarget_type
can help me. I think I will have README
always with python_distibution
. I will try and play a little with Pants. It will be always a good challenge 🙂hundreds-father-404
10/16/2020, 6:11 PMI think I will have README always with python_distibutionCool, so you can use
request.target.address.spec_path
in your @rule
to dynamically get the parent directory of your BUILD
file.
Then, use await Get(DigestContents, PathGlobs([os.path.join(parent_dir, "README.rst"])
to use the engine to read the README.rst file from the file system.
I recommend taking this approach:
1. Implement the example in that guide that simply hardcodes a kwarg. Get that working, so that you know all your register.py
setup and everything is working.
2. Add the logic to set long_description
from a README
.
3. Figure out what semantics you want for setting the version
, e.g. reading from __init__.py
vs. VERSION
Treat each step as a distinct milestone. It can get confusing if you try to do everything all at once.hundreds-father-404
10/16/2020, 6:14 PMIt will be always a good challenge 🙂That being said, please do not hesitate to ask for help! The plugin docs are only in their first iteration. We know from a couple other plugin authors that we want to do a rewrite of them to be more helpful. It’s totally okay if things don’t make sense right away. These concepts can be hard to make sense of at first, and we know we can do a better job explaining them. No need to suffer trying to figure something out - we’re happy to help 🙂
enough-postman-51783
10/16/2020, 6:17 PMawait Get
but I have problem with parent directory. This ``request.target.address.spec_path`` should definitely help me 🙂 Thanks for help one more time! 🙂hundreds-father-404
10/16/2020, 6:18 PMenough-postman-51783
10/16/2020, 6:29 PMfull-oyster-41619
10/20/2020, 1:46 PM