Can anyone please explain, what is setup.py and how can it be configured or used?
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
||||
|
This allows you to easily install Python packages. Often it's enough to write:
and the module will install itself. |
|||||||||||||||||||||
|
|
It helps to install a python package It does the similar job of Using Let's start with some definitions: Package - A folder/directory that contains Let's say you want to install a package named
Instead, if you don't want to actually install it but still would like to use it. Then do,
This command will create symlinks to the source directory within site-packages instead of copying things. Because of this, it is quite fast (particularly for large packages). Creating If you have your package tree like,
Then, you do the following in your
Instead, if your package tree is more complex like:
In this case, your
Add more stuff to (
The And, you're ready to upload your package to PyPi.org so that others can install your package using First step is to claim your package name & space in pypi using:
Once registered, nobody can use your package name. After this, you have to upload your package there (to the cloud) by,
Optionally, you can also sign your package with
Bonus: See a sample |
|||||
|
|
If you’re familiar with command line installations, then Some packages are pure Python, and are only byte compiled. Others may contain native code, which will require a native compiler (like |
|||||||||||||||||||||
|
|
If you downloaded package that has "setup.py" in root folder, you can install it by running
If you are developing a project and are wondering what this file is useful for, check Python documentation on writing the Setup Script |
|||
|
|
|
Many packages use the |
|||
|
|
|
setup.py can be used in two scenarios , First, you want to install a Python package. Second, you want to create your own Python package. Usually standard Python package has couple of important files like setup.py, setup.cfg and Manifest.in. When you are creating the Python package, these three files will determine the (content in PKG-INFO under egg-info folder) name, version, description, other required installations (usually in .txt file) and few other parameters. setup.cfg is read by setup.py while package is created (could be tar.gz ). Manifest.in is where you can define what should be included in your package. Anyways you can do bunch of stuff using setup.py like
There are bunch of other commands which could be used with setup.py . for help
|
||||
|
|
|
When you download a package with
Press enter, you should see something like this:
Then type after this
Press |
|||
|
|
|
To install a Python package you've downloaded, you extract the archive and run the setup.py script inside:
To me, this has always felt odd. It would be more natural to point a package manager at the download, as one would do in Ruby and Nodejs, eg. A package manager is more comfortable too, because it's familiar and reliable. On the other hand, each I'm not saying the setup.py workflow is less secure than a package manager (I understand Pip just runs the setup.py inside), but certainly I feel it's awkard and jarring. There's a harmony to commands all being to the same package manager application. You might even grow fond it. |
|||||
|
protected by Matt Fenwick Nov 5 '13 at 2:57
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
pippackage manager? – Jason Antman Jun 19 '15 at 23:47