https://pantsbuild.org/ logo
#general
Title
# general
e

echoing-london-29138

02/17/2022, 8:36 AM
Hi Again everyone 🙂 I have a tiny question, I saw that on the previous version of pants there was goal named setup-py which (if I understand correctly) would generate the setup.py file. I understand that this feature is still available behind the scene when I see that the package is automatically created by pants. But, I would like to be able to use ‘pip install -e’ in order to develop my package, and for that I need to have a setup.py file for my package (it is a requirement from pip). Is it possible to write on the my file system the generated setup.py file ? Thanks for your answer 🙂 Arthur
w

wide-midnight-78598

02/17/2022, 1:09 PM
I think doing
pip install -e
might auto-generate a
setup.py
, I guess you want it to match the
setup.py
you already have created in your BUILD targets? Did you want that generated
setup.py
to be continually updated? Or did you just need to emit it once? I think if you create a
python_distribution
and build the sdist (via
./pants package ::
, you'll generate a
.gz
file. If you uncompress that, the generated
setup.py
will be there e.g. From:
Copy code
python_distribution(
    name="hellofib-dist",
    dependencies=[":libhellofib"],
    wheel=True,
    sdist=True,
    provides=setup_py(
        name="hellofib-dist",
        version="0.0.1",
        description="A distribution for the hello fib library.",
    ),
)
In my
/dist/hellofib-dist-0.0.1.tar.gz
, I end up having this `setup.py`:
Copy code
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
# Target: hellofib:hellofib-dist

from setuptools import setup

setup(**{
    'description': 'A distribution for the hello fib library.',
    'install_requires': (
    ),
    'name': 'hellofib-dist',
    'namespace_packages': (
    ),
    'package_data': {
    },
    'packages': (
        'hellofib',
    ),
    'version': '0.0.1',
})
I'm not sure if I'm misunderstanding, or if this is good enough for your purposes?
e

echoing-london-29138

02/17/2022, 1:22 PM
I would like have the setup.py automatically updated. I would like to know if there is a way to avoid the uncompress step, and directly have the setup.py
Also, pip install -e doesn’t autogenerate the setup.py (at least not in my project 😕 )
w

wide-midnight-78598

02/17/2022, 1:32 PM
Hmm, I might be conflating a few things, or I guess maybe there was a do-nothing setup.py in the latest project where I had to do an editable install 🤷‍♂️ Or I created some sort of pip install alias that auto-generated one. Damn, that sounds like something I would do 🤦 Outside of creating a plugin, I haven't seen an option or setting that emits the setup.py on its own, but hopefully one of the maintainers can help out!
🙏 1
e

enough-analyst-54434

02/17/2022, 2:12 PM
@echoing-london-29138 when you say "... use
pip install -e
to develop my package", what does that entail? The
pip install -e
just installs your project's live sources (as well as their third party dependencies) in the current venv. But then what do you do in that venv? I ask because Pants does things differently here. It maintains the venvs. So if you want to test the live sources you
./pants test
,
lint
,
fmt
, etc. If you want to run your live app, there's
./pants run
and if you just want to explore your code in a repl session there is
./pants repl
. If you could explain the parts of your development process not addressed by these goals, that might be the best place to start.
e

echoing-london-29138

02/17/2022, 2:21 PM
The issue here, is that we have a legacy project, which is not managed by pants. And in order to make the integration between the new code into the legacy and move things smoothly and slowly to the pants managed project, we need to be able to integrate the packages in development mode. So we don’t need to reinstall for every change we do
e

enough-analyst-54434

02/17/2022, 2:29 PM
Ok. That then is something Pants doesn't currently support. Let me re-angle the question then in light of your scenario. Why does continuing to use
pip install -e
not work? What's lacking there?
e

echoing-london-29138

02/17/2022, 2:30 PM
The setup.py file is missing, I could create a dumb one, but I would like to have the one generated by pants
e

enough-analyst-54434

02/17/2022, 2:35 PM
I think that's what you need to weigh, is the
pip install -e
workflow more important than
setup.py
generation during the transition period. If so, the sacrifice is to hand maintain the
setup.py
until you're ready to bring that project into the fold of being managed by Pants. Right now you're trying to spilt responsibilities. It would be great if Pants could handle that, but it currently can't.
Basically you'd need a new feature that generated
setup.py
in the workspace alongside your code. Currently the auto-generated
setup.py
is only generated when needed (via the
package
goal or off in a temporary sandbox).
e

echoing-london-29138

02/17/2022, 3:06 PM
Thanks for your help 🙂
2 Views