-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add pyproject.toml and poetry.lock #20
base: master
Are you sure you want to change the base?
Conversation
Added poetry-friendly compilation/installation of C-Jigsaw using a poetry run command (in lieu of the compilation found in setup.py). To invoke the compilation/installation of C-Jigsaw into jigsaw-python source installation, you can do:
|
The full workflow (assuming you have poetry installed): git clone https://github.com/dengwirda/jigsaw-python.git # currently should clone this branch for this to work |
In principle, this should be able to reproduce the functionality of the current setup.py into a poetry environment.
Squashed changes into a single commit. |
It is worth nothing that with this method, the wheels include the compiled _lib and _bin, which means that now you can publish these compiled binaries to PyPi along with jigsawpy and it won't require a separate installation. To create the wheels, just do |
Just getting back to this at the end of the year @jreniel --- thanks for putting this interface to
|
Hi @dengwirda, those are very good questions. Let's see if I can address them thoroughly.
Committing a poetry.lock file is recommended, although not strictly necessary. What it does is provide a working deterministic build. However, that doesn't mean this is the only way to build. I'd say lock files are more of a strong suggestion for the compiler, but doesn't mean that whatever is in there is the only way to build. It only tells the compiler which version did work at some point.
It's not a strict lock, it's more like a strong suggestion for the compiler for a build that did work, but you can build with other versions too.
Well, it doesn't always compile with arbitrary versions, been testing this a lot, and I can provide more comments on this later. In fact, if you do test poetry, you'll notice what I'm talking about, but let's build up the knowledge about poetry first and let the system itself guide us. If you look at the pyprojet.toml I put:
This is a rather complex question. setup.py is getting deprecated for real in favor of pyproject.toml (this is extremely similar to how Rust works). But poetry is not the only build system that exists. Poetry is the new de-facto default so to speak (for most cases, at least). But if you are build Rust-Python binding for example, you wouldn't use poetry as backend, you would use maturin as backend, but it would still use pyproject.toml. The idea is that setup.py is deprecated officially based on PEP518, and pyproject.toml can provide deterministic builds based on many different build backends of your choosing (poetry being, as mentioned the de-facto standard in most cases).
Not 100% sure what you mean by this, but, give me a few days and I'll provide more guidance on how to test poetry. What I can tell you is the following, look at almost every Python package that is up to date and almost every package has switched to poetry (where applicable). Poetry still uses pip in the backend, but poetry is deterministic, while setup.py is considered a lot more ad-hoc. Unfortunately, setup.py based builds do not play well with poetry based builds, and that's why I've been using my own forks on my builds. Give me some time and I can put together more examples on how to test, in the meantime, I would suggest you look into poetry and test the branches I've put together, particularly with poetry build, e.g. poetry shell One thing that poetry does a lot better than setup.py is build the wheels. Poetry will include the binaries. In my case I had to make this fork and implement the change because my own build are poetry based and jigsapy/inpoly were not compiling correctly without a proper pyproject.toml. Now every works seamlessly, and everything gets compiled in the background when I do |
Also worth mentioning, this doesn't force you to have poetry installed or directly use poetry. I think it works just the same if you clone it and do |
[build-system] The snippet above is an example of a project that uses setup.py and pyproject.toml ... I've learned more about this topic since I opened this PR, and one thing that perhaps I should (self) clarify is that, it's not that setup.py is getting deprecated, it's more that pip is now more pyproject.toml driven, and setup.py or build.py play a supporting, rather than a primary role. |
Thanks for your thoughts on this @jreniel, I appreciate it! |
Hi @dengwirda, I'll try to make room to modify this into a setuptools based and potentially with a poetry entry as well, so that it can play well with as many users as possible. But if you happen to have someone that beats me to the punch on this, feel free to close this and merge the other one! I won't feel left out or offended. |
Thanks @jreniel no worries at all --- I'll have a look at supporting a minimal |
The current setup.py in jigsaw-python uses the module
packaging
without declaring it as a dependency.This breaks installation of jigsaw-python using poetry.
The introduction of a pyproject.toml fixes this (PEP 518), allowing installation of jigsaw-python using poetry.