Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module
#1
Hi, im trying to make a module:
from distutils.core import setup

setup(
    name            = "nester"
    version         = '1.0.0'
    py_modules      = ['nester']
    author          = 'j'
    author_email    = '[email protected]'
    url             = 'nothing.com'
    description     = 'a simple printer of nested lists'
)
and when I run:
$python3 setup.py sdist

I get a syntax error though I cant imagine what it is

Error:
File "setup.py", line 5 version = '1.0.0' ^ SyntaxError: invalid syntax
I've tried messing around with the syntax of the setup.py and am continually coming up short, can somebody please help me or at least point me in the right direction? Wall
Reply
#2
You need commas between parameters.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Commas. Each of those is a keyword argument to a function. They must be comma separated.
Reply
#4
As mention comma separated.
Use this import from setuptools import setup and not distutils.
Do pip install wheel then always build with bdist_wheel.

Here a full example.
# life.py
def answer_to_life(value):
    if value == 42:
        print(f'Right answer <{value:~^10}>')
    else:
        print('Wrong answer')

if __name__ == '__main__':
    answer_to_life(42)
# setup.py
from setuptools import setup

__author__ = 'snippsat'

setup(
    name="Life",
    version='1.0.0',
    py_modules=['life'],
    author='S',
    author_email='p@p',
    url='nothing.com',
    description='Answer to life'
)
Build install and run from command line.
# Build
E:\div_code\my_module
λ python setup.py bdist_wheel
running bdist_wheel
running build ....

# cd to dist folder
E:\div_code\my_module
λ cd dist\

E:\div_code\my_module\dist
λ ls
Life-1.0.0-py3-none-any.whl

# Install 
E:\div_code\my_module\dist
λ pip install Life-1.0.0-py3-none-any.whl
Processing e:\div_code\my_module\dist\life-1.0.0-py3-none-any.whl
Installing collected packages: Life
Successfully installed Life-1.0.0

# Test that it work
E:\div_code\my_module\dist
λ ptpython
>>> from life import answer_to_life

>>> answer_to_life(10)
Wrong answer

>>> answer_to_life(42)
Right answer <~~~~42~~~~>

>>> exit()

E:\div_code\my_module\dist
λ
Reply
#5
Thank you all so much!

I've done
 pip install wheel 
and yet bdist_wheel is coming up as an invalid command
Reply
#6
(Oct-25-2019, 09:21 PM)fcktheworld587 Wrote: and yet bdist_wheel is coming up as an invalid command
As you use python3 command i guess you use default Python3 Distro setup.
The need to use pip3 not pip(python 2 default on older Distros).
pip3 install --upgrade setuptools
pip3 install wheel
If also missing build tool can also install this.
sudo apt install python3-venv python3-pip python3-dev
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020