bobfang1992 / pytomlpp

A python wrapper for tomlplusplus
https://bobfang1992.github.io/pytomlpp/pytomlpp.html
MIT License
86 stars 10 forks source link

Build, test and publish wheels via Github Action, remove cmake #4

Closed chaitan94 closed 4 years ago

chaitan94 commented 4 years ago

Wheels building status

  1. Linux: wheels seem to build for manylinux without any issues.
  2. Mac OS: failing with a project level error:
    [ 50%] Building CXX object CMakeFiles/pytomlpp.dir/src/pytomlpp.cpp.o
    In file included from /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-req-build-ojfeoq17/src/pytomlpp.cpp:3:
    /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-req-build-ojfeoq17/include/pytomlpp.hpp:38:99: error: 'value' is unavailable: introduced in macOS 10.14
          py::object time_delta = PY_DATETIME_MODULE.attr("timedelta")("minutes"_a = dt.time_offset.value().minutes);
                                                                                                    ^
    /Applications/Xcode_11.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/optional:943:33: note: 'value' has been explicitly marked unavailable here
      constexpr value_type const& value() const&
                                  ^
    1 error generated.
  3. Windows: Definitely the trickiest. Have to test once Mac OS support is in place.

Publishing workflow

Note: We do not build and publish sdist to pip. Ideal publishing flow for any new release should be:

(Assuming we are publishing a version say 1.2.3)

Publish to test PyPI

  1. Set file content of VERSION to 1.2.3rc1
  2. Build sdist locally: python setup.py sdist
  3. Publish sdist: twine upload --repository testpypi dist/*
  4. Test install works locally pip install -i https://test.pypi.org/simple/ pytomlpp==1.2.3rc1
  5. If something fails, go to step 1, increment version, say rc2, repeat until success

Publish to PyPI

(First make sure PYPI_TOKEN is setup in your repository's Github secrets)

  1. Set file content of VERSION to 1.2.3
  2. Add a new commit Bump to 1.2.3
  3. Push commit git push
  4. Verify in GitHub Actions that all wheels are built as expected (note they won't be published yet, as we didn't tag the commit)
  5. If any of them fail, you should fix the issues accordingly before proceeding further
  6. Tag your commit git tag 1.2.3
  7. Push commit git push origin 1.2.3
  8. Sit back and relax as your wheels get built and released on PyPI
zooba commented 4 years ago

Windows should be trivial for this, I don't understand what's so tricky?

The GitHub Actions images include CMake and Visual Studio for Python 3.5 and later, so once you drop 2.7 support it ought to be straightforward.

Do some of the build tools you're using need contributions?

EpicWink commented 4 years ago

I would suggest you pull in the changes of #2, That would remove the need for Cmake, especially as then we're testing just the library itself. This could also fix the issues with Windows

bobfang1992 commented 4 years ago

Looking at this, and I think I agree with @EpicWink on where this should go: we should remove cmake altogether and just use python setup.py/pip to build this package. Also can remove the google tests as there is no need for them. @chaitan94 Do you want to make this change? Thanks!

bobfang1992 commented 4 years ago

I guess to do is to:

And then we are in good shape.

chaitan94 commented 4 years ago

Sure will make suggested changes.

Apart from that are any of you aware of what could be the issue I'm facing in Mac OS build? I am not familiar with C++17 features as much yet. Seems like optional feature is not working as expected in mac.

bobfang1992 commented 4 years ago

@chaitan94 I will look into that and see if I can help you.

bobfang1992 commented 4 years ago

@chaitan94 I merged #3, please rebase, thanks.

chaitan94 commented 4 years ago

Regarding google tests, I guess we wouldn't need test_lib_config.cpp as well right?

bobfang1992 commented 4 years ago

Regarding google tests, I guess we wouldn't need test_lib_config.cpp as well right?

yep, no need for it anymore @chaitan94

chaitan94 commented 4 years ago

I've pulled in all latest changes and removed google-tests related code. Right now wheels are being built both by Github Actions and Travis (Although we have yet to fix the macOS issue on Github Actions). Should we deprecate Travis?

bobfang1992 commented 4 years ago

Yeah, let's deprecate Travis. Give me some time and I will see if I can fix the Mac OS issue. BTW is windows okay now or you need to work on it?

chaitan94 commented 4 years ago

Right now its failing with 'unknown option '-std=c++17', I think MSVC expects something like '/std:c++17' instead of '-std=c++17'. I will try that and check accordingly.

chaitan94 commented 4 years ago

PyPy build also seems to fail (even on Linux): https://github.com/chaitan94/pytomlpp/runs/790601180?check_suite_focus=true

   In file included from src/pytomlpp.cpp:3:
  include/pytomlpp.hpp: In function ‘toml::array pytomlpp::py_list_to_toml_array(const pybind11::list&)’:
  include/pytomlpp.hpp:264:77: error: cannot bind non-const lvalue reference of type ‘pybind11::handle&’ to an rvalue of type ‘pybind11::handle’
               toml::date_time date_time_value = py_datetime_to_toml_date_time(it);
                                                                               ^~
chaitan94 commented 4 years ago

I have added back toml-test. I also made a change so that tests won't succeed without it.

Guys I have restricted to Linux and non-pypy. I think it would be best if we merge the work so far and continue work on fixing Mac OS, Windows and PyPy build seperately. Since there are many commits already constantly rebasing would be a inefficient use of time.

chaitan94 commented 4 years ago

The build and test is succeeding as of now: https://github.com/chaitan94/pytomlpp/runs/790658356?check_suite_focus=true

bobfang1992 commented 4 years ago

Hi, Thanks for all the hard work. So the gist is:

Is this understanding correct? I will be happy to merge this if it is. And then we can work on separate PRs to get the above limitations removed.

Just 2 points:

  1. Let me do a quick review
  2. Could you rebase? Seems currently we have conflicts.

Thanks!

chaitan94 commented 4 years ago

Hi, Thanks for all the hard work. So the gist is:

* This change deprecates Travis and uses Github Actions instead.

* it builds on Linux

* it does not build on Windows or Mac OS yet, also not working for Pypy

Is this understanding correct? I will be happy to merge this if it is. And then we can work on separate PRs to get the above limitations removed.

Just 2 points:

1. Let me do a quick review

2. Could you rebase? Seems currently we have conflicts.

Thanks!

Yes, you are correct on all three points. I have resolved the conflicts just a few minutes ago - there shouldn't be any now. I have remove cmake realted stuff. We should be good to merge once this suceeds: https://github.com/chaitan94/pytomlpp/actions/runs/141790648 .

chaitan94 commented 4 years ago

Windows should be trivial for this, I don't understand what's so tricky?

@zooba Windows is ALWAYS the trickiest. Never underestimate it :stuck_out_tongue_closed_eyes:.

Hence, let's keep it and macos support separate from this for now.

bobfang1992 commented 4 years ago

Hi, sorry I still see there is conflicts and cannot merge... Can you check again? @chaitan94

bobfang1992 commented 4 years ago

This branch cannot be rebased due to conflicts Rebasing the commits of this branch on top of the base branch cannot be performed automatically due to conflicts encountered while reapplying the individual commits from the head branch.

This is what I am seeing right now.

chaitan94 commented 4 years ago

Maybe you want to squash and merge instead?

EpicWink commented 4 years ago

Maybe you want to squash and merge instead?

You can do this as well

git fetch -p --all
git reset --soft upstream/master
git add -u
git commit
chaitan94 commented 4 years ago

This branch cannot be rebased due to conflicts

@bobfang1992 I made a clean rebase again now. Hopefully, you shouldn't face any issues now.

EpicWink commented 4 years ago

Ahh yeah, pathlib.Path.glob is a generator. You'll need to valid_toml_files = list(valid_toml_files)

bobfang1992 commented 4 years ago

Great thanks! This is a lot of work. Thank you a lot @chaitan94