Hello I am trying to building a python package I have the following folder structure
.
├── Dockerfile
├── entrypoint.sh
├── Pipfile
├── Pipfile.lock
├── setup.py
└── vms-backup
├── commands
│ ├── __init__.py
│ ├── to_csv.py
│ ├── to_sql.py
│ └── upload_to_s3.py
└── __init__.py
the setup.py contains the following code:
from setuptools import setup, find_packages
import pipfile
pf = pipfile.load("Pipfile")
setup(
name="vms-backup",
version="1.0.0",
packages=find_packages(exclude=["tests"]),
python_requires="==3.8.13",
install_requires=["click"],
entry_points="""
[console_scripts]
vms-backup=vms-backup:cli
""",
)
and vms-backup/.init.py
import click
from commands import to_csv, to_sql, upload_to_s3
@click.group()
def cli():
pass
cli.add_command(to_csv)
cli.add_command(to_sql)
cli.add_command(upload_to_s3)
if __name__ == "__main__":
cli()
The code works perfectly if I execute, but when executing pip install -e . in order to test the entry_points I got the following output:
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in vms-backup setup command: 'NoneType' object has no attribute 'group'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Any idea about what is wrong with the code?
Thanks
EDIT
If I execute inside a dockerfile the error change:
backup_1 | Obtaining file:///usr/app
backup_1 | Preparing metadata (setup.py): started
backup_1 | Preparing metadata (setup.py): finished with status 'error'
backup_1 | error: subprocess-exited-with-error
backup_1 |
backup_1 | × python setup.py egg_info did not run successfully.
backup_1 | │ exit code: 1
backup_1 | ╰─> [1 lines of output]
backup_1 | error in vms-backup setup command: ("EntryPoint must be in 'name=module:attrs [extras]' format", 'vms-backup=vms-backup:cli')
backup_1 | [end of output]
backup_1 |
backup_1 | note: This error originates from a subprocess, and is likely not a problem with pip.
backup_1 | error: metadata-generation-failed
backup_1 |
backup_1 | × Encountered error while generating package metadata.
backup_1 | ╰─> See above for output.
I would say your problem is that the package name vms-backup
uses a dash.
Try with vms_backup
(or vmsbackup
).
The command name can stay the same: vms-backup = vms_backup:cli