Search code examples
pythonflasksetup.pypython-wheel

Installing Flask project can't open setup.py


I am following the Deploy to Production tutorial from Flask. I am required to run python setup.py bdist_wheel to build a wheel build distribution file. But that command gives this error:

python: can't open file 'setup.py': [Errno 2] No such file or directory

After searching, I found out that the file is supposed to be at the root of the library I am using. I couldn't find it at the root of the wheel or flask libraries.

Where is the setup.py file that the tutorial is telling me to use?


Solution

  • That page is not a standalone tutorial. A previous step in the tutorial walks you through making your project installable with a setup.py file. It's a separate step from deploying because you should install your project both during development and deployment.

    The summary of the linked tutorial step is: create the following setup.py file to describe your project, then use pip to install the project in the virtualenv.

    from setuptools import find_packages, setup
    
    setup(
        name='flaskr',
        version='1.0.0',
        packages=find_packages(),
        include_package_data=True,
        install_requires=[
            'flask',
        ],
    )
    
    # install during development
    pip install -e .
    
    # install in production
    pip install flaskr-1.0.0-py3-none-any.whl