0

I have been reusing several python projects and when I execute python setup.py install all the code gets copied into /usr/lib/python2.7/dist-packages. Now I am trying to create my own Python project and this is my setup.py

from setuptools import setup, find_packages

setup(
    name = "My project",
    version = "0.1",
    license = "BSD",
    packages=find_packages(),

)

However, that copies all my scripts into a /build directory which gets created in the directory where the setup.py is. How can I change that behaviour and so that the scripts move to /usr/lib/python2.7/dist-packages instead?

1

1 Answer 1

1

You have to build the package first and that package ends up in /dist. Once you have the package file you have to install it with pip install. It will then be transferred to /usr/lib/python2.7/dist-packages.

The purpose of creating packages is for distributing your code, so it assumes that you won't just be using it yourself and builds a package that can then be installed.

You won't be allowed to directly write to /usr/lib/python2.7/dist-packages unless you use sudo because it is a system directory.

Also direct installation is not recommended because you might get something wrong and have to uninstall. It is always a safer and better practice to build the package and test it in a virtual environment before you actually install it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.