Skip to content
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

add setup.py to install python package #254

Merged
merged 15 commits into from
Oct 26, 2021
Merged

add setup.py to install python package #254

merged 15 commits into from
Oct 26, 2021

Conversation

mcgibbon
Copy link
Contributor

@mcgibbon mcgibbon commented Oct 15, 2021

This PR adds a setup.py file inside serialbox-python which can be used to pip install it as a python package.

It also adds a build-pip workflow step which pip installs serialbox-python and runs the python tests.

@mcgibbon
Copy link
Contributor Author

While the package installs correctly, it does not pass the Python tests (in test/serialbox-python/serialbox). These tests also do not pass on our non-pip (normal cmake) install, so it's unclear whether they break due to our installation or the code. In particular, serialbox.error.invoke crashes in the "archive" test, presumably because the compiled library exits directly instead of returning an error value.

@jenkins-apn
Copy link
Collaborator

Hi there, this is jenkins continuous integration...
Do you want me to verify this patch?

@mcgibbon
Copy link
Contributor Author

mcgibbon commented Oct 15, 2021

The tests do now appear to be passing (I replaced a sys.exit with the appropriate set-sentinel-value call), but not on CI. I'm unsure why, but it doesn't appear to be finding CMakeLists.txt at the top level of the repo. You can check it out on our branch tests here.

@mcgibbon
Copy link
Contributor Author

mcgibbon commented Oct 18, 2021

OK, tests are now passing on CI. The issue was that the older version of pip in the default environment copies the setup.py and other files to a temporary directory away from the source code that needed to compile, so when I tried to grab the sources from two levels up it wasn't finding it. The updated versions now in the build-pip CI step build a wheel with the files in-place.

@ofuhrer
Copy link
Contributor

ofuhrer commented Oct 19, 2021

@havogt Could we kick off CI for this PR?

@havogt
Copy link
Collaborator

havogt commented Oct 21, 2021

ok to test

@havogt
Copy link
Collaborator

havogt commented Oct 21, 2021

launch jenkins

Copy link
Collaborator

@havogt havogt left a comment

Choose a reason for hiding this comment

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

Thanks @mcgibbon! Looks good. I'll ask @egparedes if he wants to have a quick look as he has experience with pip setups.


DIR = os.path.abspath(os.path.dirname(__file__))

# Convert distutils Windows platform specifiers to CMake -A arguments
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you copy this structure from a template and therefore all the windows stuff or does Serialbox actually compile on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied from the cmake setup.py template. No idea whether it does or does not compile on windows. I'd be happy to remove the windows stuff if you can point out what is safe/appropriate to remove, though the only issue it might cause is someone thinking it works on Windows if it does not.

# logic and declaration, and simpler if you include description/version in a file.
setup(
name="serialbox",
version="0.0.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably move the version number into a text file (instead of keeping it in the CMakeLists.txt) to make it easily accessible here. I can do that in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've had a really good experience using bumpversion to control this, you tell it all the places where your version string exists and it will update them with a command. It keeps track of the version centrally in its own config.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I'll have a look.

@havogt havogt requested a review from egparedes October 21, 2021 10:55
Copy link

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

It looks good to me. My only minor point is that if building the package in Windows is not expected to work, it would be good to document it somewhere (or remove the Windows parts from the building script).

@havogt
Copy link
Collaborator

havogt commented Oct 25, 2021

launch jenkins

@mcgibbon
Copy link
Contributor Author

Committed the suggested change, should be ready to go barring the Jenkins test failure being relevant.

@havogt
Copy link
Collaborator

havogt commented Oct 25, 2021

Thanks! Could you merge with master, then jenkins should be green as well.

@havogt
Copy link
Collaborator

havogt commented Oct 25, 2021

launch jenkins

@havogt havogt merged commit bd0cbd3 into GridTools:master Oct 26, 2021
@ofuhrer ofuhrer deleted the feature/setup_py branch October 26, 2021 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants