How to customize your Python version for Python projects in SNAP applications __python

Source: Internet
Author: User

We know that for the Python project, we just need to specify plugin as Python in our snapcraft.yaml to download the python version specified in Snapcraft for the Python project. But for some projects, our developers may need a specific Python version, so how do we implement this functionality? In today's tutorial, we'll introduce a new feature added to Snapcraft 2.27.


Let's take a look at one of my projects first:

Https://github.com/liu-xiao-guo/python-plugin Snapcraft.yaml

Name:python36
version: ' 0.1 ' 
summary:this is a simple example not using Python plugin
description: |
  This is a python3 example

grade:stable 
confinement:strict

Apps: python36
  :
    command:helloworld_ In_python
  python-version:
    command:python3--version

parts:
  my-python-app:
    Source:https ://github.com/liu-xiao-guo/python-helloworld.git
    Plugin:python after
    : [python]
  python:
    Source:https://www.python.org/ftp/python/3.6.0/python-3.6.0.tar.xz
    plugin:autotools
    configflags: [-- PREFIX=/USR]
    build-packages: [Libssl-dev]
    Prime:
      --usr/include

Here, for our Python project, it specifies the python defined in our project Python part. This Python version is downloaded directly from the Web.
We can directly package our applications and run our applications:
$ python36
Hello, World

Obviously our Python is working properly. We can check our Python version with the command python36.python-version command:
$ python36.python-version 
python 3.6.0

It shows the version 3.6 of Python that we are currently running. It's the version we downloaded in Snapcraft.
Related Article

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.