Skip to content

Fix astropy so that it can be used in app bundles, and add CI to prevent regression#8795

Merged
astrofrog merged 6 commits intoastropy:masterfrom
astrofrog:fix-app-bundles
May 14, 2020
Merged

Fix astropy so that it can be used in app bundles, and add CI to prevent regression#8795
astrofrog merged 6 commits intoastropy:masterfrom
astrofrog:fix-app-bundles

Conversation

@astrofrog
Copy link
Member

@astrofrog astrofrog commented Jun 4, 2019

With applications like pyinstaller, it's easy to build application bundles for different platforms. Unfortunately, astropy doesn't work out of the box with these and requires some tweaking due to various issues. In the past, @embray actually opened a PR to fix this (#960) but this was never finished.

Since it would be nice for this to work cleanly, I've decided to start off by adding a CircleCI job that will test that this works correctly and that we don't regress in future. I'll then work on fixing issues, and will see if I can cherry pick or adapt any of the solutions from #960. So this is just a WIP for now.

UPDATE: this is now ready, see #8795 (comment)

EDIT: Fix #7052

@astrofrog
Copy link
Member Author

Some of the fixes will much easier to do by adding a hook-astropy.py into PyInstaller, so I'll work on that.

@bsipocz
Copy link
Member

bsipocz commented Oct 27, 2019

@astrofrog - I'm bumping the milestone to the next bugfix, to help us see how we stand. Of course if any from there is ready before the release, they can be moved back to 4.0.

@astrofrog
Copy link
Member Author

Sounds good, I definitely won't have time to finish this for 4.0.

@astrofrog astrofrog force-pushed the fix-app-bundles branch 2 times, most recently from d303bc6 to d6c1840 Compare January 21, 2020 14:46
@bsipocz
Copy link
Member

bsipocz commented Feb 26, 2020

is this still something on the table post APE17?

@bsipocz bsipocz modified the milestones: v4.0.1, v4.1 Feb 26, 2020
@astrofrog
Copy link
Member Author

Yes this would still be nice to get working, I just haven't had time

@bsipocz
Copy link
Member

bsipocz commented Feb 26, 2020

no worries, I just remilestoned it then. We can always move it back to the bugfix milestone when it's merged.

@mhvk mhvk removed this from the v4.1 milestone May 3, 2020
@mhvk
Copy link
Contributor

mhvk commented May 3, 2020

Not release-critical, so removing milestone.

@astrofrog astrofrog changed the title WIP: Fix astropy so that it can be used in app bundles, and add CI to prevent regression Fix astropy so that it can be used in app bundles, and add CI to prevent regression May 4, 2020
astrofrog added 4 commits May 4, 2020 16:43
… can be used properly when bundled in a pyinstaller application.

This also fixes relative imports that are not to same directory and should therefore be absolute imports. This fix was done because the helper script copies the astropy tests to a separate directory as they cannot be run from the application bundle.
@astrofrog
Copy link
Member Author

This is now ready for review - all required fixes to make astropy work properly in bundles were done in separate PRs over the last year or so, this now just add a tox environment and associated Travis cron job to make sure that we don't break this capability. The Travis job is 7 minutes in total, so not a huge overhead, and I've only enabled it as a cron job to avoid slowing down any PRs. I had a temporary commit here to make sure it ran correctly, but have now removed the commit so the job won't show up here (and CI should therefore pass anyway).

A side bonus is that this makes sure that the tests are able to be extracted as-is and run against an installed version of astropy (this was needed since pytest cannot discover tests in application bundles) - normally this should work, but there were a few relative imports that have crept in since we switched to absolute imports. Relative imports to the same directory are fine, but this fixes ones where the relative import went one or more levels up (which shouldn't be there).

In any case, this is now ready for review and can be backported to 4.0.x.

@astrofrog astrofrog added this to the v4.0.2 milestone May 4, 2020
@astrofrog
Copy link
Member Author

I think with this merged we can close #7052

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks nice - I like that it also tests that relative imports do not return. One tiny comment (I'll leave approval to someone who understands the pyinstaller scheme better)

Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on success reported in #7052 (comment) (oh, wait, maybe the success is not related to this PR but still...) and @mhvk 's favorable review, I don't see any reason to hold this off any longer. Glancing at the code did not reveal anything shocking but I am not familiar with how Pyinstaller works, so I am approving but leaving it for another to merge.

Thanks!

@astrofrog
Copy link
Member Author

The success over in #7052 is due to fixes that were done in other PRs in the process of doing this one - this current PR essentially just adds the regression test 😄

@astrofrog
Copy link
Member Author

Since this has been approved, I'll go ahead and merge so that it doesn't go stale 😄

@astrofrog astrofrog merged commit d5b3dfd into astropy:master May 14, 2020
astrofrog added a commit that referenced this pull request May 19, 2020
Fix astropy so that it can be used in app bundles, and add CI to prevent regression
astrofrog added a commit that referenced this pull request May 19, 2020
Fix astropy so that it can be used in app bundles, and add CI to prevent regression
astrofrog added a commit that referenced this pull request May 19, 2020
Fix astropy so that it can be used in app bundles, and add CI to prevent regression
astrofrog added a commit that referenced this pull request May 19, 2020
Fix astropy so that it can be used in app bundles, and add CI to prevent regression
@embray
Copy link
Member

embray commented Sep 5, 2020

Wow, my first attempt to solve this was 7 years ago now. Amazing to see this finally done :)

@astrofrog
Copy link
Member Author

@embray thank you for starting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error building executable using pyinstaller

5 participants