Hi Again everyone :slightly_smiling_face: I have a...
# general
e
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
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
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
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
@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
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
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
The setup.py file is missing, I could create a dumb one, but I would like to have the one generated by pants
e
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
Thanks for your help 🙂