<p>Side note: personally I dislike using a <em>minimum</em> version: you never know beforehand how the language will evolve and if a certain future version will still be compatible with your code. For example many 2.7-compatible scripts can't actually work with python 3.X, setting 2.7 as the minimum version won't cut it.</p>

<p>I prefer to explicitly list as allowed the (existing) versions that I can test and confirm to be compatible. Any future version can be added later on, after such confirmation is obtained.</p>

<p>If you agree with the above then the <a href="https://github.com/linkedin/pygradle/blob/master/docs/plugins/python.md" rel="nofollow noreferrer"><code>com.linkedin.python</code></a> plugin can apparently perform such version checks (it doesn't looks like it supports a <em>minimum</em> version):</p>

<blockquote>
  <p><strong>Default and allowed Python version</strong></p>
  
  <p>This plugin enforces a set of default and allowed Python versions. For
  example, you can specify <code>pythonVersion = '3'</code> and you will get
  whatever the default Python 3 version is. Similarly <code>pythonVersion =
  '2'</code> gets you whatever the default Python 2 version is.</p>
  
  <p>This plugin also enforces a set of allowed Python versions. If you
  choose a Python version that is not allowed, you will see an error
  messages such as:</p>

<pre><code>Python 3.2 not allowed; choose from [2.6, 2.7, 3.4, 3.5, 3.6]
</code></pre>
  
  <p>If you see this error message, you must adjust your <code>pythonVersion</code>
  setting to one of the allowed values.</p>
  
  <p>Consumers of this extension can change the default Python 2, Python 3,
  and allowed versions by making a call on the <code>PythonDetails</code> object,
  either the one returned by <code>PythonExtension.getDetails()</code> or on any
  <code>PythonDetails</code> instance you create, e.g. in Groovy:</p>

<pre><code>pythonDetails.setPythonDefaultVersions('2.7', '3.6', ['2.7', '3.5', '3.6'])
</code></pre>
</blockquote>

<p>But I'm not familiar with pygradle, I can't really tell exactly how the plugin works and/or is configured to do the job.</p>

CC BY-SA 3.0
2018-02-25T08:53:42.520Z
2018-02-25T08:53:42.520Z
Dan Cornilescu
<p><a href="https://github.com/linkedin/pygradle" rel="nofollow noreferrer">Pygradle</a> is used to build a python project.</p>

<p><strong>Problem</strong></p>

<p>The problem is that the CI runs a different Python version, resulting in different build outcomes, e.g. the build succeeded on the laptop, but failed on CI.</p>

<p><em>CI</em></p>

<pre><code>============================= test session starts ==============================
platform linux -- Python 3.6.3, pytest-2.9.1, py-1.4.29, pluggy-0.3.1
rootdir: /home/travis/build/user/project, inifile: 
plugins: cov-2.2.1
collected 1 items
</code></pre>

<p><em>Laptop</em></p>

<pre><code>============================= test session starts ==============================
platform linux2 -- Python 2.7.5, pytest-2.9.1, py-1.4.29, pluggy-0.3.1
rootdir: /home/user/dev/project, inifile: 
plugins: cov-2.2.1
collected 1 items
</code></pre>

<p><strong>Discussion</strong></p>

<p>To ensure that the build fails both locally on CI and on the laptop, the same python version should be used.</p>

<p><strong>Question</strong></p>

<p>Is it possible to set a minimum Python version in Pygradle?</p>

<pygradle>
Is it possible to set a minimum Python version in Pygradle?
030
# Is it possible to set a minimum Python version in Pygradle?

(Asked by: username_0 on 2018-01-22)

Pygradle is used to build a python project.
Problem
The problem is that the CI runs a different Python version, resulting in different build outcomes, e.g. the build succeeded on the laptop, but failed on CI.
CI
============================= test session starts ==============================
platform linux -- Python 3.6.3, pytest-2.9.1, py-1.4.29, pluggy-0.3.1
rootdir: /home/travis/build/user/project, inifile: 
plugins: cov-2.2.1
collected 1 items

Laptop
============================= test session starts ==============================
platform linux2 -- Python 2.7.5, pytest-2.9.1, py-1.4.29, pluggy-0.3.1
rootdir: /home/user/dev/project, inifile: 
plugins: cov-2.2.1
collected 1 items

Discussion
To ensure that the build fails both locally on CI and on the laptop, the same python version should be used.
Question
Is it possible to set a minimum Python version in Pygradle?

**Tags:** pygradle


---

## 1 answers

### Answer by username_1 on 2018-02-25. Score: 0 | Accepted answer

Side note: personally I dislike using a minimum version: you never know beforehand how the language will evolve and if a certain future version will still be compatible with your code. For example many 2.7-compatible scripts can't actually work with python 3.X, setting 2.7 as the minimum version won't cut it.
I prefer to explicitly list as allowed the (existing) versions that I can test and confirm to be compatible. Any future version can be added later on, after such confirmation is obtained.
If you agree with the above then the com.linkedin.python plugin can apparently perform such version checks (it doesn't looks like it supports a minimum version):

Default and allowed Python version
This plugin enforces a set of default and allowed Python versions. For
  example, you can specify pythonVersion = '3' and you will get
  whatever the default Python 3 version is. Similarly pythonVersion =
  '2' gets you whatever the default Python 2 version is.
This plugin also enforces a set of allowed Python versions. If you
  choose a Python version that is not allowed, you will see an error
  messages such as:
Python 3.2 not allowed; choose from [2.6, 2.7, 3.4, 3.5, 3.6]

If you see this error message, you must adjust your pythonVersion
  setting to one of the allowed values.
Consumers of this extension can change the default Python 2, Python 3,
  and allowed versions by making a call on the PythonDetails object,
  either the one returned by PythonExtension.getDetails() or on any
  PythonDetails instance you create, e.g. in Groovy:
pythonDetails.setPythonDefaultVersions('2.7', '3.6', ['2.7', '3.5', '3.6'])


But I'm not familiar with pygradle, I can't really tell exactly how the plugin works and/or is configured to do the job.


---

