"How to package additional files under site-packages "

2019-03-04 Thread Saba Kauser
Hello,

I have a setup.py that has this:
package_data = { 'tests': [ '*.png', '*.jpg']}
data_files = [ ('', ['./README.md']),
   ('', ['./CHANGES']),
   ('', ['./LICENSE']) ]

setup( name= PACKAGE,
   version = VERSION,
.
.
   packages = find_packages(),
   package_data = package_data,
   data_files   = data_files,
   include_package_data = True,
.
)

This setup is copying README.md, CHANGES and LICENSE files under python-install 
path/Lib
e.g:
/Library/Frameworks/Python.framework/Versions/3.7/CHANGES
/Library/Frameworks/Python.framework/Versions/3.7/LICENSE
/Library/Frameworks/Python.framework/Versions/3.7/README.md

And my package is installed under :
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ibm_db.cpython-37m-darwin.so

I want data_files to be copied under my package install path.
How do I achieve this?

Thanks in advance!
Saba.


Saba Kauser
Db2 Connect development and support.

Rocket Software Development India Pvt Ltd
Karle Town Centre - SEZ,
HUB 1 building, 4th Floor (North West Wing),
100 ft. Kempapura road, adjacent to Nagawara lake,
Nagawara, Bangalore - 560 045
E: [email protected]<mailto:[email protected]>
-



Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA 02451 ? 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: "How to package additional files under site-packages "

2019-03-05 Thread Saba Kauser
Thanks!
My package (ibm_db) has LICENSE, README.md and CHANGES files that I want to be 
available in the same location as my package is installed I.e under 
site-packages. However, with current setup.py 
https://github.com/ibmdb/python-ibmdb/blob/master/IBM_DB/ibm_db/setup.py, these 
files get installed under python install path.
e.g: C:\Users\skauser\AppData\Local\Programs\Python\Python36\LICENSE

I have specified them as:
data_files = [ ('', ['./README.md']),
   ('', ['./CHANGES']),
   ('', ['./LICENSE']) ]

Setup(
..
package_data = package_data,
   data_files   = data_files,
   include_package_data = True,
  cmdclass = cmd_class,
..)

Since the directory path is empty, these files get copied under current path of 
execution. However, I want them to be copied under the install location of my 
package.
Is there any other way I can achieve this?

Thanks!

-Original Message-
From: dieter 
Sent: Tuesday, March 5, 2019 12:04 PM
To: [email protected]
Subject: Re: "How to package additional files under site-packages "

Saba Kauser  writes:
> ...
> I want data_files to be copied under my package install path.
> How do I achieve this?

You could look at one of my packages (i.e. "dm.*", e.g. "dm.pdb").

Essentially, I have the data files besides the Python sources and let 
"setuptools" determine the relevant files (sources and data) as those managed 
via a source code control system (=SCCS). For the latter to work, your Python 
must have installed the integration module for your SCCS.



Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: "How to package additional files under site-packages "

2019-03-07 Thread Saba Kauser
Thank you!
I used get_python_lib() for directory in data_files, and it seem to have worked.

Thanks for your assistance!

-Original Message-
From: dieter 
Sent: Wednesday, March 6, 2019 12:15 PM
To: [email protected]
Subject: Re: "How to package additional files under site-packages "

Saba Kauser  writes:
> ...
> My package (ibm_db) has LICENSE, README.md and CHANGES files that I want to 
> be available in the same location as my package is installed I.e under 
> site-packages. However, with current setup.py 
> https://github.com/ibmdb/python-ibmdb/blob/master/IBM_DB/ibm_db/setup.py, 
> these files get installed under python install path.
> e.g: C:\Users\skauser\AppData\Local\Programs\Python\Python36\LICENSE
>
> I have specified them as:
> data_files = [ ('', ['./README.md']),
>('', ['./CHANGES']),
>('', ['./LICENSE']) ]
>
> Setup(
> ..
> package_data = package_data,
>data_files   = data_files,
>include_package_data = True,
>   cmdclass = cmd_class,
> ..)
>
> Since the directory path is empty, these files get copied under current path 
> of execution. However, I want them to be copied under the install location of 
> my package.
> Is there any other way I can achieve this?

As you do not want to follow my example, maybe read the "setuptools" 
documentation.

There definitely is a way to achieve your goal -- other than my approach. If 
necessary override parts of the "distutils/setuptools"
machinery.



Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


"Post install setup does not work as expected with pip install"

2019-03-12 Thread Saba Kauser
Hello,

I have a post install class that looks like this:
if('darwin' in sys.platform):
class PostInstall(install):
""" Post installation - run install_name_tool on Darwin """
def run(self):
clipath = os.getenv('IBM_DB_HOME', '@loader_path/clidriver')
print("in PostInstall with {}".format(clipath))
for so in glob.glob(r'build/lib*/ibm_db*.so'):
os.system("install_name_tool -change libdb2.dylib 
{}/lib/libdb2.dylib {}".format(clipath, so))
install.run(self)
cmd_class = dict(install = PostInstall)


And I pass cmd_class to setup(..) as:
setup(..
  include_package_data = True,
   cmdclass = cmd_class,
   **extra
 )

When I execute setup.py as "python setup.py install", then the PostInstall 
operation is executed after the ibm_db.so is built and installed and I see the 
intended result.
Howeever, when I run "pip install ibm_db" or "pip install .",
the execution order looks like this:
  warnings.warn(notifyString)
running install
in PostInstall with /Applications/dsdriver/  ==> this is my post install 
script
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7==> I need to traverse to this 
folder to find my shared library

I would expect it to be run post the ibm_db is installed, not before it gets 
built.

Can you please let me know how can this be fixed. Is this a bug with pip?


Saba Kauser
Db2 Connect development and support.

Rocket Software Development India Pvt Ltd
Karle Town Centre - SEZ,
HUB 1 building, 4th Floor (North West Wing),
100 ft. Kempapura road, adjacent to Nagawara lake,
Nagawara, Bangalore - 560 045
E: [email protected]<mailto:[email protected]>
-



Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA 02451 ? 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: "Post install setup does not work as expected with pip install"

2019-03-13 Thread Saba Kauser
I am able to get this to work.
I had to invoke parent's run before my post install logic could kick.

_
From: Saba Kauser
Sent: Tuesday, March 12, 2019 6:01 PM
To: [email protected]
Subject: "Post install setup does not work as expected with pip install"


Hello,

I have a post install class that looks like this:
if('darwin' in sys.platform):
class PostInstall(install):
""" Post installation - run install_name_tool on Darwin """
def run(self):
clipath = os.getenv('IBM_DB_HOME', '@loader_path/clidriver')
print("in PostInstall with {}".format(clipath))
for so in glob.glob(r'build/lib*/ibm_db*.so'):
os.system("install_name_tool -change libdb2.dylib 
{}/lib/libdb2.dylib {}".format(clipath, so))
install.run(self)
cmd_class = dict(install = PostInstall)


And I pass cmd_class to setup(..) as:
setup(..
  include_package_data = True,
   cmdclass = cmd_class,
   **extra
 )

When I execute setup.py as "python setup.py install", then the PostInstall 
operation is executed after the ibm_db.so is built and installed and I see the 
intended result.
Howeever, when I run "pip install ibm_db" or "pip install .",
the execution order looks like this:
  warnings.warn(notifyString)
running install
in PostInstall with /Applications/dsdriver/  ==> this is my post install 
script
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7==> I need to traverse to this 
folder to find my shared library

I would expect it to be run post the ibm_db is installed, not before it gets 
built.

Can you please let me know how can this be fixed. Is this a bug with pip?


Saba Kauser
Db2 Connect development and support.

Rocket Software Development India Pvt Ltd
Karle Town Centre - SEZ,
HUB 1 building, 4th Floor (North West Wing),
100 ft. Kempapura road, adjacent to Nagawara lake,
Nagawara, Bangalore - 560 045
E: [email protected]<mailto:[email protected]>
-



Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA 02451 ? 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


"get_python_lib() :for pip install, data_files with get_python_lib() are copied with duplicate path name on ubuntu"

2019-04-08 Thread Saba Kauser
Hi there,

I have the following in setup.py :
from distutils.sysconfig import get_python_lib

data_files = [ (get_python_lib(), ['./README.md']),
(get_python_lib(), ['./LICENSE']),
 (get_python_lib(), ['./CHANGES']),
(get_python_lib(), ['./config.py.sample'])]


setup( name = PACKAGE,
version = VERSION,
license = LICENSE,
description = 'Python DBI driver for DB2 (LUW, zOS, i5) and IDS',
author = 'IBM Application Development Team',
.
.
data_files = data_files,
include_package_data = True,
cmdclass = cmd_class,
**extra
)
Can be seen at : 
https://github.com/ibmdb/python-ibmdb/blob/master/IBM_DB/ibm_db/setup.py#L286

On:
Distributor ID: Ubuntu
Description:Ubuntu 16.04.3 LTS
Release:16.04
Codename:   xenial

Pip install is copying files under a duplicate append of current site-package 
path. E.g:

/work/skauser/python_installations/python27/lib/python2.7/site-packages/work/skauser/python_installations/python27/lib/python2.7/site-packages/CHANGES

/work/skauser/python_installations/python27/lib/python2.7/site-packages/work/skauser/python_installations/python27/lib/python2.7/site-packages/LICENSE

/work/skauser/python_installations/python27/lib/python2.7/site-packages/work/skauser/python_installations/python27/lib/python2.7/site-packages/README.md

/work/skauser/python_installations/python27/lib/python2.7/site-packages/work/skauser/python_installations/python27/lib/python2.7/site-packages/config.py.sample

On other platforms, the files are correctly copied under 
/work/skauser/python_installations/python27/lib/python2.7/site-packages.
>From python command line on ubuntu, get_python_lib() returns the correct path:
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.sysconfig import get_python_lib
>>> get_python_lib()
'/work/skauser/python_installations/python27/lib/python2.7/site-packages'

I need to know why is the incorrect behavior while using pip.

Building the source as:
Python setup.py build
Python setup.py install
Copies the files correctly.

Any help is appreciated!
Thanks.

Saba Kauser
Db2 Connect development and support.

Rocket Software Development India Pvt Ltd
Karle Town Centre - SEZ,
HUB 1 building, 4th Floor (North West Wing),
100 ft. Kempapura road, adjacent to Nagawara lake,
Nagawara, Bangalore - 560 045
E: [email protected]<mailto:[email protected]>
-



Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA 02451 ? 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


"How to protect the python code"

2019-09-05 Thread Saba Kauser
Hello Experts,

I am looking for ways available to protect the python source code from being 
available to users for write/modify.
Is it a good idea to think that python source code can be protected?

I am aware that there are ways available to generate extensions like in C(.pyd 
files) and module the sensitive code likewise, but are there any better options 
available for protecting the native python source code itself. My requirement 
is to have the application/source in native python and not intermediate to 
other languages.

Please share your thoughts.

Thanks!

Saba Kauser
E: [email protected]<mailto:[email protected]>
-



Rocket Software, Inc. and subsidiaries ? 77 Fourth Avenue, Waltham MA 02451 ? 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: "How to protect the python code"

2019-09-05 Thread Saba Kauser
Thanks Chris.
Makes sense!


-Original Message-
From: Chris Angelico 
Sent: Thursday, September 5, 2019 2:34 PM
To: [email protected]
Subject: Re: "How to protect the python code"

On Thu, Sep 5, 2019 at 6:50 PM Saba Kauser  wrote:
>
> Hello Experts,
>
> I am looking for ways available to protect the python source code from being 
> available to users for write/modify.

Run it on a server and don't let them see the source code.

> Is it a good idea to think that python source code can be protected?

Nope. If you're going to ship Python code for people to run on their own 
systems - or, honestly, *any* code - you should assume that they can read it 
themselves. The only way is to NOT ship the code, which (in today's world) 
usually means publishing it as a web app.

ChrisA


Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■ 
Main Office Toll Free Number: +1 855.577.4323
Contact Customer Support: 
https://my.rocketsoftware.com/RocketCommunity/RCEmailSupport
Unsubscribe from Marketing Messages/Manage Your Subscription Preferences - 
http://www.rocketsoftware.com/manage-your-email-preferences
Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy


This communication and any attachments may contain confidential information of 
Rocket Software, Inc. All unauthorized use, disclosure or distribution is 
prohibited. If you are not the intended recipient, please notify Rocket 
Software immediately and destroy all copies of this communication. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list