Skip to content

Commit

Permalink
fix: missing main import
Browse files Browse the repository at this point in the history
Using a more recent maturin, and closer to what is documented as the
recommended structure for a mixed Python/Rust project
  • Loading branch information
michalc committed Oct 23, 2024
1 parent 447d83e commit 6962cfa
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
42 changes: 24 additions & 18 deletions .github/workflows/deploy-package-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: Deploy package to PyPI

# on:
# release:
# types: [published]

on:
release:
types: [published]
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-source:
Expand All @@ -11,9 +17,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Update version in pyproject.toml from current git tag
run: |
sed -i "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml
# - name: Update version in pyproject.toml from current git tag
# run: |
# sed -i "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml

- uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -51,9 +57,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Update version in pyproject.toml from current git tag
run: |
sed -i "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml
# - name: Update version in pyproject.toml from current git tag
# run: |
# sed -i "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -104,9 +110,9 @@ jobs:
with:
python-version: '${{ matrix.python-version }}'

- name: Update version in pyproject.toml from current git tag
run: |
sed -i "" "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml
# - name: Update version in pyproject.toml from current git tag
# run: |
# sed -i "" "s/0\\.0\\.0\\.dev0/${GITHUB_REF_NAME/v/}/g" pyproject.toml

- name: Build package
run: |
Expand Down Expand Up @@ -140,9 +146,9 @@ jobs:
with:
python-version: '${{ matrix.python-version }}'

- name: Update version in pyproject.toml from current git tag
run: |
(Get-Content pyproject.toml).Replace('0.0.0.dev0', ($Env:GITHUB_REF_NAME).Replace('v', '')) | Set-Content pyproject.toml
# - name: Update version in pyproject.toml from current git tag
# run: |
# (Get-Content pyproject.toml).Replace('0.0.0.dev0', ($Env:GITHUB_REF_NAME).Replace('v', '')) | Set-Content pyproject.toml

- name: Build package
run: |
Expand Down Expand Up @@ -182,7 +188,7 @@ jobs:
find ./dist -mindepth 2 -type f -exec mv -t ./dist -i '{}' +
rm -R -- ./dist/*/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: ./dist/
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages_dir: ./dist/
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "stream_unzip_zipcrypto_decrypt"
name = "_zipcrypto"
version = "0.1.0"
edition = "2021"

[lib]
name = "stream_unzip_zipcrypto_decrypt"
name = "_zipcrypto"
crate-type = ["cdylib"]

[dependencies]
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.12,<0.13"]
requires = ["maturin>=1.7.4,<2.0.0"]
build-backend = "maturin"

[project]
Expand Down Expand Up @@ -38,7 +38,5 @@ ci = [
"Source" = "https://github.com/uktrade/stream-unzip"

[tool.maturin]
include = [
"stream_unzip.py",
"src/**"
]
python-source = "python"
module-name = "stream_unzip._zipcrypto_decrypt"
2 changes: 1 addition & 1 deletion stream_unzip.py → python/stream_unzip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from stream_inflate import stream_inflate64

from stream_unzip_zipcrypto_decrypt import zipcrypto_decryptor
from ._zipcrypto import zipcrypto_decryptor


NO_ENCRYPTION = object()
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ impl StreamUnzipZipCryptoDecryptor {
}

#[pymodule]
fn stream_unzip_zipcrypto_decrypt(m: &Bound<'_, PyModule>) -> PyResult<()> {
#[pyo3(name="_zipcrypto")]
fn zipcrypto(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<StreamUnzipZipCryptoDecryptor>()?;
Ok(())
}

0 comments on commit 6962cfa

Please sign in to comment.