Python code packaging and release details, python code details

Source: Internet
Author: User

Python code packaging and release details, python code details

In a python program, A. py file is used as a module and different functions are defined in each module. When we want to use a function in a module, we must first import this module. Otherwise, the function will be undefined.

The following describes how to package and install packages.

In this example, a simulated logon program is created:

The logIn. py file code is as follows:

pwd=int(raw_input('please input your passward: '))if pwd==123:  print 'success'else:  print 'error'

I. Packaging

1. Create a folder to store the. py file that we will use for release. (now we create a folder named distribution and put logIn. py in this folder)

2. Create a new setup. py file in the distribution folder. The Code is as follows:

From distutils. core import setupsetup (name = 'login', # This is the final packaged file name version = '1. 0.0 ', py_modules = ['logint'], # what to pack ,. py file ,)

3. In the end, cd is included in the distrbution folder, and then the following command is run:

python setup.py sdist

This example shows several more files in the folder. In the distfolder, login-1.0.0.tar.gz is our release package;

Ii. Install the package to a local copy:

sudo python setup.py install

Path:/usr/local/lib/python2.7/dist-packages


How to Package Multiple python programs

What is the package? You can use a py2exe plug-in to compress an exe file.

Python packaging problems

This is related to the current path of cmd.
Try:
D:
Python d: \ nester \ setup. py sdist

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.