Python Create Project

Source: Internet
Author: User

Project skeleton
    • noseTest framework
Windows 10 configuration creates skeleton project directory

PowerShell for Windows 10

mkdir projectscd projects/mkdir skeletoncd skeleton/mkdir bin, NAME, tests, docsNew-Item -type file  NAME/__init__.py, tests/__init__.py  # 创建初始化模块

binFiles are used to hold scripts that run on the command line, but this is not where the modules are stored.

Createsetup.pyUsed to install the project

setup.py

Try: fromSetuptoolsImportSetupexcept Importerror: fromDistutils.coreImportSetupconfig={' description ':' My Project ',' Author ':' My Name ',' URL ':' URL to get it at. ',' Download_url ':' Where to download it. ',' Author_email ':' My email. ',' Version ':' 0.1 ',' Install_requires ': [' nose '],' Packages ': [' NAME '],' Scripts ': [],' name ':' ProjectName '}setup (**Config

Edit the above file and write your own contact information so that you don't need to update it every time you copy it.

Finally need a simple test dedicated skeleton file called tests/NAME_test.py .

NAME_tests.py

fromimport*import NAMEdef setup():    print("SETUP!")    def teardown():    print("TEAR DOWN!")    def test_basic():    print("I RAN!")

You can run to ls -R view the directory structure.

tests/to return to the previous level of the catalog, run the test:

nosetests
Use this skeleton

Each time you want to create a new project, just do the following things:

    • Copy the Skeleton catalogue and change the name to the name of the new project.
    • Rename the name directory to the name of your project, or the name you want to give your own root module.
    • Edit setup.py it to include information about the new project.
    • Rename and replace the name with tests/NAME_test.py your module.
    • Use nosetests Check for errors.
    • Start writing code.

Example:

cp -r  .\projects\ xintcd xint\skeletonRename-Item NAME xintRename-Item -Path ‘D:\APP\xint\skeleton\tests\NAME_test.py‘ -NewName ‘D:\APP\xint\skeleton\tests\xint_test.py‘
get-help Rename-Item -examples  # 获取帮助
Python Packaging toolsdistutils、setuptoolsAnalyze creating a Python virtual environment

If the shortcut to Anaconda disappears (Windows 10), you can try the following:

    • win+REnter cmd the command line, jump to Anaconda the installation directory, and then execute
      python .\Lib\_nsis.py mkmenus
    • Then look at the Start menu, and the associated shortcut to the Anaconda you want appears.
Create a project using Visual Studio

Python Create Project

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.