Hướng dẫn python developer github - nhà phát triển python github
Mục đích của hướng dẫn này là ghi lại các thực tiễn, mẹo và thủ thuật tốt nhất để phát triển Python. Đối với tập lệnh và gói ... TBD Mục đích của phần này là cung cấp một hướng dẫn để làm theo khi bạn muốn định cấu hình dự án Python và được triển khai thành PYPI. Tổ chức dự án Đăng nhập Kiểm tra Đăng nhập Setup.pyKiểm tra #!/usr/bin/env python # -*- coding: utf-8 -*- """The setup script.""" from setuptools import setup, find_packages with open('README.md') as readme_file: readme = readme_file.read() with open('HISTORY.md') as history_file: history = history_file.read() requirements = [YOUR_REQUIREMENTS] setup_requirements = ['pytest-runner', ] test_requirements = ['pytest', ] setup( author="leucothia", author_email='', classifiers=[ 'Development Status :: 2 - Pre-Alpha', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], description=" 🐳 DESCRIPTION_OF_YOUR_PACKAGE", install_requires=requirements, license="Apache Software License 2.0", long_description=readme + + '\n\n' + history, long_description_content_type="text/markdown", include_package_data=True, keywords='REPO_NAME', name='REPO_NAME', packages=find_packages(include=['YOUR_PACKAGES']), setup_requires=setup_requirements, test_suite='tests', tests_require=test_requirements, url='https://github.com/oceanprotocol/REPO_NAME', version='0.0.1', zip_safe=False, ) ToxHội nhập liên tục Travis Ci Bumpversion Thử nghiệm trong Pycharm Quản lý gói địa phương và môi trường ảo Đăng nhậpKiểm tra
Tox Hội nhập liên tục Travis Ci Bumpversion
Thử nghiệm trong Pycharm Quản lý gói địa phương và môi trường ảo Sử dụng PIP và VirtualEnV version: 1 disable_existing_loggers: False formatters: simple: format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s" handlers: console: class: logging.StreamHandler level: DEBUG formatter: simple stream: ext://sys.stdout info_file_handler: class: logging.handlers.RotatingFileHandler level: INFO formatter: simple filename: info.log maxBytes: 10485760 # 10MB backupCount: 20 encoding: utf8 error_file_handler: class: logging.handlers.RotatingFileHandler level: ERROR formatter: simple filename: errors.log maxBytes: 10485760 # 10MB backupCount: 20 encoding: utf8 loggers: my_module: level: ERROR handlers: [console] # Ignore the file handlers until deployment propagate: no root: level: INFO handlers: [console, info_file_handler, error_file_handler] Kiểm traToxHội nhập liên tục Hội nhập liên tụcTravis CiBumpversion
Thử nghiệm trong Pycharm
BumpversionThử nghiệm trong Pycharm Thử nghiệm trong PycharmQuản lý gói địa phương và môi trường ảo Sử dụng PIP và VirtualEnV Sử dụng pipenv Quản lý gói địa phương và môi trường ảoSử dụng PIP và VirtualEnVSử dụng pipenv virtualenv -p $(which python3.6) py36 # Create a Python 3.6 virtualenv named py36 source py36/bin/activate # Make the py36 virtualenv active python --version # Check the version of Python in the virtualenv pip install blahblah # Install the Python package named blahblah from PyPI pip freeze # List the Python packages installed in the virtualenv deactivate # Deactivate the current virtualenv (py36) source other_env/bin/activate # activate other_env Sử dụng Conda
Eclipse + Pydev Sử dụng pipenvTrình quản lý gói được đề xuất PYPA hiện tại.Pipenv trên github. Sử dụng CondaHiện tại, các gói không được công bố cho kho lưu trữ gói Anaconda.Tuy nhiên, bạn có thể sử dụng Conda làm Trình quản lý môi trường ảo và 5 gói Python vào môi trường Conda của bạn.Dọn dẹp thư mục dự ánSau khi làm việc với một dự án Python trong một thời gian, thư mục dự án có thể nhận được đầy đủ các tạo tác và đôi khi những thứ đó có thể gây ra vấn đề (ví dụ: xung đột).Bạn có thể làm sạch chúng bằng cách sử dụng: # Remove build artifacts rm -fr build/ rm -fr dist/ rm -fr .eggs/ find . -name '*.egg-info' -exec rm -fr {} + find . -name '*.egg' -exec rm -f {} + # Remove Python file artifacts find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + find . -name '__pycache__' -exec rm -fr {} + # Remove test and coverage artifacts find . -name '.pytest_cache' -exec rm -fr {} + rm -fr .tox/ rm -f .coverage rm -fr htmlcov/ Mẹo: Nếu bạn gặp lỗi về quyền, thì hãy tự cho mình các quyền cần thiết bằng cách sử dụng 6IDE và biên tập viênPhòng thí nghiệm Jupyter 7 Trong mỗi môi trường để chuyển đổi hạt nhân hoạt động!Nguyên tửSpyderLắp đặt Spyder trong mỗi VENV để đảm bảo sử dụng kernel. Eclipse + PydevPycharm |