0

My team and I have built a Django app, that we need to distribute to other internals teams for testing. A traditional Django application consists of the following project structure -

  • parentfolder
    • djangoproject
    • djangoapp
    • manage.py
    • db.sqlite3

The code is inside djangoapp and djangoproject, which I'd like to password-protect. However, all the softwares that I've seen so far hide the folders, which then can be made visible only through that software itself. Once the folder is hidden, Django can't run the application anymore because it can't see the folders and the code inside them.

What I'd like is, for both the folders to be placed under password protection, but still be visible. For example, to open and see the contents of the folder, you'll have to enter a password, but the folders are still visible for the Django app to work.

1

The main issue that you'll likely run into is this: If Python can access your code and run it (allowing your application to work) then it would be fairly trivial for someone else to do the same.

I can't comment on your question to get more clarification on this, but what are the reasons exactly that you need to protect or hide these parts of the codebase? I can't think of many reasons why an internal QA team or testers wouldn't be trusted with (at least) read access to the source, depending on the type of testing being done.

With all that said, I think your best option would be to compile the parts of the codebase you want to protect into bytecode (.pyc) and distribute. Although, as I mentioned above, it's easy for someone to decompile the bytecode. You can accomplish this in a few different ways, the most common methods of packaging a Python application into an executable would be Py2App and Py2exe. Alternatively, you could also use Cython to compile to C code and then distribute the (.pyd) binary. Refer to Python wiki link below for links to the tools mentioned above, as I cannot post an answer with more than 2 links due to my reputation points.

Personally, if I was in this position and needed to distribute a Python application to testers without revealing any source code, I would simply start up the Python application as a SaaS and share with testers that way.

Refer to the Python wiki, specifically the section on "Protecting Source Code"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.