-
Notifications
You must be signed in to change notification settings - Fork 139
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 generate setup.py by default. #462
Conversation
This seems to be causing problems as there still aren't alternatives to I was trying to package a python package without a |
The generic answer is the build package, which should be able to invoke the build backend for any Python project, based on the information specified in its Python packaging is also moving towards separate build & install stages, with the wheel package format as the boundary between them, so |
So to clarify we're not trying to build a package like a
Hmm, I wonder why it's unclear how to do this when it used to be straight forward with distutils/setuptools. Wheel is used for distributing pre-built packages on sites like pypi which is not what we're trying to do. We're just trying to do the compile/build stage from the existing sdist which comes before the install, this would be the stage say where any c extensions would get built but before the package is installed into the target
Well we're not trying to use wheels at all so I'm not sure that would be right, we're basically trying to do a standard in tree build of the sdist in preparation for install, we're only trying to do a build, we're not trying to create artifacts for distribution outside of buildroot.
Hmm, it's unclear what we should actually be calling, and pip doesn't seem to provide a build(without packaging) option either from what I can tell, we've always had to directly invoke it from distutils/setuptools in the past. We don't even support pip for builds due to it not being cross compilation friendly last I checked. |
The scheme Python packaging has been working towards for the last few years is to use the wheel as the standard interface between the build step and the install step. So whatever build system the project uses - such as Flit - produces a wheel with the interface in PEP 517, and that defines what is to be installed. I.e. the wheel is the concrete representation of the stage you describe after building C extensions etc. but before the package is installed. The wheel represents all the files that should be installed, without the build tool having to know anything about the install location(s). |
So I guess it's expected that distros round trip the stdists through wheels for all package builds I guess? I did come across this which seems similar to how we normally do builds.
Hmm, I thought using wheels caused issues with cross compilation unless they are pure python(and even then I think pip didn't play nice in general with cross compilation), although things may have changed. I guess I probably need to wait for the installer cli interface though, any idea if installer has been tested in cross compilation scenarios? Historically we've had to hack up the internals to get python's build systems to place nice with cross compilation in general as cross compilation seems to not get a lot of testing in that area from most python packaging related projects. |
That's the idea, yes. 🙂
I think that's a red herring. 'Editable' installs are meant for development: instead of installing the package files, you install a little shim which adds the source location to the import path, so you can change the source and use it without having to reinstall it. As part of that, it can do an in-place build if there's anything that needs building. It's possible you could figure out some way to use that for downstream packaging, but it's quite different from the intended use case, so you'd be swimming against the stream. The
Pure Python wheels, where the filename ends like
The install is the easy bit - the wheels already contain the compiled libraries for a specific platform, and installing is just a matter of unpacking them to the right locations (plus generating some script wrappers and fiddling with a bit of metadata). Any complexity involved in cross-compilation is on the build side, to get the wheel. |
Seems a bit odd to me but I suppose it's possible it could work, the how part is just not all that obvious for cross compilation scenarios like this.
Yeah, I don't think those are that big an issue. We just don't use them currently at all since we prefer using sdists.
Yeah, which is an obviously wrong assumption, but it has unfortunately managed to get baked into a lot of python's packaging/build tooling.
Well install is often much less simple with cross-compilation than one would often assume since the install location(site-packages for the target python interpreter) also differs from that used by the running python interpreter(the host python interpreter). There's a good bit of complexity on both sides here I think. By the way would it be possible to provide |
TBF, from a Python packaging point of view, it's not obviously wrong. I'd estimate that ~90-95% of packages on PyPI are pure Python, where we don't have to worry about cross compilation at all. And for the packages that do need compilation, 'build it on the relevant platform' generally works well enough for ~95% of what the people we hear from are interested in. If you're interested in discussing how Python packaging can improve on this, then the Packaging category on the Python Discourse forum is probably the place to do so.
Sure, but so long as you know what the right target directories are, it's just a matter of specifying them in the right place.
I'm sorry about this difficulty, and I've done my best to document how to deal with it: https://flit.readthedocs.io/en/latest/bootstrap.html I hope that one day, there will be a TOML parser in the Python standard library. Until then, it's hard to avoid needing a bit of a manual workaround. There's more discussion about this in #462. I'm afraid I'm not prepared to reintroduce |
Reading that it says flit is itself packed with flit, so wouldn't that mean you just need to set
I don't see how it's hard to avoid, seems setting
This is the only thing that seemed to work without a |
There are several reasons that I don't want to do that. The most obvious & least important is that Next, for the dependency cycle between Finally, I want to have Flit & the ecosystem of newer tools & standards we've developed standing firmly on their own feet, not propped up by setuptools right at the base. The Again, though, if you want to add a Some other resources you might find interesting:
For simple packages like |
I was working on fixing that as well....why not bundle tomli with flit like pip does?
So make migration/bootstrapping as difficult as possible? That seems rather counterproductive....
I don't get this...you want people to migrate but you want it to also be as painful as possible by making even a simple installation super difficult for anyone that has custom distro tooling(by creating recursive dependency issues)? I did manage to hack something together temporarily but it's really not ideal. |
My experience with Linux distros is that the people who care most about this kind of bootstrapping also insist on unbundling dependencies, so bundling makes more work for downstreams, not less. I might revisit that if there are more downstream ecosystems that are fine with bundling... but if I did that, I'd expect pushback from the ecosystems that I know dislike bundling. 🤷
I appreciate that not having a setup.py file makes your life more difficult, but I don't think this is 'as difficult as possible'. I've thought about bootstrapping, written docs, and offered suggestions here. Once more, this is how I would suggest downstreams deal with the tomli <-> flit_core dependency cycle:
I feel like your responses are gradually edging towards irritated grumbling that I won't do what you want, rather than having a productive discussion. I won't lock the thread yet, but please, if you're frustrated about this, go and do something else for a few hours rather than writing a fast, grumpy reply. |
I'd say while this is true for applications it's more often the opposite for build systems(good ones at least), the popular cross-language python based build system meson(used for building apps like systemd on all modern distros) has a very strict rule when it comes to dependencies which I agree with a lot(for python based build tools at least):
Yeah, thanks for the suggestions, I've actually been experimenting a bunch, I'm mostly trying to see if I can find a more maintainable solution for buildroot than that pile of ugly hacks I came up with, ideally something that has a more incremental migration path.
I've made a few attempts at something along these lines but keep getting bogged down in dependency hell fairly quickly.
Sorry, I'm really just trying to bounce ideas around to see what I'm missing and what might be missing on on the pep-517 build system side of things. I'm usually pretty good with build systems in general(I help maintain a lot of packages in buildroot) but none of the approaches I've tried so far appeared to be all that maintainable when it comes to the integration with buildroot(which to be fair is a bit weird when it comes to python stuff). It's not out of the norm for features we need for cross compilation, or features needed due to our distro tooling being a bit weird to be missing entirely from newer build systems(and it's not out of the norm to have features we need missing on older widely used build systems like meson either), sometimes it just takes a good bit of back and forth to find a good maintainable solution(which is what I'm trying to do). |
Autogenerating
setup.py
was a workaround to let pip install from source before PEP 517. pip supports PEP 517 since 19.0 (January 2019). Of course it supports installing wheels since much earlier (2013), and this is the default installation method. So I'm gradually moving towards getting rid of the generatedsetup.py
file.In Flit 3.4 (2021-10-10), I added a message saying that the default would change, and adding a (no-op)
--setup-py
option. This PR will make--no-setup-py
the default behaviour, and update the message accordingly.I haven't decided when to merge this yet. The
flit
command line tool is meant as a developer tool, so I think it's reasonable to do changes like this relatively quickly (unlike in the lower-levelflit_core
package). But the purpose of adding the message in 3.4 is to give people a chance to be aware of the change coming and react to it.