README.md in pycall-1.4.2 vs README.md in pycall-1.5.0

- old
+ new

@@ -17,14 +17,12 @@ pycall.rb supports Ruby version 2.4 or higher. ## Supported Python versions -pycall.rb supports Python version 2.7 or higher. +pycall.rb supports Python version 3.7 or higher. -Note that in Python 2.7 old-style class, that is defined without a super class, is not fully supported in pycall.rb. - ## Note for pyenv users pycall.rb requires Python's shared library (e.g. `libpython3.7m.so`). pyenv does not build the shared library in default, so you need to specify `--enable-shared` option at the installation like below: @@ -142,13 +140,13 @@ ## PyCall object system PyCall wraps pointers of Python objects in `PyCall::PyPtr` objects. `PyCall::PyPtr` class has two subclasses, `PyCall::PyTypePtr` and -`PyCall::PyRubyPtr`. `PyCall::PyTypePtr` is specialized for type (and classobj -in 2.7) objects, and `PyCall::PyRubyPtr` is for the objects that wraps pointers -of Ruby objects. +`PyCall::PyRubyPtr`. `PyCall::PyTypePtr` is specialized for type objects, +and `PyCall::PyRubyPtr` is for the objects that wraps pointers of +Ruby objects. These `PyCall::PyPtr` objects are used mainly in PyCall infrastructure. Instead, we usually treats the instances of `Object`, `Class`, `Module`, or other classes that are extended by `PyCall::PyObjectWrapper` module. @@ -160,21 +158,36 @@ translates Ruby's coerce system into Python's swapped operation protocol. ## Deploying on Heroku Heroku's default version of Python is not compiled with the `--enabled-shared` -option and can't be accessed by PyCall. Alternative [buildpacks](https://devcenter.heroku.com/articles/buildpacks) are available, -including these that have been reported to work with PyCall: +option and can't be accessed by PyCall. -https://github.com/richgong/heroku-buildpack-python -https://github.com/dsounded/heroku-buildpack-python -https://github.com/ReforgeHQ/heroku-buildpack-python +There are many ways to make our heroku use Python that is compiled with the `--enabled-shared` option: -These community-developed buildpacks are not supported by Heroku, so it's -worth examining the source to make sure the buildpack you use suits your -needs. For instance, 'ReforgeHQ' works well with Python 3.8.1, but has not -been configured to work with other versions and may not be as generally -useful as the 'dsounded' or 'richgong' buildpacks. + - use Heroku's official Python buildpacks `post_compile` hooks to recompile the python if the `--enabled-shared` option is not enabled. + example script of `post_compile` in ruby on rails app `bin/post_compile`. + + set -e + buildpack_url=https://github.com/heroku/heroku-buildpack-python + buildpack_vsn=v197 # adjust version accordingly https://github.com/heroku/heroku-buildpack-python/tags + + # rebuild python if it's missing enable-shared + if ! python3 -msysconfig | grep enable-shared \ + > /dev/null; then + PYTHON_VERSION="$(< runtime.txt)" + git clone -b "$buildpack_vsn" "$buildpack_url" _buildpack + export WORKSPACE_DIR="$PWD/_buildpack/builds" + rm -f .heroku/python/bin/python # prevent failing ln after build + sed -i 's!figure --pre!figure --enable-shared --pre!' \ + "$WORKSPACE_DIR"/runtimes/python3 + "$WORKSPACE_DIR/runtimes/$PYTHON_VERSION" /app/.heroku/python/ + rm -fr _buildpack + fi + + - use your own precompiled python with `--enabled-shared` options then fork the official heroku [python buildspacks](https://github.com/heroku/heroku-buildpack-python) and change the `BUILDPACK_S3_BASE_URL` with your own uploaded precompiled python in Amazon's S3. + - use 3rd party buildpacks from the [markets](https://elements.heroku.com/buildpacks) that have python with `--enabled-shared` option. + The buildpack will expect to find both a `runtime.txt` and a `requirements.txt` file in the root of your project. You will need to add these to specify the version of Python and any packages to be installed via `pip`, _e.g_ to use version Python 3.8.1 and version 2.5 of the 'networkx' package: