Python Forum
Can copyright be applied python scripts? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Can copyright be applied python scripts? (/thread-20873.html)



Can copyright be applied python scripts? - tim777 - Sep-04-2019

Can copyright be applied to python scripts?


RE: Can copyright be applied python scripts? - buran - Sep-04-2019

the real question is how you will enforce it and is it worth the efforts?
i.e. it's up to you under what license terms you will distribute your work (i.e. that's legal matter)


RE: Can copyright be applied python scripts? - metulburr - Sep-04-2019

You can put any license terms you want on your scripts. Like buran said, the trouble of enforcing it is usually not worth it. Anything can be reversed engineered. Even Windows exe files can be tapped into. But python's are much easier to break into as it was never intended to be closed software.
https://stackoverflow.com/questions/261638/how-do-i-protect-python-code


RE: Can copyright be applied python scripts? - DeaD_EyE - Sep-04-2019

You can work with importlib.ressources, which is not so painful.

C:\Users\Admin\Desktop\example_with_ressources    
λ tree /F                                         
Auflistung der Ordnerpfade                        
Volumeseriennummer : 6CC1-07AC                    
C:.                                               
│   test.py                                       
│   test.spec                                     
│                                                 
└───data                                          
        test1.txt                                 
        test2.txt                                 
        test3.txt                                 
        __init__.py                               
                                                  
test.py
from importlib import resources
import data # <- import of package with data files


with resources.path(data, 'test1.txt') as p:
    print(p, type(p)) # <- pathlib object
    print(p.read_text())
    

print(resources.read_text(data, 'test2.txt'))
print(resources.read_text(data, 'test3.txt'))
test.spec
# -*- mode: python ; coding: utf-8 -*-                        
                                                              
block_cipher = None                                           
                                                              
                                                              
a = Analysis(['test.py'],                                     
             pathex=['.'],                                    
             binaries=[],                                     
             datas=[                                          
                ('data/test1.txt', 'data'),                   
                ('data/test2.txt', 'data'),                   
                ('data/test3.txt', 'data'),                   
             ],                                               
             hiddenimports=[],                                
             hookspath=[],                                    
             runtime_hooks=[],                                
             excludes=[],                                     
             win_no_prefer_redirects=False,                   
             win_private_assemblies=False,                    
             cipher=block_cipher,                             
             noarchive=False)                                 
pyz = PYZ(a.pure, a.zipped_data,                              
             cipher=block_cipher)                             
exe = EXE(pyz,                                                
          a.scripts,                                          
          a.binaries,                                         
          a.zipfiles,                                         
          a.datas,                                            
          [],                                                 
          name='test',                                        
          debug=False,                                        
          bootloader_ignore_signals=False,                    
          strip=False,                                        
          upx=True,                                           
          upx_exclude=[],                                     
          runtime_tmpdir=None,                                
          console=True )                                      
                                                              
The variable datas must be edited to copy non-python files into the executable file.
Running the creation of exe-file:

Result:
Output:
C:\Users\Admin\Desktop\example_with_ressources λ dist\test.exe C:\Users\Admin\AppData\Local\Temp\_MEI110682\data\test1.txt <class 'pathlib.WindowsPath'> test x Hi