# Python Port Build Errors



## matt.lager (Nov 23, 2021)

I'm struggling to build several python ports after updating my ports tree over the past week... py38 ports result in errors similar to the one below. I tried completely rebuilding python38 which worked, but did not resolve the following issues. Any advice would be appreciated!

FreeBSD 13.0-RELEASE-p4 #3 releng/13.0-n244760-940681634ee

```
===>   py38-setuptools-57.0.0 depends on file: /usr/local/bin/python3.8 - found
===>  Configuring for py38-setuptools-57.0.0
Traceback (most recent call last):
  File "setup.py", line 100, in <module>
    dist = setuptools.setup(**setup_params)
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/lib/python3.8/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/setuptools/dist.py", line 455, in __init__
    _Distribution.__init__(self, {
  File "/usr/local/lib/python3.8/distutils/dist.py", line 292, in __init__
    self.finalize_options()
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/setuptools/dist.py", line 800, in finalize_options
    for ep in sorted(eps, key=by_order):
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/setuptools/dist.py", line 799, in <lambda>
    eps = map(lambda e: e.load(), pkg_resources.iter_entry_points(group))
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/pkg_resources/__init__.py", line 2449, in load
    self.require(*args, **kwargs)
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/pkg_resources/__init__.py", line 2472, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/var/ports/basejail/usr/ports/devel/py-setuptools/work-py38/setuptools-57.0.0/pkg_resources/__init__.py", line 772, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'packaging>=20.0' distribution was not found and is required by the application
*** Error code 1

Stop.
make: stopped in /basejail/usr/ports/devel/py-setuptools
```


----------



## SirDice (Nov 23, 2021)

Read /usr/ports/UPDATING:

```
20210425:
  AFFECTS: users of python
  AUTHOR: kai@FreeBSD.org

  The default version of python3 and python was switched to 3.8.

  For ports users wanting to keep version 3.7 as default,
  add DEFAULT_VERSIONS+= python=3.7 python3=3.7 to make.conf

  Following procedures may ease the upgrade:

  For users of pre-build packages:
  # sh
  # for i in $(pkg query -g %n 'py37-*'); do pkg set -yn ${i}:py38-${i#py37-}; done
  # pkg upgrade

  For portmaster users:
  # sh
  # portmaster -o lang/python38 python37
  # REINSTALL="$(pkg info -o "*py37*" | awk '{printf "%s ", $2}')"
  # pkg delete -f "*py37*"
  # portmaster $REINSTALL
  # REBUILD=$(pkg query -g "%n:%dn" '*' | grep py3 | grep -v py38 | cut -d : -f 1 | sort -u)
  # portmaster $REBUILD
  # REBUILD2=$(pkg list | grep python-37 | xargs pkg which | awk '{print $6}' | sort -u)
  # portmaster $REBUILD2
```


----------



## matt.lager (Nov 23, 2021)

SirDice said:


> Read /usr/ports/UPDATING:
> 
> ```
> 20210425:
> ...


That is from April 25th, 2021 so I am not sure that is my problem. I update ports tree every monday and perform upgrades via portmaster.I have python 3.8 installed and all modules are py38. My build problem is based on py38 as well so I don't think that UPDATING note is applicable.

The following was posted about 10 hours ago (from the time of this reply), so I know I am not the only one:





						259993 – devel/py-pyparsing: build failure: pkg_resources.DistributionNotFound: The 'packaging>=20.0' distribution was not found and is required by the application
					






					bugs.freebsd.org


----------



## SirDice (Nov 23, 2021)

matt.lager said:


> I update ports tree every monday and perform upgrades via portmaster.


Couldn't tell from the initial post. We have many users come here with build issues that update once a year or even less. 



matt.lager said:


> I have python 3.8 installed and all modules are py38.


Ok, that at least rules out any strange errors caused by having a few older modules around (that's quite a common issue). 



matt.lager said:


> so I know I am not the only one:


That's good to know but the official build clusters aren't having issues with building this. So the issue isn't caused by the port itself. It's often a combination of things, the build clusters build everything in a "clean" environment, so nothing else is installed. Sometimes just having package A installed will cause problems with building package B. We just need to figure out who's the culprit in this case.


----------



## matt.lager (Nov 23, 2021)

SirDice said:


> Couldn't tell from the initial post. We have many users come here with build issues that update once a year or even less.
> 
> 
> Ok, that at least rules out any strange errors caused by having a few older modules around (that's quite a common issue).
> ...


Looking again, all my jails updated fine except where I had bind916 installed, which pulls in a ridiculous amount of other ports that the build depends on, so at least I narrowed to that!


----------



## matt.lager (Nov 23, 2021)

matt.lager said:


> Looking again, all my jails updated fine except where I had bind916 installed, which pulls in a ridiculous amount of other ports that the build depends on, so at least I narrowed to that!


I'm going with a "pkg autoremove" to clean house, then use portmaster to update bind. Going to be a much longer build, but will post back to see if that does the trick.


----------



## SirDice (Nov 23, 2021)

matt.lager said:


> I'm going with a "pkg autoremove" to clean house


That would certainly help, you don't want to have old and unused dependencies lingering around.


----------



## matt.lager (Nov 23, 2021)

SirDice said:


> That would certainly help, you don't want to have old and unused dependencies lingering around.


I used to be more religious about doing autoremove, but it's bitten me a couple times specifically with MySQL and libraries being removed that it depended on. I can't remember the specific details but I couldn't figure out why MySQL wouldn't start, until I ran the mysqld binary by hand and it spit out a missing library error. Nonetheless, thanks for all the help!


----------



## ajs (Nov 23, 2021)

Same problem here.  As far as I can tell without digging too much is there seems to be a circular dependency on py-packaging that affects portmaster.

I addressed the problem with a manual install of devel/py-packaging  , and then resuming the portmaster updates.


----------



## Alain De Vos (Nov 24, 2021)

When you enable too many options you can end up into circular dependencies. But that's normal.


----------

