Skip to content

Commit

Permalink
tweak build-dev and CI (#159)
Browse files Browse the repository at this point in the history
* tweak build-dev and ci

* correctly set python and rust version numbers

* more details in version comment
  • Loading branch information
samuelcolvin authored Jun 3, 2022
1 parent 9bee15c commit f1b8649
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/set_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -72,7 +73,7 @@ jobs:
- uses: codecov/[email protected]
with:
file: ./coverage.xml
env_vars: PYTHON,OS
env_vars: PYTHON,RUST,OS

lint:
runs-on: ubuntu-latest
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<WatchfilesRustInternalError>(),
Expand Down
Empty file added tests/__init__.py
Empty file.

0 comments on commit f1b8649

Please sign in to comment.