Project skeleton
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