# Installation of py37-sqlite3 from ports



## olav (Jan 17, 2019)

Installing this package from pkg is easy and works great

```
sudo pkg install py37-sqlite3
```

But how can I install it from ports?

When I write

```
sudo make -C /usr/ports/databases/py-sqlite3 PYTHON_VERSION=python3.7 deinstall install clean
```

It will just install for Python 2.7 

Output:

```
===>  Deinstalling for py27-sqlite3
===>   Deinstalling py27-sqlite3-2.7.15_7
Updating database digests format: 100%
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        py27-sqlite3-2.7.15_7

Number of packages to be removed: 1
[1/1] Deinstalling py27-sqlite3-2.7.15_7...
[1/1] Deleting files for py27-sqlite3-2.7.15_7: 100%
===>  License PSFL accepted by the user
===>   py27-sqlite3-2.7.15_7 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by py27-sqlite3-2.7.15_7 for building
===>  Extracting for py27-sqlite3-2.7.15_7
=> SHA256 Checksum OK for python/Python-2.7.15.tar.xz.
===>  Patching for py27-sqlite3-2.7.15_7
===>   py27-sqlite3-2.7.15_7 depends on package: py27-setuptools>0 - found
===>   py27-sqlite3-2.7.15_7 depends on file: /usr/local/bin/python2.7 - found
===>   py27-sqlite3-2.7.15_7 depends on shared library: libsqlite3.so - found (/usr/local/lib/libsqlite3.so)
===>  Configuring for py27-sqlite3-2.7.15_7
running config
===>  Building for py27-sqlite3-2.7.15_7
running build
running build_ext
building '_sqlite3' extension
creating build
creating build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7
creating build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/cache.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/cache.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/connection.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/connection.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/cursor.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/cursor.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/microprotocols.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/microprotocols.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/module.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/module.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/prepare_protocol.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/prepare_protocol.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/row.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/row.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/statement.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/statement.o
cc -DNDEBUG -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing -fPIC -DMODULE_NAME="sqlite3" -I/usr/local/include -IModules/_sqlite -I/usr/local/include/python2.7 -c _sqlite/util.c -o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/util.o
creating build/lib.freebsd-11.2-RELEASE-p4-amd64-2.7
cc -shared -fstack-protector -O2 -pipe -march=native -fstack-protector -fno-strict-aliasing build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/cache.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/connection.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/cursor.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/microprotocols.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/module.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/prepare_protocol.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/row.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/statement.o build/temp.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite/util.o -L/usr/local/lib -L/usr/local/lib -Wl,-rpath=/usr/local/lib -lsqlite3 -lpython2.7 -o build/lib.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite3.so
===>  Staging for py27-sqlite3-2.7.15_7
===>   py27-sqlite3-2.7.15_7 depends on package: py27-setuptools>0 - found
===>   py27-sqlite3-2.7.15_7 depends on file: /usr/local/bin/python2.7 - found
===>   Generating temporary packing list
running install
running build
running build_ext
running install_lib
creating /usr/ports/databases/py-sqlite3/work-py27/stage/usr/local/lib/python2.7
creating /usr/ports/databases/py-sqlite3/work-py27/stage/usr/local/lib/python2.7/lib-dynload
copying build/lib.freebsd-11.2-RELEASE-p4-amd64-2.7/_sqlite3.so -> /usr/ports/databases/py-sqlite3/work-py27/stage/usr/local/lib/python2.7/lib-dynload
running install_egg_info
running egg_info
creating sqlite3.egg-info
writing sqlite3.egg-info/PKG-INFO
writing top-level names to sqlite3.egg-info/top_level.txt
writing dependency_links to sqlite3.egg-info/dependency_links.txt
writing manifest file 'sqlite3.egg-info/SOURCES.txt'
reading manifest file 'sqlite3.egg-info/SOURCES.txt'
writing manifest file 'sqlite3.egg-info/SOURCES.txt'
Copying sqlite3.egg-info to /usr/ports/databases/py-sqlite3/work-py27/stage/usr/local/lib/python2.7/lib-dynload/sqlite3-0.0.0-py2.7.egg-info
running install_scripts
writing list of installed files to '/usr/ports/databases/py-sqlite3/work-py27/.PLIST.pymodtmp'
/usr/bin/strip /usr/ports/databases/py-sqlite3/work-py27/stage/usr/local/lib/python2.7/lib-dynload/_sqlite3.so
====> Compressing man pages (compress-man)
===>  Installing for py27-sqlite3-2.7.15_7
===>  Checking if py27-sqlite3 already installed
===>   Registering installation for py27-sqlite3-2.7.15_7
Installing py27-sqlite3-2.7.15_7...
===>  Cleaning for py27-sqlite3-2.7.15_7
===>  Cleaning for py36-sqlite3-3.6.8_7
===>  Cleaning for py37-sqlite3-3.7.2_7
===>  Cleaning for py35-sqlite3-3.5.6_7
```

The following installed packages

```
$ pkg info | grep py
py27-Babel-2.3.4               Collection of tools for internationalizing Python applications
py27-Jinja2-2.9.5              Fast and easy to use stand-alone template engine
py27-MarkupSafe-1.0            Implements XML/HTML/XHTML Markup safe string for Python
py27-alabaster-0.7.6           Modified Kr Sphinx theme
py27-asn1crypto-0.22.0         ASN.1 library with a focus on performance and a pythonic API
py27-certifi-2018.4.16         Mozilla SSL certificates
py27-cffi-1.11.5               Foreign Function Interface for Python calling C code
py27-chardet-3.0.4             Universal encoding detector for Python 2 and 3
py27-cryptography-2.3          Cryptographic recipes and primitives for Python developers
py27-docutils-0.14             Python Documentation Utilities
py27-enum34-1.1.6              Python 3.4 Enum backported to 3.3, 3.2, 3.1, 2.7
py27-idna-2.7                  Internationalized Domain Names in Applications (IDNA)
py27-imagesize-0.7.1           Python image size library
py27-ipaddress-1.0.22          Port of Python 3.3+ ipaddress module to 2.7
py27-lxml-4.1.1                Pythonic binding for the libxml2 and libxslt libraries
py27-openssl-17.5.0_1          Python interface to the OpenSSL library
py27-pip-9.0.1                 Tool for installing and managing Python packages
py27-pycparser-2.18            C parser in Python
py27-pygments-2.2.0            Syntax highlighter written in Python
py27-pysocks-1.6.8             Python SOCKS module
py27-pystemmer-1.3.0_1         Snowball Stemming Algorithms for Information Retrieval
py27-pytest-runner-2.11.1      Test support for pytest runner in setup.py
py27-pytz-2017.2,1             World Timezone Definitions for Python
py27-requests-2.18.4_1         HTTP library written in Python for human beings
py27-setuptools-36.2.2         Python packages installer
py27-setuptools_scm-1.17.0     Setuptools plugin to manage your versions by scm tags
py27-six-1.10.0                Python 2 and 3 compatibility utilities
py27-snowballstemmer-1.2.0_1   Snowball stemming library collection for Python
py27-sphinx-1.4.8_2,1          Python documentation generator
py27-sphinx_rtd_theme-0.2.4    Mobile-friendly py-sphinx theme
py27-sqlite3-2.7.15_7          Standard Python binding to the SQLite3 library (Python 2.7)
py27-termcolor-1.1.0_1         ANSII Color formatting for output in terminal
py27-urllib3-1.22,1            HTTP library with thread-safe connection pooling, file post, and more
py27-virtualenv-15.1.0         Tool for creating isolated Python environments
py37-setuptools-40.6.2         Python packages installer
python2-2_3                    The "meta-port" for version 2 of the Python interpreter
python27-2.7.15                Interpreted object-oriented programming language
python37-3.7.2                 Interpreted object-oriented programming language
```


----------



## SirDice (Jan 17, 2019)

`make FLAVOR=py37 {.....}`


----------



## olav (Jan 17, 2019)

Awesome! That was fast!

Another question though, how did you figure this out? I've been reading the make file and other source files and reading through the mailing list.


----------



## SirDice (Jan 17, 2019)

olav said:


> Another question though, how did you figure this out?


Not sure where I picked it up. Probably right here on the forums 

I've used it myself a few times since then (taking a Python training for work). As they say, the best way to learn a thing is by doing that thing.


----------



## olav (Jan 18, 2019)

I think I found the source. There is a snippet about Python supporting FLAVOR, mentioned November 2017 in /usr/ports/UPDATING. Which concludes I need to learn to read that file


----------



## SirDice (Jan 18, 2019)

Reading /usr/ports/Mk/Uses/python.mk can also be quite enlightening.


----------

