[Distutils] Towards a simple and standard sdist format that isn't intertwined with distutils

Nathaniel Smith njs at pobox.com
Sun Oct 11 06:01:48 CEST 2015


On Wed, Oct 7, 2015 at 2:41 PM, Paul Moore <p.f.moore at gmail.com> wrote:
[...]
> Possibly the nearest
> we'd have to an issue is over allowing the build process to *add*
> dependencies to a binary wheel (e.g. a some builds depend on
> currently-hypothetical MKL wheel, which provides needed DLLs). I don't
> in principle object to that, but I'd like to see a fleshed out
> proposal on how wheels containing just DLLs (as opposed to Python
> packages) would work in practice - until we have a mechanism for
> building/distributing such wheels, I think it's premature to worry
> about specifying dependencies.

Just to answer this:

There's no formal proposal because it doesn't involve distutils-sig --
it's something that we already know how to do and are working on
implementing :-). The only reason it doesn't already exist on PyPI is
that Windows is the main target, and toolchain problems mean that we
aren't yet able to build numpy or scipy wheels on Windows at all.
(Long story...)

The basic idea though is just, we make a "python package" with trivial
structure:

pyopenblas/
  __init__.py
  openblas.dll
  include/
    ...

Usage:

# in downstream package setup.py
  Extension(...,
      include_dirs=... + pyopenblas.get_include(),
      linker_arguments=... + pyopenblas.get_linker_arguments(),
      ...)

# in downstream package __init__.py
import pyopenblas
pyopenblas.enable()

Implementation:

pyopenblas/__init__.py contains some code like:

DIR = os.path.dirname(__file__)
def get_include():
    return [os.path.join(DIR, "include")]

def get_linker_arguments():
    return ["-L" + DIR, "-lpyopenblas"]

def enable():
    # Platform specific code to let the runtime linker find libopenblas.so
    if WINDOWS:
        # ctypes magic to preload the DLL
    elif LINUX:
        # modify os.environ["LD_LIBRARY_PATH"]
    else:
        ...

-n

-- 
Nathaniel J. Smith -- http://vorpus.org


More information about the Distutils-SIG mailing list