# Python with dual versions of Ports - How?



## JamesElstone (Aug 27, 2017)

Hi All,

I have a query about Python, default versions, and ports being able to run against 2.7 and 3.6.

I have a fresh install of 11.1-RELEASE-p1 of which I am tracking ports/head.

My questions are:

1. What is the default version python used?
      I think it is 2.7...

2. How can port dependancies be compliled for both 2.7 and 3.6?
      Example: py-sortedcontainers is installed for both 2.7 and 3.6

3. How does a port that uses 3.6 know to check for 3.6 dependancies and not rely on 2.7       dependancies as 2.7 is default?

4. I presume you need to update ports for 2.7 and then for 3.6; what mechanisms / methods do people use for updates to both when a port version gets bumped?

5. Is there a way in a port to specify 3.6 is mandated and will check for 3.6 dependancies rather than 2.7? 

Your wisdom would be most welcomed.

Kind regards,

James.


----------



## SirDice (Aug 28, 2017)

JamesElstone said:


> 1. What is the default version python used?


Look at /usr/ports/Mk/bsd.default-versions.mk. At the moment it's 2.7.



JamesElstone said:


> 3. How does a port that uses 3.6 know to check for 3.6 dependancies and not rely on 2.7 dependancies as 2.7 is default?


Look at /usr/ports/Mk/Uses/python.mk:

```
# version       If your port requires only some set of Python versions, you
#               can set this to [min]-[max] or min+ or -max or as an
#               explicit version or as a meta port version (eg. 3.3-3.4 for
#               [min]-[max], 2.7+ or -3.3 for min+ and -max, 2.7 for an
#               explicit version or 3 for a meta port version). Example:
#
#                       USES=python:2.7         # Only use Python 2.7
#                       USES=python:3.3+        # Use Python 3.3 or newer
#                       USES=python:3.3-3.4     # Use Python 3.3 or 3.4
#                       USES=python:-3.3        # Use any Python up to 3.3
#                       USES=python:2           # Use the Python 2 meta port
#                       USES=python             # Use the set default Python
#                                               # version
```



JamesElstone said:


> 5. Is there a way in a port to specify 3.6 is mandated and will check for 3.6 dependancies rather than 2.7?


See previous answer.


----------



## JamesElstone (Aug 28, 2017)

Hi,

Have since posting have read the header of the /usr/ports/Mk/Uses/python.mk file.

It seems specifying `USES=python:3.5+` in a ports Makefile uses a branch of python3 for the port but any dependacies are (in my opinion; incorrectly) checked / built using 2.7 (default), resulting in py27-* dependants being built for a py36-* parent port.

If the port specifies `USES=python:3.6` then all the dependacies are checked against Python3.6, which is what I was expecting, such as py36-* dependants are built.

I think this is where my confusion and broken logic came from, and hence my question...

Is the behaviour when `USES=python:3.5+` as used is as expected; would it be best to post this question onto the python mailing list?

Kr,

James


----------



## SirDice (Aug 29, 2017)

I would expect USES-python:3.5+ to behave the same as USES=python:3.6. There's a separate default for Python 3.x, and I would expect it to use that as long as it meets the version requirements. The 'default' for Python 3 is 3.6 so I would expect pyhton:3.5+ to depend on Python 3.6 modules.


----------

