Skip to content
Advertisement

Remove parent directories in python build source archive

I have the following setup for my python package:

๐Ÿ“ฆmy_package
 โ”ฃ ๐Ÿ“‚src
 โ”ƒ โ”— ๐Ÿ“œ__init__.py
 โ”ฃ ๐Ÿ“œsetup.cfg
 โ”— ๐Ÿ“œpyproject.toml

The __init__.py is empty, the pyproject.toml and the setup.cfg contain example output from the PyPi documentation page (content shown below).

Now, for uploading to PyPi and for packing the python project, I run the command

python -m build

This gives me a new directory dist (in my_package) containing a Test-0.0.0.tar.gz. All this is expected. But when I open the Test-0.0.0.tar.gz, I get the following content:

๐Ÿ“ฆTest-0.0.0.tar.gz
 โ”— ๐Ÿ“‚C:
   โ”— ๐Ÿ“‚path
     โ”— ๐Ÿ“‚to
       โ”— ๐Ÿ“‚my
         โ”— ๐Ÿ“‚dev-directory
           โ”— ๐Ÿ“‚my_package
             โ”— ๐Ÿ“‚dist
               โ”— ๐Ÿ“‚tmp<some other characters>
                 โ”— ๐Ÿ“œTest-0.0.0.tar

As you can see, the .tar.gz file contains the path on my local machine which is, obviously, not very privacy friendly. I absolutely do not want to upload files containing information about my private file tree structure. And I guess, this is also not intended. Plus, as far as I know, gzip does not allow to compress directories directly.

So my question is: What am I doing wrong in my build process?

PS: As you may have guessed by the document tree, I am developing on Windows – which might be important. My Python version is 3.7.1, installed via Miniconda3.


File contents:

pyproject.toml

[build-system]
requires = [
    "setuptools>=42",
    "wheel"
]
build-backend = "setuptools.build_meta"

setup.cfg

[metadata]
name=Test

[options]
package_dir =
    = src

__init__.py is empty.

Advertisement

Answer

I updated my python to version 3.9, now everything works. I tried to find an issue on the official GitHub repository, but I didn’t find it. Still, this is a very weird behaviour.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement