Build a proper Python package#755
Merged
bcoconni merged 5 commits intoJSBSim-Team:masterfrom Oct 31, 2022
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #755 +/- ##
=======================================
Coverage 22.48% 22.48%
=======================================
Files 167 167
Lines 19138 19138
=======================================
Hits 4304 4304
Misses 14834 14834 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the structure of our Python module so that:
lib/python3.*/site-packages/jsbsim(while currently the module is installed just below the folderlib/python3.*/site-packages/and the data files are installed in the foldershare/JSBSim).jsbsim(so far they were not installed at all).*.pyican be installed alongside. This last topic is actually what is motivating this PR.There are a couple of design decisions that come with this PR. Below are their descriptions.
A proxy
__init__.pynow loads_jsbsimto mimicimport jsbsimSince the C++ module will now be located under
jsbsim, it will no longer be possible to import it directly with the commandimport jsbsim. That's annoying because it breaks backward compatibility. However that problem has been solved following the example of the package contourpy: the C++ module is renamed_jsbsimand is loaded by the file__init__.pywhich serves as a simple proxy. So when the commandimport jsbsimis issued,__init__.pyis called to load_jsbsim, read its symbols (FGFDMExec, etc.) and return them.As a consequence, the content of
__init__.pyis trivial.The file
_jsbsim.pxdis installedIncidentally, the file
_jsbsim.pxdwill be installed along with the package. This is due to the following constraints:_jsbsim.pxdmust be distributed with the Python source package*.tar.gzso that JSBSim can be built bypipon platforms for which no wheels are available.jsbsim._jsbsim, cython and/or setuptools require that_jsbsim.pxdalso meet that structure and be located in the package i.e. injsbsim/_jsbsim.pxd._jsbsim.pxdwill be installed by our Python wheels even though the file is no longer needed at this stage.The last topic can be addressed by programming
setup.pyto skip the installation of_jsbsim.pxdbut the file is less than 100kb so I guess we can live with it for now.The script
JSBSimhas been renamedJSBSim.pyThis one breaks backward compatibility. It is requested because case insensitive OSes (Windows and MacOSX) cannot manage a script named
JSBSimand a folder namedjsbsimboth located in the same directory.It is most likely feasible to hack
setup.pyto renameJSBSim.pyback toJSBSim(at least during the package installation) but I have not yet investigated that option.