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

Provide a setup.py, as Poetry does not (yet) cover all cases #54

Open
MestreLion opened this issue Dec 20, 2019 · 4 comments
Open

Provide a setup.py, as Poetry does not (yet) cover all cases #54

MestreLion opened this issue Dec 20, 2019 · 4 comments

Comments

@MestreLion
Copy link
Contributor

TL;DR: Poetry does not provide (yet) any way to install a local package (cloned from github) in editable mode (the equivalent of pip install -e .), and pip does not support (yet) editable mode with pyproject.toml. The solution is, for the time being, to provide a setup.py.

Long version:

So here's my use-case: I'm using nbtlib as a dependency in my projects, which themselves might or might not use Poetry. For developing those projects, I can simply run pip3 install --user nbtlib and done, a stable nbtlib is downloaded from PyPI and installed in my ~/.local/lib/python3.x/site-packages and made globally available to any project that might use it. (or install it in each project's virtualenv, same result)

But... I'd also like to contribute to nbtlib. So I clone it's github repo, install Poetry and pytest to run tests before creating PRs. So far so great. Now I want to use this modified version in my projects, so I need to install the local version (not a stable from PyPI). And it must be in editable mode, so any further changes are automatically refletected in my projects.

Poetry? No such feature. It's meant for managing a package's dependencies, not to install or use a package as a dependency. Pip? No luck: it does not support pip install -e . with a pyproject.toml:

01:15:27 rodrigo@desktop ~/work/minecraft/nbtlib master $ pip3 install --user -e .
ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /home/rodrigo/work/minecraft/nbtlib
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)

Poetry is still too immature and lacks a lot of features to cover all use cases of setup.py, pip and etc. And pip is not modern enough to use pyproject.toml for all of its features.

If there's no better solution, I believe nbtlib should provide a setup.py, at least until both tools mature.

@vberlier
Copy link
Owner

vberlier commented Dec 24, 2019

Poetry just reached 1.0 though, I think it's great but I can see why it might still be lacking in a few areas. I kinda like the solution proposed here. I think using poetry's setup.py generator as explained here would be a good idea.

Edit: I haven't looked into it yet but dephell could be interesting as well.

@vberlier vberlier mentioned this issue Nov 2, 2021
9 tasks
@MestreLion
Copy link
Contributor Author

Since this is still open, and you've included in the 2.0 discussion, I believe I should give some 2021 feedback:

Poetry has matured a lot since then. The whole packaging landscape did. I'm finally able to perform a poetry install . and it, by default, install the package in editable mode. I still have to set a flag to override your poetry.toml setting so it installs to my ~/.local site-packages, but at least that's doable now (is that file intended to be on the git repo?) pip install -e . works too, and invokes poetry's builder. So I don't have to use poetry on my project to use a local nbtlib.

I didn't revisit yet all of the many issues I had with it to see of any still holds today, nor I checked if they still had those poor non-XDG choices about default dirs, but the fact it has --editable makes me even consider adopting it. And also the fact that whenever I try to use pyproject.toml with setuptools it is nothing but pain. Even setup.cfg feels worse than a setup.py written using good practices.

Besides you've already created a setup.py shim for other purposes, so if a given tool requires one, it's there.

Given all of that, I think you can close this. Poetry now is able to do what I need

@MestreLion
Copy link
Contributor Author

MestreLion commented Nov 3, 2021

You might, however, consider switching to poetry-core for your build system:

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

The project itself would still be managed by the full-fledged Poetry, but the clients/users would only require the core to build.

@vberlier
Copy link
Owner

vberlier commented Nov 4, 2021

I see, thanks for the feedback on this.

You might, however, consider switching to poetry-core for your build system

Oh right looks like I didn't do it yet for nbtlib.

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