pypa / build

A simple, correct Python build frontend

Home Page:https://build.pypa.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to build source distribution [sdist] excluding particular file

Earammak opened this issue · comments

I need help in building source distribution to exclude a particular file for my project.
We are giving python wheels support to our project [ https://github.com/ibmdb/python-ibmdb].
So, the requirement is while building source distribution file should not be included and when it is building wheel it should be included in .whl file.

Source distribution and wheels are created from github actions.
Is there a way to exclude file to create a source distribution.

Thanks,

Hi @Earammak, this is probably a question for the build backend that your project uses instead of pypa/build...

In general, a project should be able to build from the sdist, so unless you are generating the file dynamically during the build, you might not be able to include it later in the wheel if it is not originally included in the sdist.

If you are generating the file dynamically, whether it is included on the sdist or wheel will depend on how you are customising the build process.

I see that in https://github.com/ibmdb/python-ibmdb you are using setuptools as build backend, so I recommend opening a GitHub discussion in pypa/setuptools with a minimal reproducible example of what you want to achieve.

@abravalheri, Thank you for quick update.
To build source distribution we will use a command is: " python -m --sdist --no-build-isolation "

From this build package, do we have any config that we can exclude while building source distribution ?

Have you tried MANIFEST.in?

Yes i tried.
From source distribution the file will be excluded.
But i need that file while installing the package from that source distribution. [ To download the file we have coded in setup.py]

That is the thing that I was referring in my first comment... If you are not generating this file dynamically, then you do need to include it in the sdist, otherwise it will not be available when creating the wheel.

The way the build process work in Python (by default) is roughly the following:

(A) source tree in project directory ---> (B) sdist ---> (C) wheel ---> (D) package installed in the final location

The wheel is created from the sdist.

Ok I understand the flow.
Can you please suggest here for my below requirement.

Currently consider we are building wheels from python version 3.6 - 3.11 for operating systems linux, macos and windows.
When this requirement does not match, the package should get installed from source distribution.

Whatever file i was mentioned to exclude is to download based on the platform we use.
The process we do from github action, building source distribution runs on linux operating systems.
linux file will be included in source distribution. And i cannot install package successfully other than linux from source distribuion.

Example i want to install package on AIX machine, the file has to download for aix file only.
When i try to install package on this machine, it don't have corresponding file and not able to install successfully.

.

I am not sure if I understood, sorry, it is very difficult to discuss in terms of generic process and generic files 😅.

If you need to download a file for each platform when creating the wheel, maybe the download should take place when transforming the sdist into wheel then?

Could you please open a GitHub discussion in pypa/setuptools with a minimal reproducible example of what you want to achieve + more details? It does not have to be the same as your real project (and actually it would be better if it is just a dummy that capture the essential parts and omit all the parts that are not necessary). I think that would make things easier to understand and talk about (unfortunately I don't have the privileges in this repo to transfer the ticket to setuptools).

If you need to download a file for each platform when creating the wheel, maybe the download should take place when transforming the sdist into wheel then?
Ideally it will be fine when it gets included in source distribution and corresponding wheel files are built.
I'm not sure, how to install a package when we don't have corresponding wheel package.
Could you please open a GitHub discussion in pypa/setuptools with a minimal reproducible example of what you want to achieve + more details? It does not have to be the same as your real project (and actually it would be better if it is just a dummy that capture the essential parts and omit all the parts that are not necessary). I think that would make things easier to understand and talk about (unfortunately I don't have the privileges in this repo to transfer the ticket to setuptools).

ok i'll discuss with setuptools package.

Thank you so much for sharing the information.

I got the solution to resolve this problem.