Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require setup.py if setup.cfg is present #10

Closed
bilderbuchi opened this issue Aug 4, 2021 · 7 comments
Closed

Don't require setup.py if setup.cfg is present #10

bilderbuchi opened this issue Aug 4, 2021 · 7 comments

Comments

@bilderbuchi
Copy link

bilderbuchi commented Aug 4, 2021

First, let me says that this looks like a great tool to bridge the conda and vanilla python packaging worlds, thank you! 👏

Setuptools/pip does not anymore require a setup.py file (if setup.cfg is present). This is reflected in the documentation, e.g. here.

I noticed that, in contrast, setuptools-conda requires a setup.py file. If no setup.py is present, when setuptools-conda.exe build . runs python.exe setup.py dist_conda, it fails with "[Errno 2] No such file or directory".

If run pip install -e . in the same directory, it completes successfully without issue.

pip install -e .
Obtaining file:///blabla/python_template
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Installing collected packages: demo
  Running setup.py develop for demo
Successfully installed demo-0.1

Do you need a more precise repro procedure, or is this sufficient?

@chrisjbillington
Copy link
Owner

It would be good to support projects without a setup.py. But setuptools-conda is implemented as a distutils command dist_conda, that is called as python setup.py dist_conda. Do you know if there is a way to call custom distutils commands via e.g. pip for projects that lack a setup.py?

Otherwise I'm thinking one approach could be to temporarily create a stub setup.py

@chrisjbillington
Copy link
Owner

I think I was reading some code deep in pip or similar that essentially ran a setup.py stub in a little isolated exec() or runpy call without creating a file on disk. I'll check out what they do, seuptools-conda can probably do the same.

@bilderbuchi
Copy link
Author

You're probably right -- in the log output above you see that pip says "Running setup.py develop for demo", so it probably creates one itself.

@bilderbuchi
Copy link
Author

bilderbuchi commented Aug 5, 2021

Indeed, the code in pip to create a shim file can be found here. That file also contains a number of functions make_setuptools_<command>_args, so maybe something along those lines will also be necessary to define for dist_conda?

@bilderbuchi
Copy link
Author

bilderbuchi commented Aug 5, 2021

Huh, interesting. I just realised that pip install -e . without a setup.py file present only works if a pyproject.toml is present (even if empty), otherwise I get "ERROR: File "setup.py" not found for legacy project". I think this is as it "should" be, see discussion at pypa/pip#9945 (danger: rabbit hole!)

@chrisjbillington
Copy link
Owner

Thanks for the pointer to pip's shim. I went ahead and did something similar, and I'm pretty happy with it. Let me know if there are any issues.

@bilderbuchi
Copy link
Author

Thanks for the quick fix, this works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants