Lập Trình Linux

Python Getting Started With setuptools setup.py setup.cfg and OpenStack pbr




Python Getting Started With setuptools setup.py setup.cfg and OpenStack pbr

1)
Install setuptools
#sudo apt-get install python-setuptools

2)
select a python project/module which we need to to install using setuptools

3)
Open python console and try import your project/module and you should get error, since project/module not installed.

4)
* Create a setup.py file in the project/module folder with following lines and run #python setup.py build and install
import setuptools
setuptools.setup()

* Edit setup.py file and add following line and run #python setup.py build and install
import setuptools
setuptools.setup(name=”regservice”, packages=setuptools.find_packages())

Examples:

5)
Run “#python setup.py build”
* Check the folders and files which are created by above command
* Create a requirement.txt file in project/module folder and run “#python setup.py build” again and check the require.txt file in the egg folder.
* Run “#python setup.py install” and open a python console and try to import your project/module
* Try different options of #python setup.py build
* Try different options of #python setup.py install

6)
setup.py commands
————————–
#python setup.py –help-commands

a)
#sudo python setup.py build –help

b)
#sudo python setup.py install –help

Options for ‘install’ command:

–user install in user site-package
‘/home/saju/.local/lib/python2.7/site-
packages’

–record filename in which to record list of
installed files

#sudo python setup.py install –user

#sudo python setup.py install –user –record=a.txt

c)
sudo python setup.py sdist

d)
sudo python setup.py nosetests

e)
sudo python setup.py build_sphinx

f)
sudo python setup.py develop -z

g)
sudo python setup.py test

h)
sudo python setup.py install –user saveopts
sudo python setup.py develop -z saveopts

7)
* Modify the setup.py file in the project/module folder with following lines
import setuptools
setuptools.setup(setup_requires=[‘pbr’], pbr=True)

* What is pbr

* Run “#python setup.py build” and examin requirement.txt and egg/require.txt
* Create a setup.cfg file in the project/module folder with following lines
[metadata]
name= blabla
* Run “#python setup.py build” and examin requirement.txt and egg/require.txt
* Run “#python setup.py install” and open python console and try to import your project/module

8)
* Uninstall a package which installed with command “#python setup.py install”
#sudo pip uninstall regservice

9)
* Modify the setup.py file in the project/module folder with following lines
import setuptools
setuptools.setup()

Then run following command to install the module and try to import the module in python console. You can use “#sudo pip uninstall regservice” to unstall the module
#sudo python setup.py install

10)
modify the setup.py in the project folder with following lines
import setuptools
setuptools.setup(name=”regservice”)

Then run following command to install the module and try to import the module in python console. You can use “#sudo pip uninstall regservice” to unstall the module#sudo python setup.py install

Nguồn:https://ftlinuxcourse.com/

Xem Thêm Bài Viết Khác:https://ftlinuxcourse.com/lap-trinh-linux

Lập Trình Linux
WEB APPLICATION HACKING || KALI LINUX 2016.2
Lập Trình Linux
Shimeji Desktop Pet – Download And Install | Full Tutorial
Tin HOT
Trực Tiếp Xổ Số Miền Nam Hôm Nay Thứ 6 Ngày 01/05/2020, KQXS Mien Nam
  • tks for such a good tut


  • Dear Friends and Saju,I have an issue in Make install … please read the thread and reply me
    How to copy an image file on Makeinstall of Gtk2 app ?
    http://www.gtkforums.com/viewtopic.php?f=3&t=179183


  • i have problem with fb.py (((((((((( no module named mechanize )))))))))))) how solve it i dont understnad your method is too long so bro explane me on some simple steps please ???????????????


  • @Leo Adams I know that you probably had your response by now but may be someone else will read this and find it useful :
    to paste into console or vim it's: { control + shift + v }


  • Hello, Saju,

    Thanks very much for the awesome tutorial. 

    Could you please tell me how I can paste the content from clipboard to prompt and vim as you did at 0:43 and 4:12?

    Peace,
    Leo