Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing only .pyc (python compiled) with setuptools

Tags:

I want to run python setup.py install (the setup script uses setuptools), and I want only the .pyc files to be included in the resulting egg or directory. all .py files must not be present. How can I do this ?

like image 460
Stefano Borini Avatar asked Apr 20 '11 12:04

Stefano Borini


People also ask

Is Setuptools installed by default with Python?

Even in a vanilla version of Python 3.7. 6 (installed via pyenv ), the packages installed by default are both pip and setuptools .

How do I run a .PYC file in Python?

pyc files are created by the Python interpreter when a . py file is imported. They contain the "compiled bytecode" of the imported module/program so that the "translation" from source code to bytecode (which only needs to be done once) can be skipped on subsequent imports if the . pyc is newer than the corresponding .

Do I need to install Setuptools?

you generally don't need to worry about setuptools - either it isn't really needed, or the high-level installers will make sure you have a recent enough version installed; in this last case, as long as the operations they have to do are simple enough generally they won't fail.

What is the difference between .py and .PYC files?

py files contain the source code of a program. Whereas, . pyc file contains the bytecode of your program.


1 Answers

not with install, but a possibility is to run the following command

python setup.py bdist_egg --exclude-source-files

and install the resulting egg in dist with easy_install

easy_install dist/eggname.egg

Note that according to the manual install is nothing but a shortcut to easy_install use.

like image 117
Stefano Borini Avatar answered Sep 21 '22 06:09

Stefano Borini