2

I am trying to use build-pyarmored-wheel to build a company project, I am following steps as described in 

https://pyarmor.readthedocs.io/en/latest/build-wheel.html?highlight=pyproject.toml#build-pyarmored-wheel

content of pyproject.toml

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

produces
Building wheels for collected packages: company-project
  Building wheel for company-project (pyproject.toml) ... done
  Created wheel for company-project: filename=company_project-1.0.0.0-py3-none-any.whl size=3906 sha256=dd639eb8fe24db685bb9b73576b7cdca656356211c935e031e08314b9d2ef562

when I change the content of pyproject.toml

[build-system]
requires = ["setuptools", "wheel", "pyarmor>7.2.0"]
build-backend = "pyarmor.build_meta"

error is generated is


  Building wheel for company-project (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/employee/.pyenv/versions/3.6.7/bin/python /Users/employee/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/cd/ztpbtx9x13x634f270x96mbxjqz_sg/T/tmp2mqap73h
       cwd: /Users/employee/DEV/company-project
  Complete output (12 lines):
  Traceback (most recent call last):
    File "/Users/employee/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
      main()
    File "/Users/employee/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/employee/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 262, in build_wheel
      metadata_directory)
    File "/private/var/folders/cd/ztpbtx9x13x634f270x96mbxjqz_sg/T/pip-build-env-euh9w736/overlay/lib/python3.6/site-packages/pyarmor/build_meta.py", line 100, in build_wheel
      config_settings = _fix_config(config_settings, obf_options)
    File "/private/var/folders/cd/ztpbtx9x13x634f270x96mbxjqz_sg/T/pip-build-env-euh9w736/overlay/lib/python3.6/site-packages/pyarmor/build_meta.py", line 72, in _fix_config
      from pip._internal.configuration import Configuration, ConfigurationError
  ModuleNotFoundError: No module named 'pip'
  ----------------------------------------
  ERROR: Failed building wheel for company-project
Failed to build company-project
ERROR: Failed to build one or more wheels



If it helps setup.py looks like as follows

from os import path
import re
from setuptools import find_packages, setup


def open_file(filepath, mode='r'):
    here = path.abspath(path.dirname(__file__))
    full_path = path.join(here, filepath)
    return open(full_path, mode)


def find_version(package):
    with open_file('{}/__init__.py'.format(package)) as f:
        return re.findall(r"^__version__ = '([^']+)'\r?$", f.read(), re.M)[0]


def find_requires():
    with open_file('requirements.txt') as f:
        return [line.strip() for line in f]


NAME = 'company-project'
VERSION = find_version('company_project’)
PACKAGES = find_packages()
REQUIRES = find_requires()

setup(
    name=NAME,
    version=VERSION,
    packages=PACKAGES,
    include_package_data=True,
    zip_safe=False,
    install_requires=REQUIRES
)

vector8188
  • 1,293
  • 4
  • 22
  • 48

1 Answers1

1

The method described in the linked guide is marked as not supported at the bottom of the page

Build pyarmored wheel is a helper function, there is no more support for this.

This is further confirmed on the github issues (like here)

Please check the documentation about wheel, there is no support for this feature.


What worked for me is to simply obfuscate the code first and generate the package from the obfuscated code

Make sure to include the pytransform library in the package using package_data with setuptools.

Mart10
  • 758
  • 3
  • 14