s3path icon indicating copy to clipboard operation
s3path copied to clipboard

Make boto3 dependency optional/soft for cases where only PureS3Path is needed

Open echernyavskiy opened this issue 2 years ago • 5 comments

Looking at the code it seems PureS3Path does not need anything from boto3. However boto3 is a hard requirement for s3path. This is problematic for environments like AWS Lambda Python runtime that has boto3 "built-in". Could boto3 be a soft dependency like awacs for troposphere for example?

echernyavskiy avatar Feb 15 '23 17:02 echernyavskiy

Hi @echernyavskiy Thanks for the issue :-)

I don't full understand your use case in AWS Lambda Python like you say you already have boto3 built-in So when you do import from s3path you don't have an issue. You want to install s3path without "reinstalling" boto3 again? is this your use case?

liormizr avatar Feb 16 '23 10:02 liormizr

@liormizr, right - since boto3 is "built into" the runtime, I don't have to define it as a dependency in my pyproject.toml / requirements.txt. Except s3path requires it, so it gets installed into the venv anyway. Could it be a soft dependency instead?

echernyavskiy avatar Feb 16 '23 11:02 echernyavskiy

Hi @echernyavskiy, Sorry for the delay.

We have an issue to move boto3 from the dependencies. Basically it means that all the users of this package will need to do change the way that thy install the package and that is a big change.

Now I don't see a nice way to exclude dependency. If you have an idea how to do so I'm open for suggestions Also I see that AWS do recommend to specify your boto3 version so there won't be surprises if AWS decide to change boto3 version.

liormizr avatar Mar 27 '23 07:03 liormizr

There does seem to be a lively discussion about this here: https://discuss.python.org/t/optional-dependency-groups-omitting-package-requirements/20833/1 - I agree that this would be useful. I have some libraries that need to manipulate both local filesystem paths and S3 paths, and the PureS3Path functionality would be extremely useful, but adding the full boto3 library as a required dependency is a non-starter since many consumers won't even use the AWS functionality.

plondino avatar May 20 '24 20:05 plondino

@plondino

Boto3 is currently a hard requirement
How ever in case you are using only PureS3Path it's not going to be loaded. We changed it so it will be lazy imported only when using S3Path.

liormizr avatar May 31 '24 06:05 liormizr