How do I protect Python code?

I am developing a piece of software in Python that will be distributed to my employer's customers. My employer wants to limit the usage of the software with a time restricted license file. If we distribute the .py files or even .pyc files it will be easy to (decompile and) remove the code that checks the license file. Another aspect is that my employer does not want the code to be read b

我如何保护Python代码?

我正在开发一个Python软件,将分发给我的雇主的客户。 我的雇主希望限制软件的使用时间限制许可证文件。 如果我们分发.py文件或甚至.pyc文件,将很容易(反编译)并删除检查许可证文件的代码。 另一方面是我的雇主不希望我们的客户阅读代码,担心代码可能被盗用,或者至少是“新颖的想法”。 有没有解决这个问题的好方法? 最好采用现成的解决方案。 该软件将在Linux系统上运行(所以我不认为py2exe会做到这一点)。 P

glDrawElements to draw a cube in PyOpenGL

I recently started to learn OpenGL through Python thanks to several tutorial (especially the Nicolas P. Rougier one: http://www.labri.fr/perso/nrougier/teaching/opengl/). I am now switching to 3D and I am trying to draw a cube. Thus, I manage to get some triangles which do not render a cube (this seems to be normal as I do not duplicate my vertices and I use the glDrawArrays function). Howe

glDrawElements在PyOpenGL中绘制一个立方体

我最近开始通过Python学习OpenGL,这要归功于几个教程(特别是Nicolas P. Rougier:http://www.labri.fr/perso/nrougier/teaching/opengl/)。 我现在切换到3D,我正在尝试绘制一个立方体。 因此,我设法得到一些不渲染立方体的三角形(这似乎是正常的,因为我不重复我的顶点,并使用glDrawArrays函数)。 然而,之后,我建立了一个索引“vector”来进一步使用glDrawElements函数来渲染我的立方体。 结果,我没有得到任何错

Why I cannot rotate my cube in PyOpenGL?

I am trying to rotate my cube when I pushed the key 'r' (keyevent), I am using Pyopengl, but I don't know why this doesn't it. This is a part of my code. def init(): glMatrixMode (GL_PROJECTION) glClearColor(0.529, 0.529, 0.529, 0.0)#Definimos color de ventana glColor3f(0.0, 1.0, 1.0)#Definimos color inicial para el cubo def dibujarCubo(): glClear (GL_COLOR_BUFFER

为什么我不能在PyOpenGL中旋转我的多维数据集?

当我按下'r'(keyevent)键时,我试图旋转我的多维数据集,我使用Pyopengl,但我不知道为什么不这样做。 这是我的代码的一部分。 def init(): glMatrixMode (GL_PROJECTION) glClearColor(0.529, 0.529, 0.529, 0.0)#Definimos color de ventana glColor3f(0.0, 1.0, 1.0)#Definimos color inicial para el cubo def dibujarCubo(): glClear (GL_COLOR_BUFFER_BIT) glColor3f (1.0, 1.0, 1.0) glL

Rotation matrix to quaternion equivalence

I am tracking 3 points (3D, xyz) on a rigid body, which I use to define a local coordinate system. I am using this local coordinate system's orientation (in the global frame of reference) to set the view orientation in a VR program. To do this, and avoid gimbal-lock with Euler angles, I am attempting to use a quaternion to set the view orientation. I create a rotation matrix from the 3 po

旋转矩阵到四元数等价

我正在跟踪刚体上的3个点(3D,xyz),我用它来定义局部坐标系。 我使用这个局部坐标系的方向(在全局参照系中)来设置VR程序中的视图方向。 要做到这一点,并避免使用欧拉角的万向节锁,我试图使用四元数来设置视图方向。 我从3个点创建一个旋转矩阵,然后使用维基百科上描述的这种方法来提取假定的等价四元数。 然后,我简单地将视图方向设置为计算的四元数。 然而,我观察到,当我也能够同时看到偏航和摇摆的变化时,

pylab/networkx; no node labels displayed after update

After I have updated matplotlib to the current version I encounter a problem with node labels in networkX: if I use the nx.draw(G) command, I get a graph, but no labels are displayed. But let's speak with examples: import networkx as nx import matplotlib.pylab as plt T=nx.Graph() T.add_edge(0,1) nx.draw(T) plt.show() this returns a valid plot, but with no node labels. Even if I pass the

pylab / networkx; 更新后不显示节点标签

在将matplotlib更新为当前版本后,我遇到了networkX中的节点标签问题:如果使用nx.draw(G)命令,我会看到一个图形,但没有显示标签。 但让我们来举例说明: import networkx as nx import matplotlib.pylab as plt T=nx.Graph() T.add_edge(0,1) nx.draw(T) plt.show() 这将返回一个有效的图,但没有节点标签。 即使我直接通过标签 import networkx as nx import matplotlib.pylab as plt T=nx.Graph() T.add_edge(0,1) la

Authentication With Imgur API

So I'm writing a simple-ish script that can automatically download images from Imgur. I've come across the Imgur API but am struggling to get it to work. I registered an app but am not sure how to use it to be able to get information about images or albums. I do not want to be able to log in as a user or anything like that - just provide a URL of an album or a single image and be able

使用Imgur API进行身份验证

所以我正在编写一个简单的脚本,可以自动从Imgur下载图像。 我遇到过Imgur API,但我正在努力让它发挥作用。 我注册了一个应用程序,但不知道如何使用它来获取有关图像或相册的信息。 我不想以用户身份或类似的方式登录 - 只需提供相册或单个图像的URL并能够下载它。 我读过,如果我想这样做,那么我不需要使用oauth的东西,我应该能够使用客户端ID。 https://www.reddit.com/r/learnprogramming/comments/2uzxfv/how_do_

403 error while getting data from Imgur api. Where am I going wrong?

From the imgur api page: For public read-only and anonymous resources, such as getting image info, looking up user comments, creating an anonymous album, etc. all you need to do is send an authorization header with your client_id along with your requests. This also works if you'd like to upload images anonymously (without the image being tied to an account). This lets us know which applic

从Imgur api获取数据时出现403错误。 我哪里错了?

从imgur api页面: 对于公共只读和匿名资源,例如获取图像信息,查找用户评论,创建匿名相册等,您只需发送带有您的client_id的授权标头以及您的请求。 如果你想匿名上传图片(没有图片绑定到帐户),这也可以。 这让我们知道哪个应用程序正在访问API。 这是我使用python-requests的请求: payload = {"Client-ID":"my client id"} r=requests.get("https://api.imgur.com/3/account/imgur/images/0.json?perPage=42&

Memoryview on c array in cython

Error initializing memoryview variable. This is my code: cdef int *popref = <int*>malloc(popsize * sizeof(int)) cdef int [:] popref_mv = popref And this is the error I am getting: Error: cdef int [:] popref_mv = popref ^ Expected an identifier or literal Running Python 2.6.6, GCC 4.4.7, Cython 0.14.1 on Red Hat Linux.

在cython中的c数组上的Memoryview

初始化memoryview变量时出错。 这是我的代码: cdef int *popref = <int*>malloc(popsize * sizeof(int)) cdef int [:] popref_mv = popref 这是我得到的错误: Error: cdef int [:] popref_mv = popref ^ Expected an identifier or literal 在Red Hat Linux上运行Python 2.6.6,GCC 4.4.7,Cython 0.14.1。

Seg Fault on Large Arrays?

Seeing strange behavior for even very small simple integer arrays. %%cython import numpy as np cimport cython cimport numpy as np def hi(): DEF MAX = 10000000 cdef int a[MAX],i cdef int[:] a_mv = a This crashes, but views into smaller views perform mine. This isn't obvious a memory issue as there's ample RAM for 10 million ints... As Kevin mentions in his comment, the pr

在大阵列上出现故障?

即使非常小的简单整数数组也会看到奇怪的行为。 %%cython import numpy as np cimport cython cimport numpy as np def hi(): DEF MAX = 10000000 cdef int a[MAX],i cdef int[:] a_mv = a 这崩溃了,但意见成小视图执行我的。 这不是一个明显的内存问题,因为有1000万内存的足够内存...... 正如Kevin在评论中提到的那样,问题不在于RAM,而在于堆栈。 您正在堆栈中分配一千万个元素的数组,当您真的应该使用

Wrapping a C library in Python: C, Cython or ctypes?

I want to call a C library from a Python application. I don't want to wrap the whole API, only the functions and datatypes that are relevant to my case. As I see it, I have three choices: Create an actual extension module in C. Probably overkill, and I'd also like to avoid the overhead of learning extension writing. Use Cython to expose the relevant parts from the C library to Pytho

用Python包装C库:C,Cython还是ctypes?

我想从Python应用程序调用C库。 我不想包装整个API,只包含与我的案例相关的函数和数据类型。 正如我所看到的,我有三个选择: 在C中创建一个实际的扩展模块可能是过度的,我也想避免学习扩展写入的开销。 使用Cython将C库中的相关部分公开给Python。 在Python中完成整个事情,使用ctypes与外部库进行通信。 我不确定2)或3)是否是更好的选择。 3)的优点是ctypes是标准库的一部分,所产生的代码将是纯Python--尽管