pycall 1.5.1 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/ci.yml +26 -27
- data/.github/workflows/release.yml +48 -0
- data/.github/workflows/windows.yml +18 -17
- data/CHANGES.md +22 -0
- data/README.md +20 -46
- data/Rakefile +11 -0
- data/docker/Dockerfile +1 -1
- data/ext/pycall/extconf.rb +2 -0
- data/ext/pycall/gc.c +6 -2
- data/ext/pycall/libpython.c +4 -0
- data/ext/pycall/pycall.c +134 -14
- data/ext/pycall/pycall_internal.h +11 -1
- data/ext/pycall/range.c +8 -2
- data/ext/pycall/ruby_wrapper.c +27 -80
- data/lib/pycall/libpython/pytypeobject_struct.rb +1 -1
- data/lib/pycall/pyobject_wrapper.rb +2 -3
- data/lib/pycall/version.rb +1 -1
- data/lib/pycall.rb +1 -1
- data/pycall.gemspec +7 -15
- metadata +16 -36
- data/bin/guard +0 -17
- data/ci/travis_before_script.sh +0 -21
- data/ci/travis_install.sh +0 -69
- data/ci/travis_retry.sh +0 -19
- data/config/Guardfile +0 -30
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbe8667d161e27770570029b6e2da005db45d5f2e61482ba7ffa96117fa82a61
|
|
4
|
+
data.tar.gz: 530c510c0accfc3b1af1daf69ad530855ecf943ffaf6dd9d47975bf7f89132a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 179af9a8a76e9f4528990468e8eb776c9031390cea2f28219c3da8aaf5dbc017df1cf2dfdf254b549a9313800ec640f82d4ca5302d6b74d3b192cc79daaf896b
|
|
7
|
+
data.tar.gz: 71a248181b886b513a650aef95a583563d5bb34e125e8f0bc1dc838e47c8ab6d38480bfe77d017065c73c47177dccab6d5a27b28d666b401e325fb118e95ea30
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -3,14 +3,9 @@ name: CI
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
- "check/unix/**"
|
|
6
|
+
- "**"
|
|
7
|
+
- '!dependabot/**'
|
|
9
8
|
pull_request:
|
|
10
|
-
types:
|
|
11
|
-
- opened
|
|
12
|
-
- synchronize
|
|
13
|
-
- reopened
|
|
14
9
|
|
|
15
10
|
jobs:
|
|
16
11
|
test:
|
|
@@ -22,9 +17,11 @@ jobs:
|
|
|
22
17
|
matrix:
|
|
23
18
|
os:
|
|
24
19
|
- ubuntu-latest
|
|
25
|
-
- ubuntu-
|
|
20
|
+
- ubuntu-22.04
|
|
26
21
|
- macos-latest
|
|
27
22
|
ruby:
|
|
23
|
+
- "3.4"
|
|
24
|
+
- "3.3"
|
|
28
25
|
- "3.2"
|
|
29
26
|
- "3.1"
|
|
30
27
|
- "3.0"
|
|
@@ -36,33 +33,35 @@ jobs:
|
|
|
36
33
|
venv:
|
|
37
34
|
- ""
|
|
38
35
|
include:
|
|
36
|
+
# Python 3.11 with the latest Ruby
|
|
37
|
+
- { os: ubuntu-22.04 , ruby: 3.3 , python: "3.11" , python_architecture: x64 , venv: "" }
|
|
38
|
+
|
|
39
39
|
# Old ruby and the latest Python 3
|
|
40
|
-
- { os: ubuntu-
|
|
41
|
-
- { os: ubuntu-
|
|
42
|
-
- { os: ubuntu-
|
|
40
|
+
- { os: ubuntu-22.04 , ruby: 2.6 , python: "3.x" , python_architecture: x64 , venv: "" }
|
|
41
|
+
- { os: ubuntu-22.04 , ruby: 2.5 , python: "3.x" , python_architecture: x64 , venv: "" }
|
|
42
|
+
- { os: ubuntu-22.04 , ruby: 2.4 , python: "3.x" , python_architecture: x64 , venv: "" }
|
|
43
43
|
|
|
44
44
|
# Ruby 2.7 with Each Python 3.x
|
|
45
|
-
- { os: ubuntu-
|
|
46
|
-
- { os: ubuntu-
|
|
47
|
-
- { os: ubuntu-
|
|
48
|
-
- { os: ubuntu-
|
|
49
|
-
- { os: ubuntu-
|
|
50
|
-
- { os: ubuntu-
|
|
45
|
+
- { os: ubuntu-22.04 , ruby: 2.7 , python: "3.12" , python_architecture: x64 , venv: "" }
|
|
46
|
+
- { os: ubuntu-22.04 , ruby: 2.7 , python: "3.11" , python_architecture: x64 , venv: "" }
|
|
47
|
+
- { os: ubuntu-22.04 , ruby: 2.7 , python: "3.10" , python_architecture: x64 , venv: "" }
|
|
48
|
+
- { os: ubuntu-22.04 , ruby: 2.7 , python: "3.9" , python_architecture: x64 , venv: "" }
|
|
49
|
+
- { os: ubuntu-22.04 , ruby: 2.7 , python: "3.8" , python_architecture: x64 , venv: "" }
|
|
50
|
+
- { os: ubuntu-22.04 , ruby: 2.7 , python: "3.7" , python_architecture: x64 , venv: "" }
|
|
51
51
|
|
|
52
52
|
# Ruby-debug with the latest Python 3
|
|
53
|
-
- { os: ubuntu-
|
|
53
|
+
- { os: ubuntu-22.04 , ruby: debug , python: "3.x" , python_architecture: x64 , venv: "" }
|
|
54
54
|
|
|
55
|
-
# Ruby
|
|
56
|
-
- { os: ubuntu-
|
|
55
|
+
# The latest stable Ruby with the latest Python 3 with venv
|
|
56
|
+
- { os: ubuntu-22.04 , ruby: "3.3" , python: "3.x" , python_architecture: x64 , venv: "venv:" }
|
|
57
57
|
|
|
58
58
|
# macOS with venv
|
|
59
|
-
- { os: macos-latest , ruby: "3.
|
|
60
|
-
- { os: macos-latest , ruby: "3.1" , python: "3.8" , python_architecture: x64 , venv: "venv:" }
|
|
59
|
+
- { os: macos-latest , ruby: "3.3" , python: "3.x" , python_architecture: x64 , venv: "venv:" }
|
|
61
60
|
|
|
62
61
|
#- { os: macos-latest , ruby: debug , python: "3.x" , python_architecture: x64 , venv: "" }
|
|
63
62
|
|
|
64
63
|
steps:
|
|
65
|
-
- uses: actions/checkout@
|
|
64
|
+
- uses: actions/checkout@v7
|
|
66
65
|
with:
|
|
67
66
|
fetch-depth: 1
|
|
68
67
|
|
|
@@ -71,7 +70,7 @@ jobs:
|
|
|
71
70
|
with:
|
|
72
71
|
ruby-version: ${{ matrix.ruby }}
|
|
73
72
|
|
|
74
|
-
- uses: actions/setup-python@
|
|
73
|
+
- uses: actions/setup-python@v7
|
|
75
74
|
with:
|
|
76
75
|
python-version: ${{ matrix.python }}
|
|
77
76
|
architecture: ${{ matrix.python_architecture }}
|
|
@@ -105,7 +104,7 @@ jobs:
|
|
|
105
104
|
fail-fast: false
|
|
106
105
|
matrix:
|
|
107
106
|
os:
|
|
108
|
-
- ubuntu-
|
|
107
|
+
- ubuntu-22.04
|
|
109
108
|
#- macos-latest
|
|
110
109
|
ruby:
|
|
111
110
|
- "3.1"
|
|
@@ -113,11 +112,11 @@ jobs:
|
|
|
113
112
|
- "3.10"
|
|
114
113
|
|
|
115
114
|
steps:
|
|
116
|
-
- uses: actions/checkout@
|
|
115
|
+
- uses: actions/checkout@v7
|
|
117
116
|
with:
|
|
118
117
|
fetch-depth: 1
|
|
119
118
|
|
|
120
|
-
- uses: conda-incubator/setup-miniconda@
|
|
119
|
+
- uses: conda-incubator/setup-miniconda@v4
|
|
121
120
|
with:
|
|
122
121
|
activate-environment: test
|
|
123
122
|
python-version: ${{ matrix.python }}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags:
|
|
5
|
+
- "*"
|
|
6
|
+
jobs:
|
|
7
|
+
github:
|
|
8
|
+
name: GitHub
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
timeout-minutes: 10
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
discussions: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
- name: Extract release note
|
|
17
|
+
run: |
|
|
18
|
+
ruby \
|
|
19
|
+
-e 'print("## PyCall "); \
|
|
20
|
+
puts(ARGF.read.split(/^## /)[1])' \
|
|
21
|
+
CHANGES.md > release-note.md
|
|
22
|
+
- name: Upload to release
|
|
23
|
+
env:
|
|
24
|
+
GH_TOKEN: ${{ github.token }}
|
|
25
|
+
run: |
|
|
26
|
+
title=$(head -n1 release-note.md | sed -e 's/^## //')
|
|
27
|
+
tail -n +2 release-note.md > release-note-without-version.md
|
|
28
|
+
gh release create ${GITHUB_REF_NAME} \
|
|
29
|
+
--discussion-category Announcements \
|
|
30
|
+
--notes-file release-note-without-version.md \
|
|
31
|
+
--title "${title}"
|
|
32
|
+
rubygems:
|
|
33
|
+
name: RubyGems
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
timeout-minutes: 10
|
|
36
|
+
permissions:
|
|
37
|
+
id-token: write
|
|
38
|
+
environment: release
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v7
|
|
41
|
+
- uses: ruby/setup-ruby@v1
|
|
42
|
+
with:
|
|
43
|
+
ruby-version: ruby
|
|
44
|
+
bundler-cache: true
|
|
45
|
+
- uses: rubygems/configure-rubygems-credentials@v2.1.0
|
|
46
|
+
- name: Push gems
|
|
47
|
+
run: |
|
|
48
|
+
bundle exec rake release:rubygem_push
|
|
@@ -3,14 +3,9 @@ name: Windows
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
- "check/windows/**"
|
|
6
|
+
- "**"
|
|
7
|
+
- '!dependabot/**'
|
|
9
8
|
pull_request:
|
|
10
|
-
types:
|
|
11
|
-
- opened
|
|
12
|
-
- synchronize
|
|
13
|
-
- reopened
|
|
14
9
|
|
|
15
10
|
jobs:
|
|
16
11
|
test:
|
|
@@ -21,19 +16,24 @@ jobs:
|
|
|
21
16
|
fail-fast: false
|
|
22
17
|
matrix:
|
|
23
18
|
ruby:
|
|
19
|
+
- "3.3"
|
|
20
|
+
- "3.2"
|
|
21
|
+
- "3.1"
|
|
24
22
|
- "3.0"
|
|
25
|
-
- 2.7
|
|
26
|
-
- 2.6
|
|
23
|
+
- "2.7"
|
|
27
24
|
python:
|
|
28
25
|
- 3.x
|
|
29
26
|
python_architecture:
|
|
30
27
|
- x64
|
|
31
28
|
include:
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
# Python 3.11 with the latest Ruby
|
|
30
|
+
- { ruby: "3.3" , python: 3.11 , python_architecture: x64 }
|
|
31
|
+
# The development version of Ruby
|
|
32
|
+
- { ruby: mingw , python: 3.x , python_architecture: x64 }
|
|
33
|
+
#- { ruby: mswin , python: 3.x , python_architecture: x64 }
|
|
34
34
|
|
|
35
35
|
steps:
|
|
36
|
-
- uses: actions/checkout@
|
|
36
|
+
- uses: actions/checkout@v7
|
|
37
37
|
with:
|
|
38
38
|
fetch-depth: 1
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ jobs:
|
|
|
42
42
|
with:
|
|
43
43
|
ruby-version: ${{ matrix.ruby }}
|
|
44
44
|
|
|
45
|
-
- uses: actions/setup-python@
|
|
45
|
+
- uses: actions/setup-python@v7
|
|
46
46
|
with:
|
|
47
47
|
python-version: ${{ matrix.python }}
|
|
48
48
|
architecture: ${{ matrix.python_architecture }}
|
|
@@ -67,20 +67,21 @@ jobs:
|
|
|
67
67
|
fail-fast: false
|
|
68
68
|
matrix:
|
|
69
69
|
ruby:
|
|
70
|
-
- "3.
|
|
70
|
+
- "3.3"
|
|
71
71
|
python:
|
|
72
|
-
- 3.
|
|
72
|
+
- 3.12
|
|
73
|
+
- 3.11
|
|
73
74
|
|
|
74
75
|
defaults:
|
|
75
76
|
run:
|
|
76
77
|
shell: pwsh
|
|
77
78
|
|
|
78
79
|
steps:
|
|
79
|
-
- uses: actions/checkout@
|
|
80
|
+
- uses: actions/checkout@v7
|
|
80
81
|
with:
|
|
81
82
|
fetch-depth: 1
|
|
82
83
|
|
|
83
|
-
- uses: conda-incubator/setup-miniconda@
|
|
84
|
+
- uses: conda-incubator/setup-miniconda@v4
|
|
84
85
|
with:
|
|
85
86
|
activate-environment: test
|
|
86
87
|
python-version: ${{ matrix.python }}
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# The change history of PyCall
|
|
2
2
|
|
|
3
|
+
## 1.5.3
|
|
4
|
+
|
|
5
|
+
* Add support for Ruby 4.1 (#225).
|
|
6
|
+
|
|
7
|
+
*andreyzhelnin-st*
|
|
8
|
+
|
|
9
|
+
* Add support for multi-threading (#223, #224).
|
|
10
|
+
|
|
11
|
+
*andreyzhelnin-st*
|
|
12
|
+
|
|
13
|
+
## 1.5.2
|
|
14
|
+
|
|
15
|
+
* Fix memory leak with str(list) (#169).
|
|
16
|
+
|
|
17
|
+
*mknkmyza*
|
|
18
|
+
|
|
19
|
+
* Fix SEGV occured on Ruby process finalization.
|
|
20
|
+
|
|
21
|
+
* Fix for supporting Ruby >= 3.3.
|
|
22
|
+
|
|
23
|
+
* Fix for supporting Python >= 3.2.
|
|
24
|
+
|
|
3
25
|
## 1.5.1
|
|
4
26
|
|
|
5
27
|
* Fix memory leak in rich compare methods (#167, #168).
|
data/README.md
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
# PyCall: Calling Python functions from the Ruby language
|
|
7
7
|
|
|
8
|
-
[](https://ci.appveyor.com/project/mrkn/pycall-rb/branch/master)
|
|
8
|
+
[](https://github.com/red-data-tools/pycall.rb/actions?query=workflow%3ACI)
|
|
10
9
|
|
|
11
10
|
This library provides the features to directly call and partially interoperate
|
|
12
11
|
with Python from the Ruby language. You can import arbitrary Python modules
|
|
@@ -21,6 +20,10 @@ pycall.rb supports Ruby version 2.4 or higher.
|
|
|
21
20
|
|
|
22
21
|
pycall.rb supports Python version 3.7 or higher.
|
|
23
22
|
|
|
23
|
+
## PyCall does not support multi-threaded use officially
|
|
24
|
+
|
|
25
|
+
CPython's C-API has GIL acquiring/releasing functions such as `PyGILState_Ensure` and `PyGILState_Release`. Programmers can call CPython's C-APIs from outside of Python threads if they manage GIL's state by these functions. However, we do not want to officially support the multi-threaded use of PyCall because creating the feature enabling stable multi-threaded use in any situation is too difficult. We want to avoid incurring the costs to support such use cases.
|
|
26
|
+
|
|
24
27
|
## Note for pyenv users
|
|
25
28
|
|
|
26
29
|
pycall.rb requires Python's shared library (e.g. `libpython3.7m.so`).
|
|
@@ -128,15 +131,15 @@ DEBUG(find_libpython) dlopen("/opt/brew/opt/python/Frameworks/Python.framework/V
|
|
|
128
131
|
|
|
129
132
|
### matplotlib
|
|
130
133
|
|
|
131
|
-
Use [
|
|
134
|
+
Use [red-data-tools/matplotlib.rb](https://github.com/red-data-tools/matplotlib.rb) instead of just importing it by `PyCall.import_module("matplotlib")`.
|
|
132
135
|
|
|
133
136
|
### numpy
|
|
134
137
|
|
|
135
|
-
Use [
|
|
138
|
+
Use [red-data-tools/numpy.rb](https://github.com/red-data-tools/numpy.rb) instead of just importing it by `PyCall.import_module("numpy")`.
|
|
136
139
|
|
|
137
140
|
### pandas
|
|
138
141
|
|
|
139
|
-
Use [
|
|
142
|
+
Use [red-data-tools/pandas.rb](https://github.com/red-data-tools/pandas.rb) instead of just importing it by `PyCall.import_module("pandas")`.
|
|
140
143
|
|
|
141
144
|
## PyCall object system
|
|
142
145
|
|
|
@@ -159,41 +162,16 @@ translates Ruby's coerce system into Python's swapped operation protocol.
|
|
|
159
162
|
|
|
160
163
|
## Deploying on Heroku
|
|
161
164
|
|
|
162
|
-
Heroku's default
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
There are many ways to make our heroku use Python that is compiled with the `--enabled-shared` option:
|
|
166
|
-
|
|
167
|
-
- use Heroku's official Python buildpacks `post_compile` hooks to recompile the python if the `--enabled-shared` option is not enabled.
|
|
168
|
-
example script of `post_compile` in ruby on rails app `bin/post_compile`.
|
|
169
|
-
|
|
170
|
-
set -e
|
|
171
|
-
buildpack_url=https://github.com/heroku/heroku-buildpack-python
|
|
172
|
-
buildpack_vsn=v197 # adjust version accordingly https://github.com/heroku/heroku-buildpack-python/tags
|
|
165
|
+
Heroku's default builds of Python are now compiled with the `--enabled-shared` option
|
|
166
|
+
(when using Python 3.10 and newer) and so work out of the box with PyCall without
|
|
167
|
+
the need for a custom buildpack.
|
|
173
168
|
|
|
174
|
-
|
|
175
|
-
if ! python3 -msysconfig | grep enable-shared \
|
|
176
|
-
> /dev/null; then
|
|
177
|
-
PYTHON_VERSION="$(< runtime.txt)"
|
|
178
|
-
git clone -b "$buildpack_vsn" "$buildpack_url" _buildpack
|
|
179
|
-
export WORKSPACE_DIR="$PWD/_buildpack/builds"
|
|
180
|
-
rm -f .heroku/python/bin/python # prevent failing ln after build
|
|
181
|
-
sed -i 's!figure --pre!figure --enable-shared --pre!' \
|
|
182
|
-
"$WORKSPACE_DIR"/runtimes/python3
|
|
183
|
-
"$WORKSPACE_DIR/runtimes/$PYTHON_VERSION" /app/.heroku/python/
|
|
184
|
-
rm -fr _buildpack
|
|
185
|
-
fi
|
|
186
|
-
|
|
187
|
-
- 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.
|
|
188
|
-
- use 3rd party buildpacks from the [markets](https://elements.heroku.com/buildpacks) that have python with `--enabled-shared` option.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
The buildpack will expect to find both a `runtime.txt` and a `requirements.txt`
|
|
169
|
+
The Python buildpack will expect to find both a `.python-version` and a `requirements.txt`
|
|
192
170
|
file in the root of your project. You will need to add these to specify the
|
|
193
171
|
version of Python and any packages to be installed via `pip`, _e.g_ to use
|
|
194
|
-
version Python 3.
|
|
172
|
+
the latest patch version Python 3.12 and version 2.5 of the 'networkx' package:
|
|
195
173
|
|
|
196
|
-
$ echo "
|
|
174
|
+
$ echo "3.12" > .python-version
|
|
197
175
|
$ echo "networkx==2.5" >> requirements.txt
|
|
198
176
|
|
|
199
177
|
Commit these two files into project's repository. You'll use these to manage
|
|
@@ -212,12 +190,11 @@ For a Ruby/Rails application this will typically report the stock `heroku/ruby`
|
|
|
212
190
|
buildpack, or possibly both `heroku/ruby` and `heroku/nodejs`.
|
|
213
191
|
|
|
214
192
|
Clear the list and progressively add back your buildpacks, starting with the Python
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
be similar to this:
|
|
193
|
+
buildpack. For example, if `ruby` and `nodejs` buildpacks were previously installed,
|
|
194
|
+
your setup process will be similar to this:
|
|
218
195
|
|
|
219
196
|
$ heroku buildpacks:clear
|
|
220
|
-
$ heroku buildpacks:add
|
|
197
|
+
$ heroku buildpacks:add heroku/python -i 1
|
|
221
198
|
$ heroku buildpacks:add heroku/nodejs -i 2
|
|
222
199
|
# heroku buildpacks:add heroku/ruby -i 3
|
|
223
200
|
|
|
@@ -229,15 +206,12 @@ specify the order Heroku will load runtimes and execute bootstrapping code. It's
|
|
|
229
206
|
important for the Python environment to be engaged first, as PyCall will need to
|
|
230
207
|
be able to find it when Ruby-based processes start.
|
|
231
208
|
|
|
232
|
-
Once you have set up your buildpacks, and have
|
|
233
|
-
`
|
|
209
|
+
Once you have set up your buildpacks, and have committed both `requirements.txt` and
|
|
210
|
+
`.python-version` files to git, deploy your Heroku application as your normally would.
|
|
234
211
|
The Python bootstrapping process will appear in the log first, followed by the Ruby
|
|
235
212
|
and so on. PyCall should now be able to successfully call Python functions from
|
|
236
213
|
within the Heroku environment.
|
|
237
214
|
|
|
238
|
-
NB It is also possible to specify buildpacks within Docker images on Heroku.
|
|
239
|
-
See Heroku's [documentation on using Docker Images](https://devcenter.heroku.com/articles/build-docker-images-heroku-yml).
|
|
240
|
-
|
|
241
215
|
## Development
|
|
242
216
|
|
|
243
217
|
After checking out the repo, run `bin/setup` to install dependencies.
|
|
@@ -253,7 +227,7 @@ version, push git commits and tags, and push the `.gem` file to
|
|
|
253
227
|
## Contributing
|
|
254
228
|
|
|
255
229
|
Bug reports and pull requests are welcome on GitHub at
|
|
256
|
-
https://github.com/
|
|
230
|
+
https://github.com/red-data-tools/pycall.rb.
|
|
257
231
|
|
|
258
232
|
|
|
259
233
|
## Acknowledgement
|
data/Rakefile
CHANGED
|
@@ -91,3 +91,14 @@ end
|
|
|
91
91
|
|
|
92
92
|
task default: :spec
|
|
93
93
|
task spec: :compile
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
release_task = Rake.application["release"]
|
|
97
|
+
# We use Trusted Publishing.
|
|
98
|
+
release_task.prerequisites.delete("build")
|
|
99
|
+
release_task.prerequisites.delete("release:rubygem_push")
|
|
100
|
+
release_task_comment = release_task.comment
|
|
101
|
+
if release_task_comment
|
|
102
|
+
release_task.clear_comments
|
|
103
|
+
release_task.comment = release_task_comment.gsub(/ and build.*$/, "")
|
|
104
|
+
end
|
data/docker/Dockerfile
CHANGED
|
@@ -183,7 +183,7 @@ RUN bundle exec iruby register
|
|
|
183
183
|
|
|
184
184
|
# Deploy matplotlib's examples
|
|
185
185
|
RUN mkdir -p /tmp \
|
|
186
|
-
&& curl -fsSL https://github.com/
|
|
186
|
+
&& curl -fsSL https://github.com/red-data-tools/matplotlib.rb/archive/master.tar.gz | tar -xzf - -C /tmp \
|
|
187
187
|
&& mv /tmp/matplotlib.rb-master/examples /notebooks/examples/matplotlib \
|
|
188
188
|
&& rm -rf /tmp/matplotlib.rb-master
|
|
189
189
|
|
data/ext/pycall/extconf.rb
CHANGED
data/ext/pycall/gc.c
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#include "pycall_internal.h"
|
|
2
2
|
|
|
3
|
+
static ID id_gcguard_table;
|
|
4
|
+
|
|
3
5
|
struct gcguard {
|
|
4
6
|
st_table *guarded_objects;
|
|
5
7
|
};
|
|
@@ -24,6 +26,7 @@ gcguard_free(void* ptr)
|
|
|
24
26
|
{
|
|
25
27
|
struct gcguard *gg = (struct gcguard *)ptr;
|
|
26
28
|
st_free_table(gg->guarded_objects);
|
|
29
|
+
rb_ivar_set(mPyCall, id_gcguard_table, Qnil);
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
static size_t
|
|
@@ -69,7 +72,6 @@ gcguard_delete(VALUE gcguard, PyObject *pyptr)
|
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
static ID id_gcguard_table;
|
|
73
75
|
static PyObject *weakref_callback_pyobj;
|
|
74
76
|
static PyObject *gcguard_weakref_destroyed(PyObject *self, PyObject *weakref);
|
|
75
77
|
|
|
@@ -98,7 +100,9 @@ void
|
|
|
98
100
|
pycall_gcguard_delete(PyObject *pyobj)
|
|
99
101
|
{
|
|
100
102
|
VALUE gcguard = rb_ivar_get(mPyCall, id_gcguard_table);
|
|
101
|
-
|
|
103
|
+
if (!NIL_P(gcguard)) {
|
|
104
|
+
gcguard_delete(gcguard, pyobj);
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
void
|
data/ext/pycall/libpython.c
CHANGED
|
@@ -217,6 +217,10 @@ pycall_init_libpython_api_table(VALUE libpython_handle)
|
|
|
217
217
|
INIT_API_TABLE_ENTRY2(PyUnicode_DecodeUTF8, PyUnicodeUCS2_DecodeUTF8, required);
|
|
218
218
|
INIT_API_TABLE_ENTRY2(PyUnicode_FromFormatV, PyUnicodeUCS2_FromFormatV, required);
|
|
219
219
|
}
|
|
220
|
+
|
|
221
|
+
INIT_API_TABLE_ENTRY(PyGILState_Check, required);
|
|
222
|
+
INIT_API_TABLE_ENTRY(PyGILState_Ensure, required);
|
|
223
|
+
INIT_API_TABLE_ENTRY(PyGILState_Release, required);
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
void
|