physfs.py 0.0.2__tar.gz → 0.2.0__tar.gz
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.
- physfs_py-0.2.0/PKG-INFO +73 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/README.md +2 -3
- physfs_py-0.2.0/physfs.py.egg-info/PKG-INFO +73 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/physfs.py.egg-info/SOURCES.txt +0 -3
- physfs_py-0.2.0/setup.py +142 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/tests/test.py +3 -2
- physfs.py-0.0.2/PKG-INFO +0 -10
- physfs.py-0.0.2/physfs.py.egg-info/PKG-INFO +0 -10
- physfs.py-0.0.2/setup.py +0 -120
- physfs.py-0.0.2/src/main.cpp +0 -20
- physfs.py-0.0.2/src/shim.cpp +0 -222
- {physfs.py-0.0.2 → physfs_py-0.2.0}/LICENSE +0 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/physfs.py.egg-info/dependency_links.txt +0 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/physfs.py.egg-info/not-zip-safe +0 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/physfs.py.egg-info/requires.txt +0 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/physfs.py.egg-info/top_level.txt +0 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/pyproject.toml +0 -0
- {physfs.py-0.0.2 → physfs_py-0.2.0}/setup.cfg +0 -0
physfs_py-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: physfs.py
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
5
|
+
Home-page: https://github.com/shabbywu/physfs.py
|
|
6
|
+
Author: shabbywu
|
|
7
|
+
Author-email: shabbywu@qq.com
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest; extra == "test"
|
|
13
|
+
|
|
14
|
+
PhysFS.py
|
|
15
|
+
==============
|
|
16
|
+
|
|
17
|
+
![github-stars][stars-badge]
|
|
18
|
+
|
|
19
|
+
| CI | status |
|
|
20
|
+
|----------------------|--------|
|
|
21
|
+
| Linux/macOS Travis | [![Travis-CI][travis-badge]][travis-link] |
|
|
22
|
+
| MSVC 2019 | [![AppVeyor][appveyor-badge]][appveyor-link] |
|
|
23
|
+
| pip builds | [![Pip Actions Status][actions-pip-badge]][actions-pip-link] |
|
|
24
|
+
| [`cibuildwheel`][] | [![Wheels Actions Status][actions-wheels-badge]][actions-wheels-link] |
|
|
25
|
+
|
|
26
|
+
[gitter-badge]: https://badges.gitter.im/pybind/Lobby.svg
|
|
27
|
+
[stars-badge]: https://img.shields.io/github/stars/shabbywu/physfs.py?style=social
|
|
28
|
+
[actions-badge]: https://github.com/shabbywu/physfs.py/workflows/Tests/badge.svg
|
|
29
|
+
[actions-pip-link]: https://github.com/shabbywu/physfs.py/actions?query=workflow%3A%22Pip
|
|
30
|
+
[actions-pip-badge]: https://github.com/shabbywu/physfs.py/workflows/Pip/badge.svg
|
|
31
|
+
[actions-wheels-link]: https://github.com/shabbywu/physfs.py/actions?query=workflow%3AWheels
|
|
32
|
+
[actions-wheels-badge]: https://github.com/shabbywu/physfs.py/workflows/Wheels/badge.svg
|
|
33
|
+
[travis-link]: https://travis-ci.org/shabbywu/physfs.py
|
|
34
|
+
[travis-badge]: https://travis-ci.org/shabbywu/physfs.py.svg?branch=master&status=passed
|
|
35
|
+
[appveyor-link]: https://ci.appveyor.com/project/shabbywu/physfs.py
|
|
36
|
+
<!-- TODO: get a real badge link for appveyor -->
|
|
37
|
+
[appveyor-badge]: https://travis-ci.org/shabbywu/physfs.py.svg?branch=master&status=passed
|
|
38
|
+
[`cibuildwheel`]: https://cibuildwheel.readthedocs.io
|
|
39
|
+
|
|
40
|
+
PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
41
|
+
|
|
42
|
+
Installation
|
|
43
|
+
------------
|
|
44
|
+
|
|
45
|
+
- `pip install physfs.py`
|
|
46
|
+
|
|
47
|
+
Requirements
|
|
48
|
+
------------
|
|
49
|
+
CMake for building, and, of course, the PhysicsFS library.
|
|
50
|
+
|
|
51
|
+
Features
|
|
52
|
+
------------
|
|
53
|
+
physfs.py provides an encapsulation of the basic interface of PhysFS, including `init`, `deinit`, `mount`, `mount_memory`, `unmount`, `ls`, `read(cat)`, `stat`.
|
|
54
|
+
|
|
55
|
+
Enables python to use PhysFS at a minimum.
|
|
56
|
+
|
|
57
|
+
License
|
|
58
|
+
-------
|
|
59
|
+
|
|
60
|
+
pybind11 is provided under a BSD-style license that can be found in the LICENSE
|
|
61
|
+
file. By using, distributing, or contributing to this project, you agree to the
|
|
62
|
+
terms and conditions of this license.
|
|
63
|
+
|
|
64
|
+
Test call
|
|
65
|
+
---------
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import physfs
|
|
69
|
+
physfs.init()
|
|
70
|
+
|
|
71
|
+
physfs.mount("./example.zip")
|
|
72
|
+
physfs.ls()
|
|
73
|
+
```
|
|
@@ -29,8 +29,7 @@ PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
|
29
29
|
Installation
|
|
30
30
|
------------
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
- `pip install ./physfs.py`
|
|
32
|
+
- `pip install physfs.py`
|
|
34
33
|
|
|
35
34
|
Requirements
|
|
36
35
|
------------
|
|
@@ -38,7 +37,7 @@ CMake for building, and, of course, the PhysicsFS library.
|
|
|
38
37
|
|
|
39
38
|
Features
|
|
40
39
|
------------
|
|
41
|
-
physfs.py provides an encapsulation of the basic interface of PhysFS, including `init`, `deinit`, `mount`, `unmount`, `ls`, `read(cat)`, `stat`.
|
|
40
|
+
physfs.py provides an encapsulation of the basic interface of PhysFS, including `init`, `deinit`, `mount`, `mount_memory`, `unmount`, `ls`, `read(cat)`, `stat`.
|
|
42
41
|
|
|
43
42
|
Enables python to use PhysFS at a minimum.
|
|
44
43
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: physfs.py
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
5
|
+
Home-page: https://github.com/shabbywu/physfs.py
|
|
6
|
+
Author: shabbywu
|
|
7
|
+
Author-email: shabbywu@qq.com
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest; extra == "test"
|
|
13
|
+
|
|
14
|
+
PhysFS.py
|
|
15
|
+
==============
|
|
16
|
+
|
|
17
|
+
![github-stars][stars-badge]
|
|
18
|
+
|
|
19
|
+
| CI | status |
|
|
20
|
+
|----------------------|--------|
|
|
21
|
+
| Linux/macOS Travis | [![Travis-CI][travis-badge]][travis-link] |
|
|
22
|
+
| MSVC 2019 | [![AppVeyor][appveyor-badge]][appveyor-link] |
|
|
23
|
+
| pip builds | [![Pip Actions Status][actions-pip-badge]][actions-pip-link] |
|
|
24
|
+
| [`cibuildwheel`][] | [![Wheels Actions Status][actions-wheels-badge]][actions-wheels-link] |
|
|
25
|
+
|
|
26
|
+
[gitter-badge]: https://badges.gitter.im/pybind/Lobby.svg
|
|
27
|
+
[stars-badge]: https://img.shields.io/github/stars/shabbywu/physfs.py?style=social
|
|
28
|
+
[actions-badge]: https://github.com/shabbywu/physfs.py/workflows/Tests/badge.svg
|
|
29
|
+
[actions-pip-link]: https://github.com/shabbywu/physfs.py/actions?query=workflow%3A%22Pip
|
|
30
|
+
[actions-pip-badge]: https://github.com/shabbywu/physfs.py/workflows/Pip/badge.svg
|
|
31
|
+
[actions-wheels-link]: https://github.com/shabbywu/physfs.py/actions?query=workflow%3AWheels
|
|
32
|
+
[actions-wheels-badge]: https://github.com/shabbywu/physfs.py/workflows/Wheels/badge.svg
|
|
33
|
+
[travis-link]: https://travis-ci.org/shabbywu/physfs.py
|
|
34
|
+
[travis-badge]: https://travis-ci.org/shabbywu/physfs.py.svg?branch=master&status=passed
|
|
35
|
+
[appveyor-link]: https://ci.appveyor.com/project/shabbywu/physfs.py
|
|
36
|
+
<!-- TODO: get a real badge link for appveyor -->
|
|
37
|
+
[appveyor-badge]: https://travis-ci.org/shabbywu/physfs.py.svg?branch=master&status=passed
|
|
38
|
+
[`cibuildwheel`]: https://cibuildwheel.readthedocs.io
|
|
39
|
+
|
|
40
|
+
PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
41
|
+
|
|
42
|
+
Installation
|
|
43
|
+
------------
|
|
44
|
+
|
|
45
|
+
- `pip install physfs.py`
|
|
46
|
+
|
|
47
|
+
Requirements
|
|
48
|
+
------------
|
|
49
|
+
CMake for building, and, of course, the PhysicsFS library.
|
|
50
|
+
|
|
51
|
+
Features
|
|
52
|
+
------------
|
|
53
|
+
physfs.py provides an encapsulation of the basic interface of PhysFS, including `init`, `deinit`, `mount`, `mount_memory`, `unmount`, `ls`, `read(cat)`, `stat`.
|
|
54
|
+
|
|
55
|
+
Enables python to use PhysFS at a minimum.
|
|
56
|
+
|
|
57
|
+
License
|
|
58
|
+
-------
|
|
59
|
+
|
|
60
|
+
pybind11 is provided under a BSD-style license that can be found in the LICENSE
|
|
61
|
+
file. By using, distributing, or contributing to this project, you agree to the
|
|
62
|
+
terms and conditions of this license.
|
|
63
|
+
|
|
64
|
+
Test call
|
|
65
|
+
---------
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import physfs
|
|
69
|
+
physfs.init()
|
|
70
|
+
|
|
71
|
+
physfs.mount("./example.zip")
|
|
72
|
+
physfs.ls()
|
|
73
|
+
```
|
|
@@ -2,13 +2,10 @@ LICENSE
|
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
4
|
setup.py
|
|
5
|
-
libs/physfs
|
|
6
5
|
physfs.py.egg-info/PKG-INFO
|
|
7
6
|
physfs.py.egg-info/SOURCES.txt
|
|
8
7
|
physfs.py.egg-info/dependency_links.txt
|
|
9
8
|
physfs.py.egg-info/not-zip-safe
|
|
10
9
|
physfs.py.egg-info/requires.txt
|
|
11
10
|
physfs.py.egg-info/top_level.txt
|
|
12
|
-
src/main.cpp
|
|
13
|
-
src/shim.cpp
|
|
14
11
|
tests/test.py
|
physfs_py-0.2.0/setup.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
# Available at setup time due to pyproject.toml
|
|
8
|
+
from setuptools import Extension, setup
|
|
9
|
+
from setuptools.command.build_ext import build_ext
|
|
10
|
+
|
|
11
|
+
__version__ = "0.2.0"
|
|
12
|
+
|
|
13
|
+
# Convert distutils Windows platform specifiers to CMake -A arguments
|
|
14
|
+
PLAT_TO_CMAKE = {
|
|
15
|
+
"win32": "Win32",
|
|
16
|
+
"win-amd64": "x64",
|
|
17
|
+
"win-arm32": "ARM",
|
|
18
|
+
"win-arm64": "ARM64",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# A CMakeExtension needs a sourcedir instead of a file list.
|
|
23
|
+
# The name must be the _single_ output extension from the CMake build.
|
|
24
|
+
# If you need multiple extensions, see scikit-build.
|
|
25
|
+
class CMakeExtension(Extension):
|
|
26
|
+
def __init__(self, name: str, sourcedir: str = "") -> None:
|
|
27
|
+
super().__init__(name, sources=[])
|
|
28
|
+
self.sourcedir = os.fspath(Path(sourcedir).resolve())
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class CMakeBuild(build_ext):
|
|
32
|
+
def build_extension(self, ext: CMakeExtension) -> None:
|
|
33
|
+
# Must be in this form due to bug in .resolve() only fixed in Python 3.10+
|
|
34
|
+
ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name)
|
|
35
|
+
extdir = ext_fullpath.parent.resolve()
|
|
36
|
+
|
|
37
|
+
# Using this requires trailing slash for auto-detection & inclusion of
|
|
38
|
+
# auxiliary "native" libs
|
|
39
|
+
|
|
40
|
+
debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug
|
|
41
|
+
cfg = "Debug" if debug else "Release"
|
|
42
|
+
|
|
43
|
+
# CMake lets you override the generator - we need to check this.
|
|
44
|
+
# Can be set with Conda-Build, for example.
|
|
45
|
+
cmake_generator = os.environ.get("CMAKE_GENERATOR", "")
|
|
46
|
+
|
|
47
|
+
cmake_args = [
|
|
48
|
+
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}",
|
|
49
|
+
f"-DPython_EXECUTABLE={sys.executable}",
|
|
50
|
+
f"-DPYTHON_EXECUTABLE={sys.executable}",
|
|
51
|
+
f"-DPython_ROOT_DIR={os.path.dirname(sys.executable)}",
|
|
52
|
+
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
|
|
53
|
+
]
|
|
54
|
+
build_args = []
|
|
55
|
+
# Adding CMake arguments set as environment variable
|
|
56
|
+
# (needed e.g. to build for ARM OSx on conda-forge)
|
|
57
|
+
if "CMAKE_ARGS" in os.environ:
|
|
58
|
+
cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item]
|
|
59
|
+
|
|
60
|
+
# In this example, we pass in the version to C++. You might not need to.
|
|
61
|
+
cmake_args += [f"-DVERSION_INFO={__version__}"]
|
|
62
|
+
|
|
63
|
+
if self.compiler.compiler_type != "msvc":
|
|
64
|
+
# Using Ninja-build since it a) is available as a wheel and b)
|
|
65
|
+
# multithreads automatically. MSVC would require all variables be
|
|
66
|
+
# exported for Ninja to pick it up, which is a little tricky to do.
|
|
67
|
+
# Users can override the generator with CMAKE_GENERATOR in CMake
|
|
68
|
+
# 3.15+.
|
|
69
|
+
if not cmake_generator or cmake_generator == "Ninja":
|
|
70
|
+
try:
|
|
71
|
+
import ninja
|
|
72
|
+
|
|
73
|
+
ninja_executable_path = Path(ninja.BIN_DIR) / "ninja"
|
|
74
|
+
cmake_args += [
|
|
75
|
+
"-GNinja",
|
|
76
|
+
f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}",
|
|
77
|
+
]
|
|
78
|
+
except ImportError:
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
else:
|
|
82
|
+
# Single config generators are handled "normally"
|
|
83
|
+
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})
|
|
84
|
+
|
|
85
|
+
# CMake allows an arch-in-generator style for backward compatibility
|
|
86
|
+
contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"})
|
|
87
|
+
|
|
88
|
+
# Specify the arch if using MSVC generator, but only if it doesn't
|
|
89
|
+
# contain a backward-compatibility arch spec already in the
|
|
90
|
+
# generator name.
|
|
91
|
+
if not single_config and not contains_arch:
|
|
92
|
+
cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]]
|
|
93
|
+
|
|
94
|
+
# Multi-config generators have a different way to specify configs
|
|
95
|
+
if not single_config:
|
|
96
|
+
cmake_args += [
|
|
97
|
+
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"
|
|
98
|
+
]
|
|
99
|
+
build_args += ["--config", cfg]
|
|
100
|
+
|
|
101
|
+
if sys.platform.startswith("darwin"):
|
|
102
|
+
# Cross-compile support for macOS - respect ARCHFLAGS if set
|
|
103
|
+
archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", ""))
|
|
104
|
+
if archs:
|
|
105
|
+
cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
|
|
106
|
+
|
|
107
|
+
# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
|
|
108
|
+
# across all generators.
|
|
109
|
+
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
|
|
110
|
+
# self.parallel is a Python 3 only way to set parallel jobs by hand
|
|
111
|
+
# using -j in the build_ext call, not supported by pip or PyPA-build.
|
|
112
|
+
if hasattr(self, "parallel") and self.parallel:
|
|
113
|
+
# CMake 3.12+ only.
|
|
114
|
+
build_args += [f"-j{self.parallel}"]
|
|
115
|
+
|
|
116
|
+
build_temp = Path(self.build_temp) / ext.name
|
|
117
|
+
if not build_temp.exists():
|
|
118
|
+
build_temp.mkdir(parents=True)
|
|
119
|
+
|
|
120
|
+
subprocess.run(
|
|
121
|
+
["cmake", ext.sourcedir, *cmake_args], cwd=build_temp, check=True
|
|
122
|
+
)
|
|
123
|
+
subprocess.run(
|
|
124
|
+
["cmake", "--build", ".", *build_args], cwd=build_temp, check=True
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
setup(
|
|
129
|
+
name="physfs.py",
|
|
130
|
+
version=__version__,
|
|
131
|
+
author="shabbywu",
|
|
132
|
+
author_email="shabbywu@qq.com",
|
|
133
|
+
url="https://github.com/shabbywu/physfs.py",
|
|
134
|
+
description="PhysFS.py is a python wrapper for the PhysicsFS library.",
|
|
135
|
+
long_description=(Path(__file__).parent / "./README.md").read_text(),
|
|
136
|
+
long_description_content_type="text/markdown",
|
|
137
|
+
ext_modules=[CMakeExtension("physfs")],
|
|
138
|
+
cmdclass={"build_ext": CMakeBuild},
|
|
139
|
+
extras_require={"test": "pytest"},
|
|
140
|
+
zip_safe=False,
|
|
141
|
+
python_requires=">=3.7",
|
|
142
|
+
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
+
|
|
2
3
|
import physfs
|
|
3
4
|
|
|
4
5
|
rootdir = Path(__file__).parent
|
|
5
|
-
assert physfs.__version__ == '0.0
|
|
6
|
+
assert physfs.__version__ == '0.2.0'
|
|
6
7
|
|
|
7
8
|
physfs.init()
|
|
8
9
|
assert physfs.ls("/") == []
|
|
@@ -19,6 +20,6 @@ physfs.deinit()
|
|
|
19
20
|
E = None
|
|
20
21
|
try:
|
|
21
22
|
physfs.ls()
|
|
22
|
-
except
|
|
23
|
+
except physfs.PhysfsUninitialedError as e:
|
|
23
24
|
E = e
|
|
24
25
|
assert E is not None
|
physfs.py-0.0.2/PKG-INFO
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: physfs.py
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
5
|
-
Home-page: https://github.com/shabbywu/physfs.py
|
|
6
|
-
Author: shabbywu
|
|
7
|
-
Author-email: shabbywu@qq.com
|
|
8
|
-
Requires-Python: >=3.7
|
|
9
|
-
Provides-Extra: test
|
|
10
|
-
License-File: LICENSE
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: physfs.py
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: PhysFS.py is a python wrapper for the PhysicsFS library.
|
|
5
|
-
Home-page: https://github.com/shabbywu/physfs.py
|
|
6
|
-
Author: shabbywu
|
|
7
|
-
Author-email: shabbywu@qq.com
|
|
8
|
-
Requires-Python: >=3.7
|
|
9
|
-
Provides-Extra: test
|
|
10
|
-
License-File: LICENSE
|
physfs.py-0.0.2/setup.py
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
# Available at setup time due to pyproject.toml
|
|
2
|
-
import platform
|
|
3
|
-
import os
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from glob import glob
|
|
6
|
-
from distutils import log
|
|
7
|
-
|
|
8
|
-
# Available at setup time due to pyproject.toml
|
|
9
|
-
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
|
10
|
-
from setuptools.command.build_clib import build_clib as _build_clib
|
|
11
|
-
from setuptools import setup, Extension
|
|
12
|
-
from setuptools.extension import Library
|
|
13
|
-
|
|
14
|
-
__version__ = "0.0.2"
|
|
15
|
-
IS_WINDOWS = platform.system() == "Windows"
|
|
16
|
-
IS_MACOS = platform.system() == "Darwin"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ext_libraries = [
|
|
20
|
-
[
|
|
21
|
-
"physfs",
|
|
22
|
-
{
|
|
23
|
-
"sources": ["libs/physfs"],
|
|
24
|
-
"type": "cmake",
|
|
25
|
-
"cmake_args": [
|
|
26
|
-
# disable build shared library for macos and linux
|
|
27
|
-
"-DPHYSFS_BUILD_SHARED=false"
|
|
28
|
-
if not IS_WINDOWS else
|
|
29
|
-
# disable build static library for windows(before something wrong in windows)
|
|
30
|
-
"-DPHYSFS_BUILD_STATIC=false",
|
|
31
|
-
# disable build test
|
|
32
|
-
"-DPHYSFS_BUILD_TEST=false",
|
|
33
|
-
# disable build docs
|
|
34
|
-
"-DPHYSFS_BUILD_DOCS=false",
|
|
35
|
-
# set -fPIC
|
|
36
|
-
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
|
|
37
|
-
],
|
|
38
|
-
"copy_objects": [] if not IS_WINDOWS else ["physfs.dll"]
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
extra_link_args = []
|
|
45
|
-
if IS_MACOS:
|
|
46
|
-
extra_link_args = ["-framework", "IOKit", "-framework", "Foundation"]
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ext_modules = [
|
|
50
|
-
Pybind11Extension("physfs",
|
|
51
|
-
["src/main.cpp", "src/shim.cpp"],
|
|
52
|
-
# Example: passing in the version to the compiled code
|
|
53
|
-
define_macros = [('VERSION_INFO', __version__)],
|
|
54
|
-
include_dirs=["libs/physfs/src"],
|
|
55
|
-
extra_link_args=extra_link_args,
|
|
56
|
-
),
|
|
57
|
-
]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class build_clib(_build_clib):
|
|
61
|
-
def build_libraries(self, libraries):
|
|
62
|
-
cwd = Path().absolute()
|
|
63
|
-
other_libraries = []
|
|
64
|
-
for (lib_name, build_info) in libraries:
|
|
65
|
-
if build_info.get("type") != "cmake":
|
|
66
|
-
libraries.append((lib_name, build_info))
|
|
67
|
-
continue
|
|
68
|
-
|
|
69
|
-
log.info("building '%s' library", lib_name)
|
|
70
|
-
src = Path(build_info["sources"][0]).absolute()
|
|
71
|
-
build_temp = (Path(self.build_temp) / lib_name).absolute()
|
|
72
|
-
build_temp.mkdir(parents=True, exist_ok=True)
|
|
73
|
-
config = 'Debug' if self.debug else 'Release'
|
|
74
|
-
build_dest = build_temp / config if IS_WINDOWS else build_temp
|
|
75
|
-
|
|
76
|
-
build_ext = self.get_finalized_command('build_ext')
|
|
77
|
-
build_lib = Path(build_ext.build_lib).absolute()
|
|
78
|
-
cmake_args = [
|
|
79
|
-
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + str(build_temp),
|
|
80
|
-
'-DCMAKE_BUILD_TYPE=' + config,
|
|
81
|
-
*build_info.get("cmake_args", [])
|
|
82
|
-
]
|
|
83
|
-
build_args = [
|
|
84
|
-
'--config', config,
|
|
85
|
-
"-v"
|
|
86
|
-
]
|
|
87
|
-
os.chdir(str(build_temp))
|
|
88
|
-
self.spawn(['cmake', str(src)] + cmake_args)
|
|
89
|
-
if not self.dry_run:
|
|
90
|
-
self.spawn(['cmake', '--build', '.'] + build_args)
|
|
91
|
-
# extend library_dirs
|
|
92
|
-
for ext in build_ext.extensions:
|
|
93
|
-
ext.library_dirs.append(str(build_dest))
|
|
94
|
-
# copy objects to dest
|
|
95
|
-
build_lib.mkdir(parents=True, exist_ok=True)
|
|
96
|
-
copy_objects = build_info.get("copy_objects")
|
|
97
|
-
if copy_objects:
|
|
98
|
-
for obj in copy_objects:
|
|
99
|
-
self.copy_file(str(build_dest / obj), str(build_lib / obj))
|
|
100
|
-
os.chdir(str(cwd))
|
|
101
|
-
return super().build_libraries(other_libraries)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
setup(
|
|
105
|
-
name="physfs.py",
|
|
106
|
-
version=__version__,
|
|
107
|
-
author="shabbywu",
|
|
108
|
-
author_email="shabbywu@qq.com",
|
|
109
|
-
url="https://github.com/shabbywu/physfs.py",
|
|
110
|
-
description="PhysFS.py is a python wrapper for the PhysicsFS library.",
|
|
111
|
-
long_description="",
|
|
112
|
-
ext_modules=ext_modules,
|
|
113
|
-
libraries=ext_libraries,
|
|
114
|
-
extras_require={"test": "pytest"},
|
|
115
|
-
# Currently, build_ext only provides an optional "highest supported C++
|
|
116
|
-
# level" feature, but in the future it may provide more features.
|
|
117
|
-
cmdclass={"build_ext": build_ext, "build_clib": build_clib},
|
|
118
|
-
zip_safe=False,
|
|
119
|
-
python_requires=">=3.7",
|
|
120
|
-
)
|
physfs.py-0.0.2/src/main.cpp
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#include <pybind11/pybind11.h>
|
|
2
|
-
#include "shim.h"
|
|
3
|
-
|
|
4
|
-
#define STRINGIFY(x) #x
|
|
5
|
-
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
namespace py = pybind11;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
PYBIND11_MODULE(physfs, m) {
|
|
12
|
-
register_physfs(m);
|
|
13
|
-
#ifdef VERSION_INFO
|
|
14
|
-
m.attr("__version__") = MACRO_STRINGIFY(VERSION_INFO);
|
|
15
|
-
#else
|
|
16
|
-
m.attr("__version__") = "dev";
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
m.attr("__author__") = "shabbywu<shabbywu@qq.com>";
|
|
20
|
-
}
|
physfs.py-0.0.2/src/shim.cpp
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
#include "shim.h"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
namespace py = pybind11;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
template<typename ... Args>
|
|
8
|
-
std::string string_format( const std::string& format, Args ... args )
|
|
9
|
-
{
|
|
10
|
-
int size_s = std::snprintf( nullptr, 0, format.c_str(), args ... ) + 1; // Extra space for '\0'
|
|
11
|
-
if( size_s <= 0 ){ throw std::runtime_error( "Error during formatting." ); }
|
|
12
|
-
auto size = static_cast<size_t>( size_s );
|
|
13
|
-
std::unique_ptr<char[]> buf( new char[ size ] );
|
|
14
|
-
std::snprintf( buf.get(), size, format.c_str(), args ... );
|
|
15
|
-
return std::string( buf.get(), buf.get() + size - 1 ); // We don't want the '\0' inside
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
void physfs_init() {
|
|
20
|
-
if (!PHYSFS_init(NULL)) {
|
|
21
|
-
throw std::runtime_error(string_format("Failure. Reason: [%s]", PHYSFS_getLastError()));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
void physfs_deinit() {
|
|
27
|
-
if (!PHYSFS_isInit()) {
|
|
28
|
-
throw std::runtime_error("PHYSFS is not initialized, please call init() first");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!PHYSFS_deinit()) {
|
|
32
|
-
throw std::runtime_error(string_format("Failure. Reason: [%s]", PHYSFS_getLastError()));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
void physfs_mount(std::string source, std::string mountPoint = "/", py::bool_ appendToPath = py::bool_(0)) {
|
|
38
|
-
if (!PHYSFS_isInit()) {
|
|
39
|
-
throw std::runtime_error("PHYSFS is not initialized, please call init() first");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (!PHYSFS_mount(source.c_str(), mountPoint.c_str(), appendToPath)) {
|
|
43
|
-
throw std::runtime_error(string_format("Failure. Reason: [%s]", PHYSFS_getLastError()));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
void physfs_unmount(std::string oldSource) {
|
|
49
|
-
if (!PHYSFS_isInit()) {
|
|
50
|
-
throw std::runtime_error("PHYSFS is not initialized, please call init() first");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!PHYSFS_unmount(oldSource.c_str())) {
|
|
54
|
-
throw std::runtime_error(string_format("Failure. Reason: [%s]", PHYSFS_getLastError()));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
py::list enumerate_fs(std::string dir) {
|
|
60
|
-
if (!PHYSFS_isInit()) {
|
|
61
|
-
throw std::runtime_error("PHYSFS is not initialized, please call init() first");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
char **rc;
|
|
65
|
-
rc = PHYSFS_enumerateFiles(dir.c_str());
|
|
66
|
-
|
|
67
|
-
py::list result;
|
|
68
|
-
char **i;
|
|
69
|
-
for (i = rc; *i != NULL; i++) {
|
|
70
|
-
result.append(std::string(*i));
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
PHYSFS_Stat physfs_stat(std::string file) {
|
|
76
|
-
if (!PHYSFS_isInit()) {
|
|
77
|
-
throw std::runtime_error("PHYSFS is not initialized, please call init() first");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
PHYSFS_Stat stat;
|
|
81
|
-
|
|
82
|
-
if(!PHYSFS_stat(file.c_str(), &stat))
|
|
83
|
-
{
|
|
84
|
-
throw std::runtime_error(string_format("failed to stat. Reason [%s]", PHYSFS_getLastError()));
|
|
85
|
-
}
|
|
86
|
-
return stat;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
py::bytes physfs_cat(std::string file) {
|
|
90
|
-
if (!PHYSFS_isInit()) {
|
|
91
|
-
throw std::runtime_error("PHYSFS is not initialized, please call init() first");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
PHYSFS_File *f;
|
|
95
|
-
f = PHYSFS_openRead(file.c_str());
|
|
96
|
-
if (f == NULL) {
|
|
97
|
-
throw std::runtime_error(string_format("failed to open. Reason: [%s]", PHYSFS_getLastError()));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
std::stringstream output;
|
|
101
|
-
while (1)
|
|
102
|
-
{
|
|
103
|
-
char buffer[1024];
|
|
104
|
-
PHYSFS_sint64 rc;
|
|
105
|
-
PHYSFS_sint64 i;
|
|
106
|
-
rc = PHYSFS_readBytes(f, buffer, sizeof (buffer));
|
|
107
|
-
if (rc == -1 ) {
|
|
108
|
-
PHYSFS_close(f);
|
|
109
|
-
throw std::runtime_error(string_format("Error condition in reading. Reason: [%s]", PHYSFS_getLastError()));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
output.write(buffer, rc);
|
|
113
|
-
if (rc < sizeof (buffer))
|
|
114
|
-
{
|
|
115
|
-
if (!PHYSFS_eof(f))
|
|
116
|
-
{
|
|
117
|
-
PHYSFS_close(f);
|
|
118
|
-
throw std::runtime_error(string_format("Error condition in reading. Reason: [%s]", PHYSFS_getLastError()));
|
|
119
|
-
}
|
|
120
|
-
PHYSFS_close(f);
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return py::bytes(output.str());
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
void register_physfs(py::module_ &m) {
|
|
129
|
-
m.doc() = R"pbdoc(
|
|
130
|
-
physfs - PhysicsFS is a library to provide abstract access to various archives.
|
|
131
|
-
-----------------------
|
|
132
|
-
|
|
133
|
-
.. currentmodule:: physfs
|
|
134
|
-
|
|
135
|
-
.. autosummary::
|
|
136
|
-
:toctree: _generate
|
|
137
|
-
|
|
138
|
-
init
|
|
139
|
-
)pbdoc";
|
|
140
|
-
|
|
141
|
-
m.def("init", &physfs_init, R"pbdoc(
|
|
142
|
-
Initialize the PhysicsFS library.
|
|
143
|
-
|
|
144
|
-
* This must be called before any other PhysicsFS function.
|
|
145
|
-
*
|
|
146
|
-
* This should be called prior to any attempts to change your process's
|
|
147
|
-
* current working directory.
|
|
148
|
-
|
|
149
|
-
)pbdoc");
|
|
150
|
-
|
|
151
|
-
m.def("deinit", &physfs_deinit, R"pbdoc(
|
|
152
|
-
Deinitialize the PhysicsFS library.
|
|
153
|
-
|
|
154
|
-
* This closes any files opened via PhysicsFS, blanks the search/write paths,
|
|
155
|
-
* frees memory, and invalidates all of your file handles.
|
|
156
|
-
*
|
|
157
|
-
* Note that this call can FAIL if there's a file open for writing that
|
|
158
|
-
* refuses to close (for example, the underlying operating system was
|
|
159
|
-
* buffering writes to network filesystem, and the fileserver has crashed,
|
|
160
|
-
* or a hard drive has failed, etc). It is usually best to close all write
|
|
161
|
-
* handles yourself before calling this function, so that you can gracefully
|
|
162
|
-
* handle a specific failure.
|
|
163
|
-
*
|
|
164
|
-
* Once successfully deinitialized, PHYSFS_init() can be called again to
|
|
165
|
-
* restart the subsystem. All default API states are restored at this
|
|
166
|
-
* point, with the exception of any custom allocator you might have
|
|
167
|
-
* specified, which survives between initializations.
|
|
168
|
-
|
|
169
|
-
)pbdoc");
|
|
170
|
-
|
|
171
|
-
m.def("mount", &physfs_mount, R"pbdoc(
|
|
172
|
-
Add an archive or directory to the search path.
|
|
173
|
-
|
|
174
|
-
* \param source directory or archive to add to the path, in
|
|
175
|
-
* platform-dependent notation.
|
|
176
|
-
* \param mountPoint Location in the interpolated tree that this archive
|
|
177
|
-
* will be "mounted", in platform-independent notation.
|
|
178
|
-
* NULL or "" is equivalent to "/".
|
|
179
|
-
* \param appendToPath nonzero to append to search path, zero to prepend.
|
|
180
|
-
)pbdoc", py::arg("source").none(false), py::arg("mountPoint") = "/", py::arg("appendToPath") = py::bool_(0));
|
|
181
|
-
|
|
182
|
-
m.def("unmount", &physfs_unmount, R"pbdoc(
|
|
183
|
-
Remove a directory or archive from the search path.
|
|
184
|
-
|
|
185
|
-
* This must be a (case-sensitive) match to a dir or archive already in the
|
|
186
|
-
* search path, specified in platform-dependent notation.
|
|
187
|
-
*
|
|
188
|
-
* This call will fail (and fail to remove from the path) if the element still
|
|
189
|
-
* has files open in it.
|
|
190
|
-
*
|
|
191
|
-
* \param oldSource dir/archive to remove.
|
|
192
|
-
|
|
193
|
-
)pbdoc", py::arg("oldSource").none(false));
|
|
194
|
-
|
|
195
|
-
m.def("ls", &enumerate_fs, R"pbdoc(
|
|
196
|
-
Get a file listing of a search path's directory.
|
|
197
|
-
)pbdoc", py::arg("dir") = "/");
|
|
198
|
-
|
|
199
|
-
m.def("stat", &physfs_stat, R"pbdoc(
|
|
200
|
-
Get various information about a directory or a file.
|
|
201
|
-
)pbdoc", py::arg("file").none(false));
|
|
202
|
-
|
|
203
|
-
m.def("cat", &physfs_cat, R"pbdoc(
|
|
204
|
-
Read bytes from a PhysicsFS filehandle
|
|
205
|
-
)pbdoc", py::arg("file").none(false));
|
|
206
|
-
|
|
207
|
-
m.def("read", &physfs_cat, R"pbdoc(
|
|
208
|
-
Read bytes from a PhysicsFS filehandle, read is alias of cat.
|
|
209
|
-
)pbdoc", py::arg("file").none(false));
|
|
210
|
-
|
|
211
|
-
py::class_<PHYSFS_Stat>(m, "PHYSFS_Stat")
|
|
212
|
-
.def_readwrite("filetype", &PHYSFS_Stat::filetype)
|
|
213
|
-
.def_readwrite("filesize", &PHYSFS_Stat::filesize)
|
|
214
|
-
;
|
|
215
|
-
|
|
216
|
-
py::enum_<PHYSFS_FileType>(m, "PHYSFS_FileType")
|
|
217
|
-
.value("PHYSFS_FILETYPE_REGULAR", PHYSFS_FileType::PHYSFS_FILETYPE_REGULAR)
|
|
218
|
-
.value("PHYSFS_FILETYPE_DIRECTORY", PHYSFS_FileType::PHYSFS_FILETYPE_DIRECTORY)
|
|
219
|
-
.value("PHYSFS_FILETYPE_SYMLINK", PHYSFS_FileType::PHYSFS_FILETYPE_SYMLINK)
|
|
220
|
-
.value("PHYSFS_FILETYPE_OTHER", PHYSFS_FileType::PHYSFS_FILETYPE_OTHER);
|
|
221
|
-
|
|
222
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|