What am I doing wrong in setup.py - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: What am I doing wrong in setup.py (/thread-6183.html) |
What am I doing wrong in setup.py - gps1539 - Nov-09-2017 Hi I recently created my first pypi package (trespass). I can use pip install trespass and it pulls the dependencies, creates the /usr/lib/python3.6/site-packages/trespass directory and python /usr/lib/python3.6/site-packages/trespass/trespass.py runs correctly. What I seem to be missing is how do I install trespass to /usr/bin? I looked at a few example setup.py files but I can't see where I messed up. Here are my setup.py file and setup.cfg files Quote:from distutils.core import setup Quote:[metadata] RE: What am I doing wrong in setup.py - metulburr - Nov-09-2017 I could be totally wrong in this but its worth a shot setup(name='myproject',author='',author_email='',scripts=['/usr/bin/myscript.py']) Other than that i would assume to copy your executable to /usr/bin and ask for permission and check if there is a filename in there already RE: What am I doing wrong in setup.py - gps1539 - Nov-09-2017 Thanks metulburr I'll try that. RE: What am I doing wrong in setup.py - snippsat - Nov-10-2017 There is also a console_scripts Entry Point ,that can be used for this.Will make command-line script available for both Windows and POSIX platforms. For Windows it will even create an .exe file so that users don’t have to change their PATH settings.Here a demo i use Click ,the method work the same for example argparse. # greet.py import click @click.command() @click.option('--count', default=3, help='Number of greetings.') @click.option('--name', prompt='Your name', help='Command line stuff') def hello(count, name): '''Simple program that greets name and count''' for x in range(count): click.echo(f'Hello {name} {"☂"}') if __name__ == '__main__': hello() # setup.py from setuptools import setup setup( name='hello', version='0.1', py_modules=['greet'], install_requires=[ 'Click', ], entry_points=''' [console_scripts] greet=greet:hello ''', )So run python setup.py bdist_wheel So this make a wheel,should always make wheel and not source distribution like tarball.Install: pip install hello-0.1-py3-none-any.whl So can now access greet from anywhere in cmd.There has been made a greet.exe in Scripts folder of Python installation.Test: C:\ λ greet Your name: Superman Hello Superman ☂ Hello Superman ☂ Hello Superman ☂ C:\ λ greet --help Usage: greet [OPTIONS] Simple program that greets name and count Options: --count INTEGER Number of greetings. --name TEXT Command line stuff --help Show this message and exit. C:\ λ greet --count 5 Your name: Hulk Hello Hulk ☂ Hello Hulk ☂ Hello Hulk ☂ Hello Hulk ☂ Hello Hulk ☂ RE: What am I doing wrong in setup.py - gps1539 - Nov-10-2017 Well I edited my setup.py to include scripts = ['trespass/trespass'], it upload and when I installed it did copy to /usr/bin, however when I edited to make one more change the upload fails "AssertionError: unsupported schema" and I've no idea why as nothing else changed. I download the setup.py from the successful upload from https://pypi.python.org/pypi/trespass/0.6.5.3 and just bumped up the version and I still get "AssertionError: unsupported schema". I'm very confused. Quote:sudo python setup.py sdist upload -r pypi I tried again with no changes on my side and I can upload again. |