我已经在Python中使用Tkinter构建了一个小测验,我希望释放游戏供所有人玩,这样人们就可以pip install
来玩游戏。
我已经通过文档发布了PyPi包,我发布了一个,它已成功安装。但是,我无法从命令行启动应用程序,也无法查找二进制文件。我不知道我哪里错了。请帮帮我。
我的setup.py文件看起来像这样
from setuptools import setup
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst')) as f:
long_description = f.read()
setup(
name='py-quiz',
version='0.1.1',
description='Python based Quiz game.',
long_description=long_description,
author='Abhijit Nathwani',
author_email='abhijit.nathwani@gmail.com',
LICENSE='MIT',
url='https://github.com/abhijitnathwani/PyQuiz',
keywords='pyquiz tkinter'
)
要打包它,我使用
python setup.py sdist upload
包已成功添加到PyPi包中,我可以使用以下命令安装它:
pip install py-quiz
安装的输出:
Collecting py-quiz
Downloading py-quiz-0.1.1.tar.gz
Installing collected packages: py-quiz
Running setup.py install for py-quiz ... done
Successfully installed py-quiz-0.1.1
但是当我这样做时,
user@somecomputer:~/PyQuiz$ py-quiz
py-quiz: command not found
如何从命令行启动游戏?请帮帮我。
应用程序代码保持here。
答案 0 :(得分:1)
I finally solved the problem above by making the following changes. There must be a package created in the directory and the folder structure should be as follows:
<Directory>
|-setup.py
|-dist
|-LICENCSE
|-readme
|-<package-name>
|-__init__.py
|-__main__.py
|-other files
and in the setup.py
the following change should be
entry_points={
'console_scripts':['<command_name> = <package_name>.__main__:<function to be called>']
In my case, it is as follows:
entry_points={
'console_scripts':['py-quiz = py_quiz.__main__:main']
The main point is to create a package inside your project directory. This should solve major problems.