0

I'm packaging with a small module named my_module; the build is described by a setup.cfg / setup.py pair. Those files are read-only (as they are monitored by a version controler that mark all files as read-only unless explicitely marked for edit).

The setup.cfg file looks like:

[metadata]
name = my_module
...

[options]
package_dir =
    = src
packages = find:
python_requires = >=3.6
install_requires =
    ...

[options.packages.find]
where = src

And the module tree is the following:

my_module_folder/
  setup.cfg
  setup.py
  src/
     my_module/
       __init__.py
       ...

sdist-ing it yields the following:

$ python3 setup.py sdist
running sdist
running egg_info
writing src/my_module.egg-info/PKG-INFO
writing dependency_links to src/my_module.egg-info/dependency_links.txt
writing requirements to src/my_module.egg-info/requires.txt
writing top-level names to src/my_module.egg-info/top_level.txt
reading manifest file 'src/my_module.egg-info/SOURCES.txt'
writing manifest file 'src/my_module.egg-info/SOURCES.txt'

running check

creating my_module-1.0.0
creating my_module-1.0.0/src
...
copying files to my_module-1.0.0...
copying setup.cfg -> my_module-1.0.0                                 # here
copying setup.py -> my_module-1.0.0
copying src/my_module/__init__.py -> my_module-1.0.0/src/my_module
...
Writing my_module-1.0.0/setup.cfg                                    # and there
error: [Errno 13] Permission denied: 'my_module-1.0.0/setup.cfg'

Note that at some point, setuptools will copy the read-only setup.cfg into the package, then later attempt to overwrite it to add an "[egg_info]" section:

[egg_info]
tag_build =
tag_date = 0

Of course that can only fails since setup.cfg was copied with its read-only attribute...

I could harshly alter permissions or file mask prior doing the build, in the setup.py, but I am looking for a more elegant solution. Any clue?

wecx
  • 302
  • 2
  • 10
  • Have you tried looking at the changes the writing of the `setup.cfg` would perform? Or rather do you know for a fact that the sdist command would make undesirable changes to the file? – YoshiMbele Jun 02 '22 at 11:13
  • @YoshiMbele it added an "[egg_info]" section in setup.cfg with the following: "tag_build =" and "tag_date = 0". I've updated the question. I'm not familiar with setuptools, I did not even know that it would embed setup.cfg in the distribution. – wecx Jun 02 '22 at 11:53
  • [This](https://stackoverflow.com/questions/3779915/why-does-python-setup-py-sdist-create-unwanted-project-egg-info-in-project-r) may be related. I am honestly not sure if you should mark both `setup.py` and `setup.cfg` as uneditable by your VCS. – YoshiMbele Jun 02 '22 at 12:26

0 Answers0