Hi,
I’m having trouble with packaging. I upload my package with twine to testpypi and I download it with pip, no problem here. However, when I’m trying to use it, I get an ImportError : cannot import name 'main' from '__main__'
.
first I though the problem was in my code without talking of packaging but I test it and it works fine. So I guess the problem is in my setup.py file or in my file tree maybe.
My file tree is looking like that :
Moreover, when I’m trying to import the ‘main’ function of __main__.py
‘manually’ in my code, it works so I really don’t know why this error occurs…
There is my setup.py file :
from setuptools import setup, find_packages
from io import open
from os import path
import pathlib
# The directory containing this file
HERE = pathlib.Path(__file__).parent
# The text of the README file
README = (HERE / "README.md").read_text()
# automatically captured required modules for install_requires in requirements.txt and as well as configure dependency links
with open(path.join(HERE, 'requirements.txt'), encoding='utf-8') as f:
all_reqs = f.read().split('\n')
install_requires = [x.strip() for x in all_reqs if ('git+' not in x) and (
not x.startswith('#')) and (not x.startswith('-'))]
dependency_links = [x.strip().replace('git+', '') for x in all_reqs if 'git+' not in x]
setup(
name='pdal-parallelizer',
description='A simple commandline app for parallelize your pdal treatments on point clouds',
version='0.0.5',
packages=find_packages(), # list of all packages
install_requires=install_requires,
python_requires='>=2.7', # any python greater than 2.7
entry_points='''
[console_scripts]
pdal-parallelizer=__main__:main
''',
author="Clément Alba (Métropole Européenne de Lille)",
long_description=README,
long_description_content_type="text/markdown",
license='MIT',
url='https://github.com/meldig/pdal-parallelizer',
download_url='https://github.com/meldig/pdal-parallelizer',
dependency_links=dependency_links,
author_email='calba@lillemetropole.fr',
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
]
)
And we can see in my __main.py__
there is a function called main :
@click.group()
@click.version_option('0.0.5')
def main():
pass
if __name__ == "__main__":
args = sys.argv
if "--help" in args or len(args) == 1:
print("pdal-parallelizer")
main()
Did someone have an idea of what I’m doing wrong ?
Thank you in advance !
Clément