Skip to content

Commit 3b756ad

Browse files
committed
Rename pythonscript -> gdpy
1 parent fa7289a commit 3b756ad

40 files changed

+1177
-1186
lines changed

README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Check Travis or Appveyor links above to see the current status of your platform.
241241
This command will checkout CPython repo, move to a pinned commit and build
242242
CPython from source.
243243

244-
It will then generate ``pythonscript/godot/bindings.pyx`` (Godot api bindings)
244+
It will then generate ``gdpy/godot/bindings.pyx`` (Godot api bindings)
245245
from GDNative's ``api.json`` and compile it.
246246
This part is long and really memory demanding so be patient ;-)
247247
When hacking godot-python you can heavily speedup this step by passing
@@ -305,7 +305,7 @@ First, export the project in .zip format.
305305

306306
Second, extract the .zip in a directory. For sake of example let's say the directory is called :code:`godotpythonproject`.
307307

308-
Third, copy the correct Python environment into this folder (if it hasn't been automatically included in the export). Inside your project folder, you will need to find :code:`/addons/pythonscript/x11-64`, replacing "x11-64" with the correct target system you are deploying to. Copy the entire folder for your system, placing it at the same relative position, e.g. :code:`godotpythonproject/addons/pythonscript/x11-64` if your unzipped directory was "godotpythonproject". Legally speaking you should also copy LICENSE.txt from the pythonscript folder. (The lazy option at this point is to simply copy the entire addons folder from your project to your unzipped directory.)
308+
Third, copy the correct Python environment into this folder (if it hasn't been automatically included in the export). Inside your project folder, you will need to find :code:`/addons/gdpy/x11-64`, replacing "x11-64" with the correct target system you are deploying to. Copy the entire folder for your system, placing it at the same relative position, e.g. :code:`godotpythonproject/addons/gdpy/x11-64` if your unzipped directory was "godotpythonproject". Legally speaking you should also copy LICENSE.txt from the gdpy folder. (The lazy option at this point is to simply copy the entire addons folder from your project to your unzipped directory.)
309309

310310
Fourth, place a godot release into the directory. The Godot export menu has probably downloaded an appropriate release already, or you can go to Editor -> Manage Export Templates inside Godot to download fresh ones. These are stored in a location which depends on your operating system. For example, on Windows they may be found at :code:`%APPDATA%\Godot\templates\ `; in Linux or OSX it is :code:`~/.godot/templates/`. Copy the file matching your export. (It may matter whether you selected "Export With Debug" when creating the .zip file; choose the debug or release version accordingly.)
311311

@@ -317,17 +317,17 @@ See also `this issue <https://github.com/touilleMan/godot-python/issues/146>`_.
317317

318318
In essence, godot-python installs a python interpreter inside your project which can then be distributed as part of the final game. Python packages you want to use need to be installed for that interpreter and of course included in the final release. This can be accomplished by using pip to install packages; however, pip is not provided, so it must be installed too.
319319

320-
First, locate the correct python interpreter. This will be inside your project at :code:`addons\pythonscript\windows-64\python.exe` for 64-bit Windows, :code:`addons/pythonscript/ox-64/bin/python3` for OSX, etc. Then install pip by running:
320+
First, locate the correct python interpreter. This will be inside your project at :code:`addons\gdpy\windows-64\python.exe` for 64-bit Windows, :code:`addons/gdpy/ox-64/bin/python3` for OSX, etc. Then install pip by running:
321321

322322
.. code-block::
323323
324-
addons\pythonscript\windows-64\python.exe -m ensurepip
324+
addons\gdpy\windows-64\python.exe -m ensurepip
325325
326326
(substituting the correct python for your system). Any other method of installing pip at this location is fine too, and this only needs to be done once. Afterward, any desired packages can be installed by running
327327

328328
.. code-block::
329329
330-
addons\pythonscript\windows-64\python.exe -m pip install numpy
330+
addons\gdpy\windows-64\python.exe -m pip install numpy
331331
332332
again, substituting the correct python executable, and replacing numpy with whatever packages you desire. The package can now be imported in your Python code as normal.
333333

@@ -348,7 +348,7 @@ In your :code:`project.godot` file, add the following section::
348348
In addition to the usual::
349349

350350
[gdnative]
351-
singletons=[ "res://pythonscript.gdnlib" ]
351+
singletons=[ "res://gdpy.gdnlib" ]
352352

353353
You can use any name for the python file and the class name
354354
:code:`autoloadpy`.

examples/pong/project.godot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ stretch_2d=true
2828

2929
[editor_plugins]
3030

31-
enabled=PackedStringArray("pythonscript_repl")
31+
enabled=PackedStringArray("gdpy_repl")
3232

3333
[gdnative]
3434

35-
singletons=["res://pythonscript.gdnlib"]
35+
singletons=["res://gdpy.gdnlib"]
3636

3737
[input]
3838

libgodot/copy_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ def copy_data(build_dir: Path) -> None:
1717
output_godot_hazmat_dir.mkdir(parents=True, exist_ok=True)
1818

1919
shutil.copy(ROOT_DIR / "src/_gdpy_libgodot.pyx", TARGET_DIR)
20-
shutil.copy(build_dir / "src/pythonscript_gdextension_ptrs.c", TARGET_DIR)
20+
shutil.copy(build_dir / "src/gdpy_gdextension_ptrs.c", TARGET_DIR)
2121

2222
shutil.copytree(build_dir / "gdextension_api", TARGET_DIR / "gdextension_api")
2323

2424
src_godot_dir = ROOT_DIR / "src/godot"
2525
shutil.copy(src_godot_dir / "__init__.py", output_godot_dir)
26-
shutil.copy(src_godot_dir / "__init__.pyi", output_godot_dir)
2726
shutil.copy(src_godot_dir / "_lang.pyx", output_godot_dir)
2827
shutil.copy(src_godot_dir / "_lang_resource_format_loader.pxi", output_godot_dir)
2928
shutil.copy(src_godot_dir / "_lang_resource_format_saver.pxi", output_godot_dir)

meson.build

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ if host_platform.startswith('linux')
163163
),
164164
include_directories: [join_paths(python_prebuild_name, 'python/install/include/python@0@.@1@'.format(cpython_distrib_version_major, cpython_distrib_version_minor))],
165165
)
166-
# e.g. addons/pythonscript/linux-x86_64/lib/python3.9/site-packages
166+
# e.g. addons/gdpy/linux-x86_64/lib/python3.9/site-packages
167167
python_site_packages_install_path = join_paths(
168-
'addons/pythonscript',
168+
'addons/gdpy',
169169
host_platform,
170170
'lib/python@0@.@1@/site-packages'.format(cpython_distrib_version_major, cpython_distrib_version_minor)
171171
)
@@ -178,9 +178,9 @@ elif host_platform.startswith('macos')
178178
),
179179
include_directories: [join_paths(python_prebuild_name, 'python/install/include/python@0@.@1@'.format(cpython_distrib_version_major, cpython_distrib_version_minor))],
180180
)
181-
# e.g. addons/pythonscript/linux-x86_64/lib/python3.9/site-packages
181+
# e.g. addons/gdpy/linux-x86_64/lib/python3.9/site-packages
182182
python_site_packages_install_path = join_paths(
183-
'addons/pythonscript',
183+
'addons/gdpy',
184184
host_platform,
185185
'lib/python@0@.@1@/site-packages'.format(cpython_distrib_version_major, cpython_distrib_version_minor)
186186
)
@@ -195,9 +195,9 @@ elif host_platform.startswith('windows')
195195
),
196196
include_directories: [join_paths(python_prebuild_name, 'python/install/include')],
197197
)
198-
# e.g. addons/pythonscript/windows-x86_64/Lib/site-packages
198+
# e.g. addons/gdpy/windows-x86_64/Lib/site-packages
199199
python_site_packages_install_path = join_paths(
200-
'addons/pythonscript',
200+
'addons/gdpy',
201201
host_platform,
202202
'Lib/site-packages'
203203
)
@@ -208,7 +208,7 @@ endif
208208

209209
install_subdir(
210210
python_distrib_path,
211-
install_dir: join_paths('addons/pythonscript', host_platform),
211+
install_dir: join_paths('addons/gdpy', host_platform),
212212
strip_directory: true,
213213
)
214214
if build_machine.system() == 'linux'
@@ -248,7 +248,7 @@ if build_machine.system() == 'linux'
248248
)
249249
install_symlink(
250250
symlink_name,
251-
install_dir: join_paths('addons/pythonscript', host_platform, parent_dir),
251+
install_dir: join_paths('addons/gdpy', host_platform, parent_dir),
252252
pointing_to: target_name,
253253
)
254254
endforeach
@@ -376,7 +376,7 @@ README.txt
376376

377377
install_data(
378378
'LICENSE.txt',
379-
install_dir: 'addons/pythonscript',
379+
install_dir: 'addons/gdpy',
380380
)
381381

382382

@@ -390,7 +390,7 @@ custom_target(
390390
],
391391
output: ['.gdignore'],
392392
install: true,
393-
install_dir: 'addons/pythonscript',
393+
install_dir: 'addons/gdpy',
394394
)
395395

396396

@@ -415,9 +415,9 @@ open("@OUTPUT0@", mode="w", encoding="utf8").write(out)
415415

416416

417417
install_data(
418-
'misc/release_pythonscript.gdextension',
418+
'misc/release_gdpy.gdextension',
419419
install_dir: '.',
420-
rename: 'pythonscript.gdextension',
420+
rename: 'gdpy.gdextension',
421421
)
422422

423423

misc/release_README.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ Pip must be installed first with `ensurepip`:
3636

3737
On Windows:
3838
```
39-
$ <pythonscript_dir>/windows-64/python.exe -m ensurepip # Only need to do that once
40-
$ <pythonscript_dir>/windows-64/python.exe -m pip install whatever
39+
$ <godot_python_dir>/windows-64/python.exe -m ensurepip # Only need to do that once
40+
$ <godot_python_dir>/windows-64/python.exe -m pip install whatever
4141
```
4242

4343
On Linux/macOS:
4444
```
45-
$ <pythonscript_dir>/x11-64/bin/python3 -m ensurepip # Only need to do that once
46-
$ <pythonscript_dir>/x11-64/bin/python3 -m pip install whatever
45+
$ <godot_python_dir>/x11-64/bin/python3 -m ensurepip # Only need to do that once
46+
$ <godot_python_dir>/x11-64/bin/python3 -m pip install whatever
4747
```
4848

4949
Note you must use `python -m pip` to invoke pip (using the command `pip`

misc/release_gdpy.gdextension

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[configuration]
2+
3+
entry_symbol = "gdpy_init"
4+
compatibility_minimum = "4.1"
5+
6+
[libraries]
7+
8+
linux.64="res://addons/gdpy/linux-x86_64/libgdpy.so"
9+
linux.32="res://addons/gdpy/linux-x86/libgdpy.so"
10+
windows.64="res://addons/gdpy/windows-x86_64/gdpy.dll"
11+
windows.32="res://addons/gdpy/windows-x86/gdpy.dll"
12+
macos.64="res://addons/gdpy/macos-x86_64/libgdpy.dylib"

misc/release_pythonscript.gdextension

Lines changed: 0 additions & 12 deletions
This file was deleted.

scripts/assetlib_release.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
import argparse
1414
import tarfile
1515
from datetime import datetime
16-
import os
17-
import shutil
18-
from urllib.request import urlretrieve
1916
from zipfile import ZipFile
2017
from concurrent.futures import ThreadPoolExecutor
2118

@@ -61,24 +58,20 @@ def pipeline_executor(dirs, release_info, platform_name):
6158
with urlopen(platform_info["url"]) as f:
6259
release_archive.write_bytes(f.read())
6360

64-
if not (dirs["pythonscript"] / platform_name).exists():
61+
if not (dirs["gdpy"] / platform_name).exists():
6562
print(f"{platform_name} - Extracting release")
6663
if platform_info["name"].endswith(".zip"):
6764
zipobj = ZipFile(release_archive)
6865
# Only extract platform-specific stuff
6966
members = (
70-
x
71-
for x in zipobj.namelist()
72-
if x.startswith(f"addons/pythonscript/{platform_name}/")
67+
x for x in zipobj.namelist() if x.startswith(f"addons/gdpy/{platform_name}/")
7368
)
7469
zipobj.extractall(path=dirs["dist"], members=members)
7570

7671
elif platform_info["name"].endswith(".tar.bz2"):
7772
tarobj = tarfile.open(release_archive)
7873
# Only extract platform-specific stuff
79-
members = (
80-
x for x in tarobj if x.name.startswith(f"./addons/pythonscript/{platform_name}/")
81-
)
74+
members = (x for x in tarobj if x.name.startswith(f"./addons/gdpy/{platform_name}/"))
8275
tarobj.extractall(path=dirs["dist"], members=members)
8376

8477
else:
@@ -96,13 +89,11 @@ def orchestrator(dirs, release_info):
9689

9790
print("Add bonuses...")
9891

99-
(dirs["pythonscript"] / ".gdignore").touch()
92+
(dirs["gdpy"] / ".gdignore").touch()
10093
license_txt = (MISC_DIR / "release_LICENSE.txt").read_text()
101-
for entry in ["dist", "pythonscript"]:
94+
for entry in ["dist", "gdpy"]:
10295
(dirs[entry] / "LICENSE.txt").write_text(license_txt)
103-
(dirs["dist"] / "pythonscript.gdnlib").write_text(
104-
(MISC_DIR / "release_pythonscript.gdnlib").read_text()
105-
)
96+
(dirs["dist"] / "gdpy.gdnlib").write_text((MISC_DIR / "release_gdpy.gdnlib").read_text())
10697
(dirs["dist"] / "README.txt").write_text(
10798
(MISC_DIR / "release_README.txt")
10899
.read_text()
@@ -118,21 +109,21 @@ def main():
118109
release_info = get_release_info(args.version)
119110
print(f"Release version: {release_info['version']}")
120111

121-
build_dir = Path(f"pythonscript-assetlib-release-{release_info['version']}").resolve()
122-
dist_dir = build_dir / f"pythonscript-{release_info['version']}"
112+
build_dir = Path(f"gdpy-assetlib-release-{release_info['version']}").resolve()
113+
dist_dir = build_dir / f"gdpy-{release_info['version']}"
123114
addons_dir = dist_dir / "addons"
124-
pythonscript_dir = addons_dir / "pythonscript"
115+
gdpy_dir = addons_dir / "gdpy"
125116

126117
build_dir.mkdir(exist_ok=True)
127118
dist_dir.mkdir(exist_ok=True)
128119
addons_dir.mkdir(exist_ok=True)
129-
pythonscript_dir.mkdir(exist_ok=True)
120+
gdpy_dir.mkdir(exist_ok=True)
130121

131122
dirs = {
132123
"build": build_dir,
133124
"dist": dist_dir,
134125
"addons": addons_dir,
135-
"pythonscript": pythonscript_dir,
126+
"gdpy": gdpy_dir,
136127
}
137128
orchestrator(dirs, release_info)
138129

scripts/generate_tmpl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
GODOT_DIR = SRC_DIR / "godot"
1414
HAZMAT_DIR = GODOT_DIR / "hazmat"
1515
TARGETS: dict[str, tuple[bool, Path]] = {
16-
"pythonscript_gdextension_ptrs.c": (False, SRC_DIR),
16+
"gdpy_gdextension_ptrs.c": (False, SRC_DIR),
1717
"gdptrs.pxd": (False, HAZMAT_DIR),
1818
"gdtypes.pxd": (False, HAZMAT_DIR),
1919
"gdapi.pxd": (False, HAZMAT_DIR),

src/_gdpy_libgodot.pyx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ cdef GDExtensionObjectPtr _create_godot_instance(argv: list[str]):
7676
return libgodot_create_godot_instance(
7777
len(argv),
7878
c_argv,
79-
_pythonscript_init,
79+
_gdpy_init,
8080
NULL
8181
)
8282

@@ -89,35 +89,35 @@ cdef GDExtensionObjectPtr _create_godot_instance(argv: list[str]):
8989
#
9090

9191

92-
# Those symbols are defined in `pythonscript_gdextension_ptrs.c` which is
92+
# Those symbols are defined in `gdpy_gdextension_ptrs.c` which is
9393
# going to be compiled together with this file into a single shared library.
9494
cdef extern from *:
9595
"""
96-
void init_pythonscript_gdextension();
96+
void init_gdpy_gdextension();
9797
"""
9898

99-
const GDExtensionInterfaceGetProcAddress pythonscript_gdptr_get_proc_address
100-
const GDExtensionClassLibraryPtr pythonscript_gdptr_library
101-
void init_pythonscript_gdextension()
99+
const GDExtensionInterfaceGetProcAddress gdpy_gdptr_get_proc_address
100+
const GDExtensionClassLibraryPtr gdpy_gdptr_library
101+
void init_gdpy_gdextension()
102102

103103

104-
cdef GDExtensionBool _pythonscript_init(
104+
cdef GDExtensionBool _gdpy_init(
105105
GDExtensionInterfaceGetProcAddress p_get_proc_address,
106106
GDExtensionClassLibraryPtr p_library,
107107
GDExtensionInitialization *r_initialization
108108
) noexcept with gil:
109-
print('[libgodot] pythonscript_init()', flush=True)
109+
print('[libgodot] gdpy_init()', flush=True)
110110

111-
# `pythonscript_gdptr_*` must be set as early as possible given it is never
111+
# `gdpy_gdptr_*` must be set as early as possible given it is never
112112
# null-pointer checked, especially in the Cython modules.
113113
# Note we start by setting only `get_proc_address`&`library` since it is the
114114
# minimum we need to check Godot compatibility, and only after that we proceed
115115
# with the rest of the pointers.
116-
pythonscript_gdptr_get_proc_address = p_get_proc_address
117-
pythonscript_gdptr_library = p_library
116+
gdpy_gdptr_get_proc_address = p_get_proc_address
117+
gdpy_gdptr_library = p_library
118118

119-
# Initialize the rest of the `pythonscript_gdptr_*` pointers
120-
init_pythonscript_gdextension()
119+
# Initialize the rest of the `gdpy_gdptr_*` pointers
120+
init_gdpy_gdextension()
121121

122122
# Initialize as early as possible, this way we can have 3rd party plugins written
123123
# in Python/Cython that can do things at this level
@@ -131,13 +131,13 @@ cdef void _initialize(void *userdata, GDExtensionInitializationLevel p_level) no
131131
print(f'[libgodot] _initialize({p_level})', flush=True)
132132

133133
import godot._lang
134-
pythonscript_initialize = <void (*)(int)><size_t>godot._lang.pythonscript_initialize_function_ptr
135-
pythonscript_initialize(p_level);
134+
gdpy_initialize = <void (*)(int)><size_t>godot._lang.gdpy_initialize_function_ptr
135+
gdpy_initialize(p_level);
136136

137137

138138
cdef void _deinitialize(void *userdata, GDExtensionInitializationLevel p_level) noexcept with gil:
139139
print(f'[libgodot] _deinitialize({p_level})', flush=True)
140140

141141
import godot._lang
142-
pythonscript_deinitialize = <void (*)(int)><size_t>godot._lang.pythonscript_deinitialize_function_ptr
143-
pythonscript_deinitialize(p_level);
142+
gdpy_deinitialize = <void (*)(int)><size_t>godot._lang.gdpy_deinitialize_function_ptr
143+
gdpy_deinitialize(p_level);

0 commit comments

Comments
 (0)