[Numpy-discussion] ANN: APyTypes 0.1

2024-05-15 Thread Oscar Gustafsson
Dear all,

as a consequence of a discussion here
https://mail.python.org/archives/list/numpy-discussion@python.org/message/WANLFEYLKRSYSOIG4A4HFLFUHKF5EPZA/
we are now please to announce the first release of APyTypes - algorithmic
data types, both fixed- and floating-point, in Python. The library aims to
be a drop-in replacement for NumPy, but with the difference that you can
exactly specify the numerical format (and rounding mode). It is fair to say
that there is a bit of work left until that, but the scalar and array data
types and basic arithmetic operations are working.

The library can be installed using:

pip install apytypes

(please let us know if your platform is not supported).

For a comparison with other libraries see:
https://apytypes.github.io/apytypes/comparison.html (general documentation
at https://apytypes.github.io/ repo at https://github.com/apytypes/apytypes
). It should be noted that this is not a suitable replacement if you just
want to use a different, existing, dtype, e.g. from ml_dtypes, this is a
completely flexible solution for any dtype with complete control of
rounding/quantization, including stochastic quantization.

BR Oscar Gustafsson

(I will not post additional announcements here, but as this was an outcome
of a discussion on the mailing list, I thought it may be of interest to at
least some members.)
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Build NumPy with Debugging Symbols with Meson

2024-05-15 Thread Robert McLeod
Hi everyone,

Is there a gist or similar guide anywhere on the steps required to build
NumPy with debugging symbols on the Windows platform using the new Meson
build system? It seems a bit difficult because NumPy seems to expect a
`conda`-like file structure whereas if you are cloning `cpython` directly
it is different. In particular `cpython` puts all the Windows files under
the `PC` and `PCBuild` subdirectories. Also meson doesn't seem to have a
means to call `python_d.exe` directly which may be causing problems. I've
ended up building both `python.exe` and `python_d.exe` but run into some
problem finding Python in `meson.build`.

This describes my efforts to date:

# Build CPython with Debugging Symbols on Windows

```shell
git clone https://github.com/python/cpython.git
cd cpython
git switch 3.11
PCbuild\get_externals.bat
# Build the debug version `python_d.exe`
PCbuild\build.bat -e -d
# Meson calls `python.exe` and doesn't seem to have an argument to change
this.
# We could either build it, or create a symlink
PCbuild\build.bat
# ln -s PCbuild/amd64/python_d.exe PCbuild/amd64/python.exe
```

The built Python will then be located in
`/cpython/PCBuild/amd64/python_d.exe`.

```batch
set PREFIX=C:/Users/Robert/dev/cpython
set PATH=%PREFIX%;%PREFIX%/PCBuild/amd64;%PREFIX%/Scripts;%PATH%
```

Next we have to install pip:
https://docs.python.org/3/library/ensurepip.html,
meson, and cython.

```shell
python_d -m ensurepip
python_d -mpip install meson meson-python ninja cython
```

NOTE: produces `pip3.exe`, not `pip`.

# Build NumPy with debug Python

```shell
git clone https://github.com/numpy/numpy.git
cd numpy
git switch maintenance/1.26.x
git submodule update --init
```

https://mesonbuild.com/meson-python/how-to-guides/debug-builds.html

Next try and build with meson/ninja:

```shell
mkdir build-dbg
cd build-dbg
meson .. setup --buildtype=debug
--includedir=C:/Users/Robert/dev/cpython/PC
--libdir=C:/Users/Robert/dev/cpython/PCbuild/amd64
ninja
ninja install
```

`meson .. setup <...>` fails and complains that,

'''
Run-time dependency python found: NO (tried sysconfig)

  ..\meson.build:41:12: ERROR: Python dependency not found
'''

which corresponds to:

```meson.build
py = import('python').find_installation(pure: false)
py_dep = py.dependency()
```

I tried also editing `pyproject.toml` to add the section:

```toml
[tool.meson-python.args]
setup = ['-Dbuildtype=debug',
 '-Dincludedir=C:/Users/Robert/dev/cpython/PC',
 '-Dlibdir=C:/Users/Robert/dev/cpython/PCbuild/amd64']
```

and then build NumPy with pip using the debug python build:

```shell
python_d -mpip install . --no-build-isolation -Cbuild-dir=build-dbg
```

But it fails in the same fashion. Searching for issues I find this one but
it's likely in this case something related to the debug Python build is the
problem.

https://github.com/mesonbuild/meson/issues/12547

Meson installed version is 1.4.0. Any advice would be appreciated. I'm
happy to write a gist if I can get it working.

-- 
Robert McLeod
robbmcl...@gmail.com
robert.mcl...@hitachi-hightech.com
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com