I am trying to create a Python pip package. This works also well. I can successfully upload and download the package and use it in the Python code. What I can't do is to use the Python package via the command line. In another StackOverflow post I found the link to a tutorial. I tried to follow it. Obviously I made a mistake. Can you guys help me please ? Installation of the package via pip here you can see that the installation worked. Unfortunately, not the whole script fit on the image. Pip does not find the package. Unfortunately, I can't embed the images directly, so I'll just embed them as links.
I have created a simple Python package. It represents here only an example. Here you can see the structure of the folder
Riffecs
| .gitignore
| .pylintrc
| LICENSE
| README.md
| requirements.txt
| setup.py
|
|
\---riffecs
__init__.py
__main__.py
Here are the basic files shown.
main.py
from . import hello_world
if __name__ == '__main__':
hello_world()
and init.py
def hello_world():
print("Hello world")
In the following you can see the "setup.py". I am of the opinion that I have followed the instructions. But obviously I made a mistake somewhere. Can you please help me to correct this mistake.
import io
import os
import setuptools
def read_description():
url = "README.md"
""" Read and Return the description """
return io.open(os.path.join(os.path.dirname(__file__), url), encoding="utf-8").read()
def def_requirements():
""" Check PIP Requirements """
with open('requirements.txt', encoding='utf-8') as file_content:
pip_lines = file_content.read().splitlines()
return pip_lines
setuptools.setup(
name="riffecs",
version='0.0.3',
description='test',
entry_points={'console_scripts': ['hello-world=riffecs:hello_world',]},
long_description=read_description(),
long_description_content_type="text/markdown",
license="MIT",
keywords="test - riffecs",
url="https://github.com/Riffecs/riffecs",
packages=["riffecs"],
install_requires=def_requirements(),
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
)
In your setup.py
file you have this line...
entry_points={'console_scripts': ['hello-world=riffecs:hello_world',]},
This is the entry point to calling you package via command line. This configuration is asking the entry point to be hello-world
, which I tried and it runs fine.
In your image however you run riffecx
which is not configured as an entrypoint to the package.
If you wanted the entrypoint to be riffecx
. change the line to:
entry_points={'console_scripts': ['riffecx=riffecs:hello_world']},
Hope this helped.