Is there any way to publish pyarmor obfuscated python package which is python version independent?

389 Views Asked by At

So I am trying to publish a proprietary python package and I am using pyarmor package to obfuscate it and then publish the obfuscated build on PyPi. It is working on the same python version environment, however as mentioned in the packaging-obfuscated-scripts it is version dependent and can not not be ran using any older or newer python version.

I have quite a heavy package, is there any way around this (avoiding building and maintaining package with different python version)?

EDIT: If not as mentioned in the documentation, is there any other way to achieve this?

1

There are 1 best solutions below

0
Brian61354270 On

Unfortunately no.

Under the hood, pyarmor creates a CPython extension module inside the "obfuscated" package. Extension modules are tied to a specific interpreter ABI, and need to be compiled separately for different minor releases of CPython (i.e., 3.10, 3.11, 3.12, etc.).

This is mentioned in the documentation linked in the question:

"when obfuscating scripts by Python 3.8, they can’t be run by Python 3.7, 3.9 etc."

As far as "avoiding building and maintaining package with different python version", this usually isn't a problem in practice. It's straightforward to build and publish wheels for multiple Python versions from a CI/CD workflow like GitHub Actions. PyPI even provides first-class support for doing so. See Publishing package distribution releases using GitHub Actions CI/CD workflows from the Python Packaging docs for an example of how this is done with GitHub. You can adapt the same principles to whatever CI/CD platform you use.