chemomer 0.1.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.
- chemomer-0.1.0/.github/workflows/ci.yml +28 -0
- chemomer-0.1.0/.github/workflows/pypi.yml +71 -0
- chemomer-0.1.0/.gitignore +6 -0
- chemomer-0.1.0/Cargo.lock +186 -0
- chemomer-0.1.0/Cargo.toml +18 -0
- chemomer-0.1.0/LICENSE +21 -0
- chemomer-0.1.0/PKG-INFO +13 -0
- chemomer-0.1.0/README.md +37 -0
- chemomer-0.1.0/pyproject.toml +26 -0
- chemomer-0.1.0/scripts/smoke_py.py +40 -0
- chemomer-0.1.0/src/lib.rs +40 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-test:
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
|
14
|
+
python: ["3.10", "3.12"]
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v7
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python }}
|
|
21
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
22
|
+
- uses: Swatinem/rust-cache@v2
|
|
23
|
+
- run: pip install maturin
|
|
24
|
+
- run: maturin build --out dist
|
|
25
|
+
- run: pip install --no-index --find-links dist chemomer
|
|
26
|
+
- run: python scripts/smoke_py.py
|
|
27
|
+
- run: cargo fmt --check
|
|
28
|
+
- run: cargo clippy --locked --all-targets -- -D warnings
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# The Python binding (pyo3) — build, test, and the gated publish path.
|
|
2
|
+
#
|
|
3
|
+
# Dispatch-only: nothing runs on push or PR. A bare dispatch builds the
|
|
4
|
+
# wheel + sdist and runs the smoke test. Publishing is doubly gated —
|
|
5
|
+
# an explicit `publish` dispatch input AND the PyPI trusted-publisher
|
|
6
|
+
# registration for project "chemomer" with repository chemomer/chemomer-py,
|
|
7
|
+
# workflow pypi.yml, no environment.
|
|
8
|
+
|
|
9
|
+
name: PyPI
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
inputs:
|
|
14
|
+
publish:
|
|
15
|
+
description: "Publish to PyPI after the build passes"
|
|
16
|
+
required: false
|
|
17
|
+
default: false
|
|
18
|
+
type: boolean
|
|
19
|
+
version:
|
|
20
|
+
description: "Version to publish (must match pyproject.toml; required when publish=true)"
|
|
21
|
+
required: false
|
|
22
|
+
type: string
|
|
23
|
+
|
|
24
|
+
permissions:
|
|
25
|
+
contents: read
|
|
26
|
+
|
|
27
|
+
jobs:
|
|
28
|
+
build-test:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v7
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.12"
|
|
35
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
36
|
+
- uses: Swatinem/rust-cache@v2
|
|
37
|
+
- run: pip install maturin
|
|
38
|
+
- run: maturin build --out dist
|
|
39
|
+
- run: maturin sdist --out dist
|
|
40
|
+
- run: pip install --no-index --find-links dist chemomer
|
|
41
|
+
- run: python scripts/smoke_py.py
|
|
42
|
+
|
|
43
|
+
publish:
|
|
44
|
+
if: inputs.publish
|
|
45
|
+
needs: build-test
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
permissions:
|
|
48
|
+
contents: read
|
|
49
|
+
# PyPI trusted publishing (OIDC): the publish credential is the
|
|
50
|
+
# job's OIDC token — no stored secret.
|
|
51
|
+
id-token: write
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/checkout@v7
|
|
54
|
+
with:
|
|
55
|
+
persist-credentials: false
|
|
56
|
+
- name: Verify version matches input
|
|
57
|
+
run: |
|
|
58
|
+
actual=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
59
|
+
if [ "$actual" != "${{ inputs.version }}" ]; then
|
|
60
|
+
echo "Version mismatch: input=${{ inputs.version }}, pyproject.toml=$actual"
|
|
61
|
+
exit 1
|
|
62
|
+
fi
|
|
63
|
+
echo "Publishing $actual"
|
|
64
|
+
- uses: actions/setup-python@v5
|
|
65
|
+
with:
|
|
66
|
+
python-version: "3.12"
|
|
67
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
68
|
+
- run: pip install maturin
|
|
69
|
+
- run: maturin build --out dist
|
|
70
|
+
- run: maturin sdist --out dist
|
|
71
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "cfg-if"
|
|
13
|
+
version = "1.0.5"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "chemomer"
|
|
19
|
+
version = "0.1.0"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"chemomer 0.1.0 (git+https://github.com/chemomer/chemomer)",
|
|
22
|
+
"pyo3",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[[package]]
|
|
26
|
+
name = "chemomer"
|
|
27
|
+
version = "0.1.0"
|
|
28
|
+
source = "git+https://github.com/chemomer/chemomer#dd77e81b531285666dd369a7f5853fbb15a9566e"
|
|
29
|
+
|
|
30
|
+
[[package]]
|
|
31
|
+
name = "heck"
|
|
32
|
+
version = "0.5.0"
|
|
33
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
34
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "indoc"
|
|
38
|
+
version = "2.0.8"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
|
|
41
|
+
dependencies = [
|
|
42
|
+
"rustversion",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "libc"
|
|
47
|
+
version = "0.2.191"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "memoffset"
|
|
53
|
+
version = "0.9.1"
|
|
54
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
55
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
56
|
+
dependencies = [
|
|
57
|
+
"autocfg",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "once_cell"
|
|
62
|
+
version = "1.21.4"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "portable-atomic"
|
|
68
|
+
version = "1.15.0"
|
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
71
|
+
|
|
72
|
+
[[package]]
|
|
73
|
+
name = "proc-macro2"
|
|
74
|
+
version = "1.0.107"
|
|
75
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
76
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
77
|
+
dependencies = [
|
|
78
|
+
"unicode-ident",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
[[package]]
|
|
82
|
+
name = "pyo3"
|
|
83
|
+
version = "0.22.6"
|
|
84
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
85
|
+
checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
|
|
86
|
+
dependencies = [
|
|
87
|
+
"cfg-if",
|
|
88
|
+
"indoc",
|
|
89
|
+
"libc",
|
|
90
|
+
"memoffset",
|
|
91
|
+
"once_cell",
|
|
92
|
+
"portable-atomic",
|
|
93
|
+
"pyo3-build-config",
|
|
94
|
+
"pyo3-ffi",
|
|
95
|
+
"pyo3-macros",
|
|
96
|
+
"unindent",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
[[package]]
|
|
100
|
+
name = "pyo3-build-config"
|
|
101
|
+
version = "0.22.6"
|
|
102
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
103
|
+
checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
|
|
104
|
+
dependencies = [
|
|
105
|
+
"once_cell",
|
|
106
|
+
"target-lexicon",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[[package]]
|
|
110
|
+
name = "pyo3-ffi"
|
|
111
|
+
version = "0.22.6"
|
|
112
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
113
|
+
checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
|
|
114
|
+
dependencies = [
|
|
115
|
+
"libc",
|
|
116
|
+
"pyo3-build-config",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[[package]]
|
|
120
|
+
name = "pyo3-macros"
|
|
121
|
+
version = "0.22.6"
|
|
122
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
123
|
+
checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
|
|
124
|
+
dependencies = [
|
|
125
|
+
"proc-macro2",
|
|
126
|
+
"pyo3-macros-backend",
|
|
127
|
+
"quote",
|
|
128
|
+
"syn",
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
[[package]]
|
|
132
|
+
name = "pyo3-macros-backend"
|
|
133
|
+
version = "0.22.6"
|
|
134
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
135
|
+
checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
|
|
136
|
+
dependencies = [
|
|
137
|
+
"heck",
|
|
138
|
+
"proc-macro2",
|
|
139
|
+
"pyo3-build-config",
|
|
140
|
+
"quote",
|
|
141
|
+
"syn",
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
[[package]]
|
|
145
|
+
name = "quote"
|
|
146
|
+
version = "1.0.47"
|
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
148
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
149
|
+
dependencies = [
|
|
150
|
+
"proc-macro2",
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
[[package]]
|
|
154
|
+
name = "rustversion"
|
|
155
|
+
version = "1.0.23"
|
|
156
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
|
+
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
|
158
|
+
|
|
159
|
+
[[package]]
|
|
160
|
+
name = "syn"
|
|
161
|
+
version = "2.0.119"
|
|
162
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
163
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
164
|
+
dependencies = [
|
|
165
|
+
"proc-macro2",
|
|
166
|
+
"quote",
|
|
167
|
+
"unicode-ident",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "target-lexicon"
|
|
172
|
+
version = "0.12.16"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "unicode-ident"
|
|
178
|
+
version = "1.0.27"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
181
|
+
|
|
182
|
+
[[package]]
|
|
183
|
+
name = "unindent"
|
|
184
|
+
version = "0.2.4"
|
|
185
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
186
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "chemomer"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Native Rust InChI engine — molfile in, identifier / AuxInfo / InChIKey out (the Python binding)"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
repository = "https://github.com/chemomer/chemomer-py"
|
|
8
|
+
publish = false
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
|
|
11
|
+
[lib]
|
|
12
|
+
crate-type = ["cdylib", "rlib"]
|
|
13
|
+
|
|
14
|
+
[dependencies]
|
|
15
|
+
# The engine, by its crate name, renamed: this crate is the `chemomer`
|
|
16
|
+
# Python module, so the engine lands as `chemomer_engine` here.
|
|
17
|
+
chemomer_engine = { package = "chemomer", git = "https://github.com/chemomer/chemomer" }
|
|
18
|
+
pyo3 = "0.22"
|
chemomer-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AsciiChem contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
chemomer-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chemomer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Summary: Native Rust InChI engine — molfile in, identifier / AuxInfo / InChIKey out (the Python binding)
|
|
9
|
+
Keywords: inchi,inchikey,chemistry,cheminformatics
|
|
10
|
+
License: MIT
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Project-URL: Engine, https://github.com/chemomer/chemomer
|
|
13
|
+
Project-URL: Repository, https://github.com/chemomer/chemomer-py
|
chemomer-0.1.0/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# chemomer-py
|
|
2
|
+
|
|
3
|
+
The **Python binding for the [chemomer](https://github.com/chemomer/chemomer)
|
|
4
|
+
engine** — a native extension module built with
|
|
5
|
+
[PyO3](https://github.com/PyO3/pyo3) + [maturin](https://github.com/PyO3/maturin).
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import chemomer
|
|
9
|
+
|
|
10
|
+
inchi, inchikey = chemomer.from_molfile(molfile_text)
|
|
11
|
+
aux = chemomer.aux_from_molfile(molfile_text)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
A thin wrapper by design: the engine (the byte-exact InChI port, gated
|
|
15
|
+
by the shared oracle corpus) lives in the chemomer repo and lands here
|
|
16
|
+
as a Cargo git dependency; this repo owns only the pyo3 surface and
|
|
17
|
+
the packaging.
|
|
18
|
+
|
|
19
|
+
## Build and test
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install maturin
|
|
23
|
+
maturin develop --release
|
|
24
|
+
python scripts/smoke_py.py
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Publishing
|
|
28
|
+
|
|
29
|
+
`pypi.yml` is dispatch-only and doubly gated (`publish` input + the
|
|
30
|
+
PyPI trusted-publisher registration for project `chemomer` with
|
|
31
|
+
repository `chemomer/chemomer-py`, workflow `pypi.yml`, no
|
|
32
|
+
environment) — the publish credential is the job's OIDC token; no
|
|
33
|
+
stored secrets.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT, same as the engine.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.7,<2"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "chemomer"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Native Rust InChI engine — molfile in, identifier / AuxInfo / InChIKey out (the Python binding)"
|
|
9
|
+
license = { text = "MIT" }
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
keywords = ["inchi", "inchikey", "chemistry", "cheminformatics"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Programming Language :: Rust",
|
|
14
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
15
|
+
"Topic :: Scientific/Engineering :: Chemistry",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Repository = "https://github.com/chemomer/chemomer-py"
|
|
20
|
+
Engine = "https://github.com/chemomer/chemomer"
|
|
21
|
+
|
|
22
|
+
[tool.maturin]
|
|
23
|
+
# The extension-module side of pyo3: the wheel never links libpython
|
|
24
|
+
# (the interpreter supplies it), so the artifact stays portable.
|
|
25
|
+
features = ["pyo3/extension-module"]
|
|
26
|
+
module-name = "chemomer"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""The chemomer-py smoke test: a V2000 molfile in, the water identity
|
|
2
|
+
out — run against the built extension module (maturin develop, or a
|
|
3
|
+
wheel installed from dist/)."""
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
import chemomer
|
|
8
|
+
|
|
9
|
+
WATER = "\n".join(
|
|
10
|
+
[
|
|
11
|
+
"water",
|
|
12
|
+
" AsciiChem",
|
|
13
|
+
"",
|
|
14
|
+
" 1 0 0 0 0 0 0 0 0 0999 V2000",
|
|
15
|
+
" 12.0000 12.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0",
|
|
16
|
+
"M END",
|
|
17
|
+
"",
|
|
18
|
+
]
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
inchi, key = chemomer.from_molfile(WATER)
|
|
22
|
+
aux = chemomer.aux_from_molfile(WATER)
|
|
23
|
+
|
|
24
|
+
failures = []
|
|
25
|
+
if inchi != "InChI=1S/H2O/h1H2":
|
|
26
|
+
failures.append(f"identifier: got {inchi!r}")
|
|
27
|
+
if aux != "AuxInfo=1/0/N:1/rA:1nO/rB:/rC:12,12,0;":
|
|
28
|
+
failures.append(f"aux: got {aux!r}")
|
|
29
|
+
if key != "XLYOFNOQVPJJNP-UHFFFAOYSA-N":
|
|
30
|
+
failures.append(f"key: got {key!r}")
|
|
31
|
+
if failures:
|
|
32
|
+
print("chemomer-py smoke test FAILED:", file=sys.stderr)
|
|
33
|
+
for failure in failures:
|
|
34
|
+
print(f" {failure}", file=sys.stderr)
|
|
35
|
+
sys.exit(1)
|
|
36
|
+
|
|
37
|
+
print(f"identifier {inchi}")
|
|
38
|
+
print(f"aux {aux}")
|
|
39
|
+
print(f"key {key}")
|
|
40
|
+
print("chemomer-py smoke test passed")
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//! The Python binding for the chemomer engine: the native extension
|
|
2
|
+
//! module `chemomer` with `from_molfile(molfile) -> (inchi, inchikey)`
|
|
3
|
+
//! and `aux_from_molfile(molfile) -> aux`.
|
|
4
|
+
//!
|
|
5
|
+
//! A thin wrapper — the engine lives in chemomer/chemomer (the git
|
|
6
|
+
//! dependency, renamed `chemomer_engine` because this crate is the
|
|
7
|
+
//! `chemomer` module); this crate owns only the pyo3 surface.
|
|
8
|
+
|
|
9
|
+
// The `#[pyfunction]` wrapper's return conversion reads as an identity
|
|
10
|
+
// `PyErr` conversion to the current clippy (pyo3 0.22 macro output) —
|
|
11
|
+
// silenced here: macro-generated code outside this module's control.
|
|
12
|
+
#![allow(clippy::useless_conversion)]
|
|
13
|
+
|
|
14
|
+
use chemomer_engine::Engine;
|
|
15
|
+
use pyo3::exceptions::PyValueError;
|
|
16
|
+
use pyo3::prelude::*;
|
|
17
|
+
|
|
18
|
+
/// Derives `(inchi, inchikey)` from a V2000 molfile.
|
|
19
|
+
#[pyfunction]
|
|
20
|
+
fn from_molfile(molfile: &str) -> PyResult<(String, String)> {
|
|
21
|
+
Engine::from_molfile(molfile)
|
|
22
|
+
.and_then(|engine| engine.inchi_string().map(|inchi| (engine, inchi)))
|
|
23
|
+
.and_then(|(engine, inchi)| engine.inchikey().map(|inchikey| (inchi, inchikey)))
|
|
24
|
+
.map_err(|error| PyValueError::new_err(error.message().to_string()))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// Derives the AuxInfo line from a V2000 molfile.
|
|
28
|
+
#[pyfunction]
|
|
29
|
+
fn aux_from_molfile(molfile: &str) -> PyResult<String> {
|
|
30
|
+
Engine::from_molfile(molfile)
|
|
31
|
+
.and_then(|engine| engine.aux_string())
|
|
32
|
+
.map_err(|error| PyValueError::new_err(error.message().to_string()))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[pymodule]
|
|
36
|
+
fn chemomer(module: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
37
|
+
module.add_function(wrap_pyfunction!(from_molfile, module)?)?;
|
|
38
|
+
module.add_function(wrap_pyfunction!(aux_from_molfile, module)?)?;
|
|
39
|
+
Ok(())
|
|
40
|
+
}
|