Solved How to build Python 2.7 ports?

eldaemon

Member

Reaction score: 7
Messages: 81

I know Python 2.7 is EOLed and generally not advised. That said, pkg search py27 comes up with lots of entries. I am not sure how I can install Python 2.7 variants through ports, however.

Thank you!
 

richardtoohey2

Active Member

Reaction score: 36
Messages: 102

I'm sure I've missed the point, but what happens if you try
Code:
cd /usr/ports/lang/python27/
make install
 
OP
E

eldaemon

Member

Reaction score: 7
Messages: 81

I don't mean the package for the language itself. I mean pip installables, like pip27-sqlite3 or py27-qt5.

Sorry for the confusion.
 

memreflect

Active Member

Reaction score: 63
Messages: 106

I don't mean the package for the language itself. I mean pip installables, like pip27-sqlite3 or py27-qt5.

Sorry for the confusion.
You want to build for the py27 "flavor". To do that, just add FLAVOR=py27 to the command line:

Code:
# Building databases/py-sqlite3
cd /usr/ports/databases/py-sqlite3

# No flavor specified, uses default Python version.
make clean install

# Python 2.7 flavor specified
make FLAVOR=py27 clean install

# Python 3.8 flavor specified
make FLAVOR=py38 clean install
You can also set default Python versions in /etc/make.conf:

Code:
DEFAULT_VERSIONS += python=3.8 python2=2.7 python3=3.8
That way, any port looking for python without a specific version requirement or python3 will use 3.8 and any port looking for python2 will use 2.7. I don't recommend setting python=2.7 because it's EOL. If you must build for Python 2.7, specify FLAVOR=py27 on the command line.
 
OP
E

eldaemon

Member

Reaction score: 7
Messages: 81

Awesome, thank you memreflect!

Was that in the docs somewhere that I missed?
 

memreflect

Active Member

Reaction score: 63
Messages: 106

Awesome, thank you memreflect!

Was that in the docs somewhere that I missed?
The closest thing to documentation for it that I found was in the Ports/FlavorsTools entry of the FreeBSD Wiki:
5. The chosen FLAVOR for a port origin should always be passed in as a make argument, not in the environment, like make -C devel/foo all FLAVOR=bar.
Unfortunately, I found nothing about ports flavors in ports(7), make.conf(5), /usr/ports/README, or 4.5 Using the Ports Collection in the FreeBSD Handbook. Maybe someone more knowledgeable will have a better reference.
 
Top