AWS SAM CLI - Looking for help

Jackson Isaac ijackson at macports.org
Tue Dec 17 19:38:42 UTC 2019


Hi Björn,

On Mon, Dec 16, 2019 at 2:51 PM Björn Raupach via macports-dev
<macports-dev at lists.macports.org> wrote:
>
> Hi there,
>
> would anyone mind helping me? I am not very experienced with Portfile development and I know little about Python, which makes this all very cumbersome (but fun).

Welcome to The MacPorts Project! We are here to help :)

>
> I am trying to setup a Portfile for AWS SAM CLI: https://github.com/awslabs/aws-sam-cli
>
> My problem is dealing with Python dependencies. I know Python people have pip, conda and virtualenv - probably more. In MacPorts I can work with Port dependencies: depends_build-append, depends_lib-append and so on. I just don’t know how to put all of them together.
>
> There is a Port for the AWS CLI (py-awscli). I went ahead and did a lot of copy & paste, trying to figure things out.
>
> I created 2 ports: py-aws-sam-cli and was-sam-cli_select. So far I managed to download aws-sam-cli from https://pypi.org, but I end up with a runtime exception.
>
> $ sam
> Traceback (most recent call last):
>   File "/opt/local/bin/sam", line 6, in <module>
>     from pkg_resources import load_entry_point
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3251, in <module>
>     @_call_aside
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3235, in _call_aside
>     f(*args, **kwargs)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
>     working_set = WorkingSet._build_master()
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 583, in _build_master
>     ws.require(__requires__)
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 900, in require
>     needed = self.resolve(parse_requirements(requirements))
>   File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 786, in resolve
>     raise DistributionNotFound(req, requirers)
> pkg_resources.DistributionNotFound: The 'tomlkit==0.5.8' distribution was not found and is required by aws-sam-cli
>
> How to deal with missing dependencies in Python? Do I need py-tomlkit and create a MacPorts dependency on that port?
>

Yes, you are indeed correct. You would need to create py-ports for any
missing dependency packages e.g., tomlkit. You might have more
dependencies further down. Happened when I was creating my first
py-port as well :)

Adding a dependency for py-port is something similar to what you have here [1].

I am not so experience with depends_build or depends_lib, but
sometimes I follow trial and error, or look at other ports, how they
use it.

For more information on dependencies, you may look at the guide [2].

> My current work is here https://github.com/raupachz/macports-ports/tree/aws-sam-cli
>
> And here is just the Portfile for py-aws-sam-cli: https://github.com/raupachz/macports-ports/blob/aws-sam-cli/python/py-aws-sam-cli/Portfile
>
>
> Thank you all for the time and effort that goes into MacPorts!
> /Björn

[1] https://github.com/raupachz/macports-ports/blob/aws-sam-cli/python/py-aws-sam-cli/Portfile#L33
[2] https://guide.macports.org/#reference.dependencies

-- 
Jackson Isaac


More information about the macports-dev mailing list