diff --git a/.github/set_version.py b/.github/set_version.py index 5ad5cfd2..694e494f 100755 --- a/.github/set_version.py +++ b/.github/set_version.py @@ -22,6 +22,9 @@ def main(cargo_path_env_var='CARGO_PATH', version_env_vars=('VERSION', 'GITHUB_R print(f'✖ "{version_env_vars}" env variables not found') return 1 + # convert from python pre-release version to rust pre-release version + # this is the reverse of what's done in lib.rs::_rust_notify + version = version.replace('a', '-alpha').replace('b', '-beta') print(f'writing version "{version}", to {cargo_path}') version_regex = re.compile('^version ?= ?".*"', re.M) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d11be71d..d3b2ca60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,13 @@ jobs: - '3.8' - '3.9' - '3.10' -# - '3.11.0-alpha - 3.11' + - '3.11.0-alpha - 3.11' runs-on: ${{ matrix.os }}-latest env: PYTHON: ${{ matrix.python-version }} + RUST: ${{ matrix.rust-version }} OS: ${{ matrix.os }} steps: @@ -72,7 +73,7 @@ jobs: - uses: codecov/codecov-action@v1.0.13 with: file: ./coverage.xml - env_vars: PYTHON,OS + env_vars: PYTHON,RUST,OS lint: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 081e5db9..fcda9da1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,3 @@ docs/_build/ /site/ # i have a pet hate of the proliferation of files in the root directory .rustfmt.toml -# this file is added by `make build-dev` as a hack to make tests work without installing the package, -# it can't be permanent because it breaks tests in cibuildwheel -tests/__init__.py diff --git a/Makefile b/Makefile index 5212edd3..dccdce30 100644 --- a/Makefile +++ b/Makefile @@ -18,9 +18,6 @@ build-dev: cargo build @rm -f target/debug/lib_rust_notify.d @mv target/debug/lib_rust_notify.* watchfiles/_rust_notify.so - # this is a hack to make tests work without installing the package, it can't be permanent because it breaks - # tests in cibuildwheel - touch tests/__init__.py .PHONY: format format: diff --git a/src/lib.rs b/src/lib.rs index b777ccd2..6320ba31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -239,7 +239,14 @@ impl RustNotify { #[pymodule] fn _rust_notify(py: Python, m: &PyModule) -> PyResult<()> { - m.add("__version__", env!("CARGO_PKG_VERSION"))?; + let mut version = env!("CARGO_PKG_VERSION").to_string(); + // cargo uses "1.0-alpha1" etc. while python uses "1.0.0a1", this is not full compatibility, + // but it's good enough for now + // see https://docs.rs/semver/1.0.9/semver/struct.Version.html#method.parse for rust spec + // see https://peps.python.org/pep-0440/ for python spec + // it seems the dot after "alpha/beta" e.g. "-alpha.1" is not necessary, hence why this works + version = version.replace("-alpha", "a").replace("-beta", "b"); + m.add("__version__", version)?; m.add( "WatchfilesRustInternalError", py.get_type::(), diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b