How to build and install a python module using setuptools
1)
Install setuptools
#sudo apt-get install python-setuptools
2)
select a python project/module which we need to to install using setuptools
https://github.com/openstack/python-keystoneclient
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:
http://pythonhosted.org/setuptools/setuptools.html#using-find-packages
https://github.com/django/django/blob/master/setup.py
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
https://github.com/openstack-dev/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
1)
Install setuptools
#sudo apt-get install python-setuptools
2)
select a python project/module which we need to to install using setuptools
https://github.com/openstack/python-keystoneclient
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:
http://pythonhosted.org/setuptools/setuptools.html#using-find-packages
https://github.com/django/django/blob/master/setup.py
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
https://github.com/openstack-dev/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
What are contents of your requirements file ? I have internally hosted packages will it work with pbr ? what should the format be for requirements.txt file for these internal packages ?
ReplyDeleteperde modelleri
ReplyDeletesms onay
MOBİL ÖDEME BOZDURMA
nftnasilalinir.com
ankara evden eve nakliyat
trafik sigortası
dedektör
websitesi kurma
aşk kitapları