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
Proper package_data management #196
Conversation
|
Yeah, so this is what I was trying to avoid until we can drop support for the master branch. I initially started with package_resources until I realized that it wasn't going to behave properly until the files are moved. I don't want to move any more files than I have to until we're no longer trying to keep the branches in sync. As a compromise, what if we made setup.py copy the files into the package before setup() so that we can convince it to put them in the right place (in the package) for just the sdist target? |
| version=CHIRP_VERSION, | ||
| url='https://chirp.danplanet.com', | ||
| python_requires=">=3.3,<4", | ||
| install_required=['wxPython', 'serial', 'six', 'future'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may have been a helpful typo. The reason the test jobs are failing with missing attrdict3 is a known problem with wxPython on Linux only:
That's why I have the version pins in requirements.txt. My understanding is that you're not supposed to specify versions in install_requires, and only use package names. However, issues like this show how that will never work.
But, even without that problem, it will make us try to compile wxwidgets itself during test environment setup on linux, which would be supremely unfortunate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wxPython issue applies to all Unix-like systems (including FreeBSD that I'm using) that did not apply wxWidgets/Phoenix#2224. Versions can absolutely be specified in install_requires, but proceed with caution from a practical point of view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I know it's possible. I'm referring to this recommendation against it:
It is not considered best practice to use install_requires to pin dependencies to specific versions, or to specify sub-dependencies (i.e. dependencies of your dependencies). This is overly-restrictive, and prevents the user from gaining the benefit of dependency upgrades.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, even without that problem, it will make us try to compile wxwidgets itself during test environment setup on linux, which would be supremely unfortunate.
The current wxPython versions, ie those not available in the Ubuntu 22.04 LTS Jammy repositories, require wxGTK 3.2, also not available in the repositories. Later versions are only available in Focal. That's the supreme unfortunate part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean...I have this running locally on jammy (and focal) using distro packages for wxpython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jammy (and even Kinetic) only has wxPython 4.0.7, which uses wxWidgets/wxGTK 3.0. wxPython 4.1 uses wx 3.1 (which became 3.2); wxPython 4.2 uses wx 3.2. wxWidgets releases are not API/ABI compatible between one another.
|
Both |
8e11369
to
3482454
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess using extras to separate wxpython is reasonable, although it's a bit of an abuse of the "optional functionality" intent.
99% of chirp users consume the bundled builds, and this will break that, so I'll have to spend some time making changes to that stuff and testing it against this.
In the meantime, can you please squash this down to just commits that make logical changes? I'm not a fan of the github-inspired practice of dumping 21 "maybe this will work" commits into the history :) If you're unwilling, I'll do it for you, but I'd appreciate it if you could do it.
I think this is probably two logical changes: 1. Moving the files and 2. changing the requirements stuff.
| in importlib_resources.files('chirp.stock_configs').iterdir() | ||
| if conf.is_file() | ||
| ] | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hate black formatting. I just wanted you to know :)
| version=CHIRP_VERSION, | ||
| url='https://chirp.danplanet.com', | ||
| python_requires=">=3.3,<4", | ||
| install_required=['wxPython', 'serial', 'six', 'future'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean...I have this running locally on jammy (and focal) using distro packages for wxpython.
| @@ -31,7 +32,6 @@ commands = | |||
|
|
|||
| [testenv:style] | |||
| basepython = python3 | |||
| sitepackages = False | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this? I suspect that we can flip sitepackages=False at the top right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was to allow the test to use the Ubuntu-provided wxPython, which would not be in the tox-created virtualenv otherwise.
| entry_points={ | ||
| 'console_scripts': ["chirp=chirp.wxui:chirpmain"], | ||
| }, | ||
| scripts=['chirpw'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed, and the chirpw from manifest. It "works" in that it loads from time to time but things break, I don't want to support it, and plan to remove it from the tree, again, once we're no longer keeping the py2 and py3 branches in sync. Last I checked it didn't even start due to changes sync'd from master. It confuses people having both and I want to avoid that. That also means the gtk extras target can go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using that since the last commit in the py3 branch in mercurial with only Python syntax changes, using PyGObject3. Even under that (and GTK 3), it is significantly lighter than and has working multi-select and copy-paste functionality compared to the wxPython interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's massively slower in my experience, I'm shocked that you find it faster. There's been over a year of development on the wx ui since the last commit on the mercurial branch. There are still some gaps, but I'm working to close them. If you find any not on the list I sent to the mailing list, feel free to bring them up.
On Windows and macos, wx provides a far superior experience for people (and native widgets), which again, represent 99% of the users :)
|
Squashing is going to happen eventually, all the separate commits were only for kicking CI and having revert points. |
Excellent, thanks, I wasn't sure. |
eac62d9
to
93b085e
Compare
|
FYI, I'm sorting the locale stuff before getting into this, since that's important (for users) and this is cleanup, but will start on build testing with this soon. But I'm wondering: do you not want to just go forward with |
|
PEP-517 compliance is a much bigger beast than just updating |
93b085e
to
07a57a2
Compare
Yeah, I don't care about PEP-517 I just thought maybe it made sense as setup.py is (for the py3 branch) only used for sdist and that maybe it made sense. This definitely breaks the packaging stuff, but I'm still working through it and am hopeful I'll be able to get it to work. I just rebased this, included locale in the move, |
7351d2a
to
928932c
Compare
|
@vishwin Okay, I have the bundled builds working with this with the changes I've pushed up here. It's very laborious (windows is slow) to validate, so I'm hoping you're okay with the changes I've made here. Please confirm. This also doesn't include If you can confirm this looks okay to you I can merge and get another build generated for the end of the week here. The sdist locale issue probably need not hold us up. |
@vishwin ? |
Data files outside the package are not installed in binary distributions, so move them inside. Use importlib_resources to load icon and stock configs. - use only the newer files(), as_files() and namespace APIs introduced in Python 3.10 - use the importlib_resources package if Python < 3.10 - remove obviated pkg_path() - bump minimum Python version to 3.7 Fix test paths to account for the move
YesNoDialog does not have set_alternative_button_order
setup.py was intentionally typoed to not specify dependencies, but breaks metadata.
wxPython is unnecessary for the automated test suite. Additionally, the GTK interface still works under PyGObject in GTK 3, so re-expose that.
This is required if we're generating a bundled app that uses an executable name that is different than what we want to show up. Specifically for macos, but might apply elsewhere.
928932c
to
3f001f9
Compare
|
Okay, well, I did a bunch of work to the build system to accommodate this and have been holding up further builds waiting for confirmation. Without that, I'm just going to have to merge this and hope for the best. Not sure the hassle has been worth it in the long run, but hopefully this doesn't cause more trouble. |
The default_dir() needs to return a string, but #196 made it return a PosixPath. This manifested as new users unable to open files, but established users could, because last_dir was pulled from the config instead of the platform module.
The default_dir() needs to return a string, but #196 made it return a PosixPath. This manifested as new users unable to open files, but established users could, because last_dir was pulled from the config instead of the platform module.
Turns out
data_fileswas deprecated; PyPA et al recommend that data files be included in the package(s) themselves, in this case, underchirp. Usingimportlib_resourcesallows obviatingpkg_path()and other hacks about included data files, as they are now fully guaranteed to be present (even in the extremely unlikely load-from-ZIP-file scenario).(This may be a precursor to full PEP-517 compliance later on)