-
Notifications
You must be signed in to change notification settings - Fork 84
Add cibuildwheel support #448
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
Merged
garfieldnate
merged 38 commits into
SoarGroup:development
from
ShadowJonathan:cibuildwheel
May 15, 2024
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
9d6bdcc
add cibuildwheel support
ShadowJonathan db2fd01
minor: fix accidental tuple packing
ShadowJonathan d1b44b4
experimental cibuildwheel config
ShadowJonathan 5c1cd76
fix windows compilation
ShadowJonathan 8b2df9d
fix windows and mac builds
ShadowJonathan 6b64901
rename to soar-sml
ShadowJonathan cac239c
add soar-compat
ShadowJonathan f5a5964
revert build.yml formatting
ShadowJonathan 8019d97
Switch to using a forked version of enscons; move pyproject.toml; ena…
ShadowJonathan 66ed9e1
whoops, wrong directory
ShadowJonathan 5c10ff0
SOAR -> Soar
ShadowJonathan 45f61d2
fix whitespace regression
ShadowJonathan 4fc122d
add readme to Python path
ShadowJonathan d863a3d
add editable builds
ShadowJonathan 3d79784
ensure soarlib gets built when python bindings are targeted
ShadowJonathan 9b0f2bc
add comments, as requested
ShadowJonathan b6c225d
remove unnecessary macos repair-wheel command
ShadowJonathan d600da7
add .dev1 suffix
ShadowJonathan b199a52
Add project details to pyproject.toml
ShadowJonathan 9886abf
up .dev version
ShadowJonathan 93a5783
add some more authors, and add cic under maintainer
ShadowJonathan 8344123
sort author names
ShadowJonathan 5b07898
add extra comments to the build portions of pyproject.toml to explain…
ShadowJonathan ad2e730
move metadata-getting and wheel_tag statements to python packaging se…
ShadowJonathan d4c4bfb
some better wording on the Python/README.md file
ShadowJonathan 0052dae
fix out/ being included in macos wheel files
ShadowJonathan fb60f6a
allow pivoting without extra back-reference
ShadowJonathan d0c6fb5
allow mac builds to downversion their tags correctly
ShadowJonathan f03cca4
add comment about purelib
ShadowJonathan f12ccf8
utilize dynamic versioning
ShadowJonathan 126ea92
mention twine uploading
ShadowJonathan 6a9b68b
separate wheel build jobs; add wheel upload jobs; alter auto-version …
ShadowJonathan 0aad38b
only run development versions on schedule or manually
ShadowJonathan 5d1e6f3
move documentation for packaging into `DEVELOPING.md`
ShadowJonathan b4b8944
add small comment to fetch-depth 0
ShadowJonathan 2824047
add comment about trusted publishing
ShadowJonathan 06daea0
add some more documentation around versioning
ShadowJonathan 05f149b
add comment about versioningit
ShadowJonathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Developing `soar-sml` | ||
|
|
||
| Before installing development releases, it is always recommended to have an updated `pip`: | ||
|
|
||
| ``` | ||
| $ pip install --upgrade pip | ||
| ``` | ||
|
|
||
| ## Instant: Installing from the latest commit | ||
|
|
||
| To install `soar-sml` *directly* from the latest `development` branch commit, without cloning it into a project directory, | ||
| run the following command: | ||
|
|
||
| ``` | ||
| $ pip install "git+https://github.com/SoarGroup/Soar#subdirectory=Core/ClientSMLSWIG/Python" | ||
| ``` | ||
|
|
||
| ## Local: Installing from a project directory | ||
|
|
||
| To make `soar-sml` available for import in python, while actively developing the source code for it, | ||
| the following command is more suitable. | ||
|
|
||
| Assuming `Soar` has been cloned under `soar/`: | ||
| ```bash | ||
| $ pip install -e soar/Core/ClientSMLSWIG/Python | ||
| ``` | ||
|
|
||
| The `-e` stands for "editable", this means pip will have python redirect the "actual" location of the `soar_sml` | ||
| package to be inside this project directory. Specifically, in this case, to the project root directory (`soar/`). | ||
|
|
||
| This command will install a python package directory under the project root (`soar/soar_sml/`), where it copies | ||
| build artifacts into, into a format that python expects. | ||
|
|
||
| During development, other than running the `pip` command again, | ||
| these files can be updated from builds with the `sml_python_dev` target: | ||
|
|
||
| ```bash | ||
| $ scons sml_python_dev | ||
| ``` | ||
|
|
||
| Running the above command, and then re-running your python scripts, | ||
| will automatically incorporate any compiled changes. | ||
|
|
||
| ## Remote: Installing a development version from the package index | ||
|
|
||
| Weekly development versions are uploaded to [`test.pypi.org/p/soar-sml`](https://test.pypi.org/p/soar-sml), | ||
| the latest of which can be installed with the following command: | ||
|
|
||
| ```bash | ||
| $ pip install --pre -i https://test.pypi.org/simple/ soar-sml | ||
| ``` | ||
|
|
||
| ## Packaging | ||
|
|
||
| Versioning is dynamic, and will calculate a version identifier according to the latest git tag. | ||
| - If the latest git tag is the current commit, it will version with that tag. | ||
| - If the latest git tag is from a past commit, it will increment the smallest segment (e.g. `.2` in `9.6.2`) and | ||
| add miscellaneous metadata (such as the commit datetime, the amount of commits since the last tag, and wether the | ||
| workspace repository was "dirty" or not: if there were uncommitted changes.). | ||
|
|
||
| `build.yml` will automatically build wheels for `soar-sml` on every commit, utilizing | ||
| [cibuildwheel](https://cibuildwheel.pypa.io/) to ease the process, and build for many python versions at once. It will | ||
| do a quick test on every build, importing `soar_sml` and running hello world, to ensure that the wheel passes basic | ||
| checks, and "works". | ||
|
|
||
| `build.yml` also contains job definitions to upload to PyPI, the Python Package Index. | ||
|
|
||
| On a GitHub release, a workflow is triggered to build the final version of wheels, and mark them | ||
| **with the version given in the corresponding git tag**. | ||
| (So if the release is named "Version 9.6.2", and the tag is "v9.6.2", then the auto-version script will see "v9.6.2") | ||
| The string `releases/` is also removed from the git tag before parsing. | ||
|
|
||
| *Do not release multiple versions pointing to the same commit*. Git tags do not have ordering compatible | ||
| with the dynamic versioning, and so with the tags `9.6.2-rc2` and `9.6.2` pointing to the same commit, | ||
| it may pick up on the `rc` tag, and version the build with that. | ||
|
|
||
| Development versions are built and uploaded to [`test.pypi.org/p/soar-sml`](https://test.pypi.org/p/soar-sml) weekly. | ||
| These will also upload on manual triggers. | ||
|
|
||
| If needed, uploading to pypi can be done manually using the | ||
| [twine CLI tool](https://twine.readthedocs.io/en/stable/#using-twine). |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # `soar-sml` | ||
|
|
||
| This directory contains the SWIG bindings to Soar's SML interface. | ||
|
|
||
| This project is also published on PyPI as [soar-sml](https://pypi.org/project/soar-sml/), | ||
| for ease of distribution and installation. | ||
|
|
||
| Versions on PyPI will follow Soar's versioning methodology. | ||
|
|
||
| `soar-sml` effectively bundles Soar with its distribution; you can download it, import it into Python, | ||
| and have a fully-working Soar kernel up and running. | ||
|
|
||
| ## Importing | ||
|
|
||
| The soar-sml package can be imported like so: | ||
|
|
||
| ```Python | ||
| import soar_sml | ||
| ``` | ||
|
|
||
| ## `Python_sml_ClientInterface` compatibility | ||
|
|
||
| The raw build artifacts of this SWIG interface exposed these bindings under a `Python_sml_ClientInterface` namespace | ||
| in the past, we've switched to using `soar_sml` to be more in line with python's packaging ideology. However, | ||
| we did not want to break compatibility with all scripts by doing so, and have also published a compatibility shim. | ||
|
|
||
| Under `compat/`, there exists a small project `soar-compat` that re-exports the classes and functions of under a | ||
| `Python_sml_ClientInterface` namespace, effectively making every existing project compatible with the new `soar-sml` | ||
| package. | ||
|
|
||
| This means that code like thus will still continue to work: | ||
|
|
||
| ```Python | ||
| import sys | ||
| sys.path.append('/home/user/SoarSuite/bin') | ||
| import Python_sml_ClientInterface as sml | ||
|
|
||
| k = sml.Kernel.CreateKernelInNewThread() | ||
| a = k.CreateAgent('soar') | ||
| print(a.ExecuteCommandLine('echo hello world')) | ||
| ``` | ||
|
|
||
| In this case, the `sys.path.append` line is redundant (it accomplishes nothing; python already properly imports | ||
| the package), and can be removed. | ||
|
|
||
| This compatibility package is available on PyPI, and can be installed directly like so: | ||
|
|
||
| ```bash | ||
| $ pip install soar-compat --no-deps | ||
| ``` | ||
| (the `--no-deps` flag is added to prevent `soar-sml` being pulled from pypi, as that is a dependency of | ||
| `soar-compat`) | ||
|
|
||
| However, for ease of installation, it can be installed as an ["extra"](https://stackoverflow.com/a/52475030/8700553) | ||
| like so: | ||
|
|
||
| ```bash | ||
| $ pip install "soar-sml[compat]" | ||
| ``` | ||
|
|
||
| Running this above command will make every Soar SML Python script on your system (or virtual environment) that uses | ||
| `import Python_sml_ClientInterface` functional, portable, with no further modifications necessary. | ||
|
|
||
| ## Building locally | ||
|
|
||
| Building and installing this package via pip, locally, is easy: | ||
|
|
||
| ```BASH | ||
| $ pip install soar/Core/ClientSMLSWIG/Python | ||
| ``` | ||
|
|
||
| This will generate all the required build artifacts, install them to your python installation (system-wide, or | ||
| inside a virtual environment), and prepare it for `import soar_sml` statements in your scripts/programs. | ||
|
|
||
| ## Developing and Packaging | ||
|
|
||
| Notes for developing and packaging `soar-sml` can be found in [`DEVELOPING.md`](./DEVELOPING.md) |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from soar_sml import * |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # `soar-compat` | ||
|
|
||
| A small shim library that provides compatibility with packaging/distribution methods for Soar's SML Bindings. | ||
|
|
||
| The raw bindings, as built in Soar, are imported as `import Python_sml_ClientInterface`, | ||
| while the pypi package `soar-sml` imports as `soar_sml`. | ||
|
|
||
| While it possible to do `import soar_sml as Python_sml_ClientInterface`, this small library avoids that need, | ||
| and allows all existing scripts to import Soar's SML Bindings in the way they're used to. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.