Pip wheel -w dist . versus python setup.py bdist_wheel

I’m trying to convert an extension package to use project.toml.

I notice that my setup.py code appears to be run from a different location when I use pip wheel.

That means my setup.py code can no longer find files using relative paths eg

os.path.join(os.path.dirname(__file__),‘../fribidi-src’)

How should I manage references to c / h files that are relative to setup.py?

Does pip provide any way to know the original location of the package files?

This probably happens because of that .. in the file path.

It is very common for frontends/installers to build a sdist first and then build a wheel out of it. This means that your code may be first turned into a tag.gz and extracted into a temporary directory and then used to build the wheel.

How should I manage references to c / h files that are relative to setup.py?

You can manage the files under the same directory, but not up in the tree.

Yes the .. is the issue. I’m trying to build a static fribidi python interface based on pyfribidi. The python packaging community don’t seem to have any way to insist on having specific libraries available at build or install time. I suppose I could use python-git as a build requirement and use that if the source files are not found.

In terms of PyPA ecosystem (including pip, setuptools, PyPI etc…), you can only specify dependencies distributed via PyPI.

If fribidi is available in conda-forge or anaconda, you could also consider distributing your project via the conda/mamba ecosystem.

1 Like

It’s true that non-pypi dependencies are not possible, but here I’m just trying to embed statically linked code into an extension.

That’s perfectly feasible using setuptools, however, pip wheel seems to make this quite difficult.

After a few tries I find that most of my problems with the pip wheel command are because all file system references should be relative.

Using setup.py directly os.path.join(os.path.dirname(__file__),'fribidi-src') is fine, but when pip is used __file__ is different and then I need to use just 'fribidi-src'.

After understanding that I managed to use git, meson & ninja to obtain the needed files.