-
Notifications
You must be signed in to change notification settings - Fork 17
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
respect pyproject.toml #16
Comments
Can you reliably find all the |
+1 for this, I also think as a longterm goal this would feel much more in-line with best practices to be able to specify this info there. Although @Roger-luo I think the syntax should be modified (see below) @cjdoris the the role of pyproject.toml is just as a build configuration file, so it actually does not included in the installed package. So it would require a bit of additional config; see below. (While it is the "correct" option, I guess I'm also not sure the extra effort is worth it though...) I think what would make sense is to have something like what [build-system]
requires = ["setuptools", "juliapkg_setup"]
build-backend = "setuptools.build_meta"
[project]
name = "myproject"
version = "0.1.0"
dependencies = [
"juliapkg",
"juliacall",
# other python dependencies
]
[tool.juliapkg]
julia_requires = "~1.6.7, ~1.7, ~1.8, ~1.9, =1.10.0, ^1.10.3"
load_file = "src/julia_deps.py" # Is generated during the build step
[tool.juliapkg.packages]
SymbolicRegression = { uuid = "8254be44-1295-4e6a-a16d-46603ac705cb", version = "=0.24.4" }
Serialization = { uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b", version = "1" } which would generate import juliapkg
juliapkg.require_julia("~1.6.7, ~1.7, ~1.8, ~1.9, =1.10.0, ^1.10.3")
juliapkg.add("SymbolicRegression", "8254be44-1295-4e6a-a16d-46603ac705cb", version="=0.24.4")
juliapkg.add("Serialization", "9e88b42a-f829-5b0c-bbe9-9e923198166b", version="1") Then, the package developer would add the following to the top of their import .julia_deps
... This is the same way that version information is usually passed from # This file is created by setuptools_scm during the build process:
from .version import __version__ I think we could do something similar for pyjuliapkg, since we would want to transfer build information from the pyproject.toml to the Python runtime. |
This is a neat idea. I've wondered about doing the analogue over in CondaPkg too - namely putting the dependencies into Project.toml instead of CondaPkg.toml. The situation is easier there because CondaPkg.toml is automatically gets bundled into the package it's in. Instead of generating a Feel free to develop this (it would be a new package, which is convenient) - but it's not a thing I'll have time to work on. |
One potential down-side - would it tie you into using a particular build system? There are quite a few Python build systems nowadays and I wouldn't want to force people into using only one. Taking |
Good points. Actually after reading more about it, while my suggestion was technically the "best practices" way of doing it, it just makes it so so so much more complicated for both us and the users. I think the better option is to simply package
Then we could just have |
Thinking about this more, I do wonder if the Julia installation should happen during This is also how Cython packages get built — they compile during the |
I personally think adding Julia at pip install would be a beneficial change. Its the exact same amount of time in total, but waiting a while for a pip install feels a lot more normal than waiting for an import call to finish installing Julia. |
@cjdoris the Rust integration tool for Python Maturin also does something like this: https://www.maturin.rs/
with the build backend specified in the pyproject.toml:
|
I don't think having Julia packages install at pip-install time is going to be possible, given it needs to happen knowing all the dependencies of all python packages in your environment. I think this would require custom behaviour in the python package manager. Doing the install at run time avoids this because we know all the packages are already installed. |
As for putting the info into pyproject.toml, it's a nice idea, but we need a mechanism for that info to be put into the package when it is built - pyproject.toml itself is not bundled in a python package. Ideally this would construct a juliapkg.toml file in the right place. I don't know how to achieve this. If it requires a custom build backend I think that's a non-starter. Maybe we can write plugins for existing build backends. |
Hm, is this actually an issue? I can add and remove packages from Julia environments, so wouldn't installing a new package be equivalent to Then if someone chooses to manually tweak the environment via I think something like maturin is a nice model for us: https://github.com/PyO3/maturin.
(Since juliaup is rust-based, we could even look at depending on maturin to pull this off...) |
Sorry I don't follow. If I do Maturin is a build backend isn't it? What exactly are you proposing to do with it? (Apologies if I'm being slow.) |
Sorry, what I meant was, we could have something like
[build-system]
requires = ["setuptools", "setuptools-rust"]
build-backend = "setuptools.build_meta" and then is used within from setuptools import setup
from setuptools_rust import Binding, RustExtension
setup(
name="hello-rust",
version="1.0",
rust_extensions=[RustExtension("hello_rust.hello_rust", binding=Binding.PyO3)],
packages=["hello_rust"],
zip_safe=False,
) The Julia version of this, would, upon import in So we could have: [build-system]
requires = ["setuptools", "juliapkg"]
build-backend = "setuptools.build_meta" and then something like the following within my from setuptools import setup
import juliapkg
setup(
julia_env=[juliapkg.fetch_environment()]
) # Would call juliapkg.resolve() And this could read from Since |
Ok thanks, I understand you now. I think this approach to try and install Julia at pip-install time would only work with a source distribution of the package, not a wheel, because hooks like this can only run at build time. A wheel (which is the preferred way to distribute python packages) can't run arbitrary code at install time AFAIU. Another issue is that I think this would end up doing None of this totally blocks the idea, but preventing package authors from distributing wheels doesn't seem nice. However we could put aside the idea of installing Julia dependencies at pip-install time. Instead I do think we can use this mechanism to read deps from the I haven't looked at setuptools, but in hatchling (another build backend) it looks quite easy to write a plugin which does this: https://hatch.pypa.io/1.9/plugins/build-hook/reference/. Could start there and extend to other backends. |
Please take a look at #35 which is a stepping-stone towards this. |
I'm wondering if we can instead of creating a
juliapkg.json
, but putting a field insidepyproject.toml
likethis would making packaging a lot easier because
pyproject.toml
will be saved in a package wheel.The text was updated successfully, but these errors were encountered: