Skip to content

Update setup.py file#606

Merged
bimalkjha merged 1 commit intoibmdb:masterfrom
kparihar07:patch-1
Feb 23, 2021
Merged

Update setup.py file#606
bimalkjha merged 1 commit intoibmdb:masterfrom
kparihar07:patch-1

Conversation

@kparihar07
Copy link
Contributor

I am proposing to update setup.py file to dynamically read DB2 include dataset ($IBM_DB_HOME.SDSNC.H) from the environment variable.
Hardcoding this dataset in setup.py file creates problem for the application having custom dataset names.

I am proposing to update setup.py file to dynamically read DB2 include dataset ($IBM_DB_HOME.SDSNC.H) from the environment variable.
Hardcoding this dataset in setup.py file creates problem for the application having custom dataset names.
@bimalkjha bimalkjha merged commit 6d66a01 into ibmdb:master Feb 23, 2021
@amukherjee28
Copy link
Member

amukherjee28 commented Feb 23, 2021

I guess this is a standard set for using the naming convention.
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/inst/src/tpc/db2z_whatyouproduce.html

And hence this is kept hidden from user and the setup is done automatically.

introducing a new environment variable will create additional task for educating the already existing users.

I would appreciate your feedback on the same.

@AWADHAMBIKA
Copy link
Contributor

@kparihar7
Can you please provide your feedback on above?

@kparihar07 kparihar07 deleted the patch-1 branch February 24, 2021 07:02
@kparihar07
Copy link
Contributor Author

This is a required dataset for installing ibm_db package and have seen Applications are having same dataset defined with different names. Making this dataset name hardcoded in setup.py file throws error while installing it.
So, it will be good if we get this dataset name from the environment file dynamically same like how we are doing for STEPLIB datasets.

@AWADHAMBIKA
Copy link
Contributor

AWADHAMBIKA commented Feb 24, 2021

thanks @kparihar7.
But in order to maintain the integrity of package for existing users who did not face this issue and will continue to use it as is, we were thinking of changing the code in the following way to accommodate your suggestion as well?

if (('DB2_INC' not in os.environ)):
	dataset_include = "//'%s.SDSNC.H'" % ibm_db_home
else:
	dataset_include = "//'%s'" % os.environ['DB2_INC']

@AWADHAMBIKA
Copy link
Contributor

AWADHAMBIKA commented Feb 24, 2021

Hi @kparihar7
Also, there is another library named "SDSNMACS" used in setup.py i.e.
subprocess.run(['tso', "oput '{}.SDSNMACS(DSNAO64C)' '{}'".format(ibm_db_home, os.path.join(os.getcwd(), library_x))])

so that means your suggestion of hardcoding is applicable here as well? Can this be defined with a different name as well?
We need to handle this as well?

NOTE: Ideally SDSNMACS, SDSNLOAD and SDSNC.H are expected to be under the same HLQ i.e. prefix remains the same for all of these.
So, considering your proposed changes, the intention here is to handle the library name as a whole or "prefix" only?

Kindly clarify a bit more.

@kparihar07
Copy link
Contributor Author

@AWADHAMBIKA For the existing user, who have already installed this should not get any issue as this is in installation only and later if any update comes to this package then they can always update their package with this new instruction.
Adding this logic may create confusion for the users having standard library dataset name.

@kparihar07
Copy link
Contributor Author

@AWADHAMBIKA We should handle this dataset also same like others, so that there will not be any hardcoding in setup.py file and whatever is required can be passed through environment file.
The mentioned datasets will always be in same HLQ but every organization will have the different HLQ and this is already handled with the variable IBM_DB_HOME which makes the complete dataset name.
Ex.- $IBM_DB_HOME.SDSNEXIT
Also, organization can have the different name for the last qualifier, that is what we want to handle through environment file.

@AWADHAMBIKA
Copy link
Contributor

@kparihar7 Sorry I couldn't quite get your point.
I understand that this is just in installation and users having standard library will never face issues.
The suggested change in logic as above will be in the setup.py only i.e. in the installation part in the next release.
So are you in favor of change or not?

We don't want to make it complicated for all the 99.9% of customers where the HLQ is the same or are having standard libraries. Hence we are adding a condition to accommodate .1% of customer like you who has a different library set i.e.

if (('DB2_INC' not in os.environ)):
#Normal Customer having standard libraries
	dataset_include = "//'%s.SDSNC.H'" % ibm_db_home 
else:
#few exceptional Customers having non-standard libraries
	dataset_include = "//'%s'" % os.environ['DB2_INC']

and if this is done for one library it needs to be done fo another one as well.
Am I right?

@AWADHAMBIKA
Copy link
Contributor

@AWADHAMBIKA We should handle this dataset also same like others, so that there will not be any hardcoding in setup.py file and whatever is required can be passed through environment file.
The mentioned datasets will always be in same HLQ but every organization will have the different HLQ and this is already handled with the variable IBM_DB_HOME which makes the complete dataset name.
Ex.- $IBM_DB_HOME.SDSNEXIT
Also, organization can have the different name for the last qualifier, that is what we want to handle through environment file.

Got it. Let me check and get back to you.

@kparihar07
Copy link
Contributor Author

@kparihar7 Sorry I couldn't quite get your point.
I understand that this is just in installation and users having standard library will never face issues.
The suggested change in logic as above will be in the setup.py only i.e. in the installation part in the next release.
So are you in favor of change or not?

We don't want to make it complicated for all the 99.9% of customers where the HLQ is the same or are having standard libraries. Hence we are adding a condition to accommodate .1% of customer like you who has a different library set i.e.

if (('DB2_INC' not in os.environ)):
#Normal Customer having standard libraries
	dataset_include = "//'%s.SDSNC.H'" % ibm_db_home 
else:
#few exceptional Customers having non-standard libraries
	dataset_include = "//'%s'" % os.environ['DB2_INC']

and if this is done for one library it needs to be done fo another one as well.
Am I right?

I am okay for this change but along with this then we need to update its install.md file also and can specify whoever has standard library name, DB2_INC variable is not required for them. Others need to provide this variable.
Agreed?

@jthyssenrocket
Copy link

@kparihar7

Do you have SDSNMACS and SDSNC.H under different HLQs or renamed SDSNC.H to something different?
I've worked with Db2 for z/OS customers in 20 years and I've never seen that before.

@kparihar07
Copy link
Contributor Author

@kparihar7

Do you have SDSNMACS and SDSNC.H under different HLQs or renamed SDSNC.H to something different?
I've worked with Db2 for z/OS customers in 20 years and I've never seen that before.

@jthyssenrocket I have all these datasets under same HLQ but SDSNC.H is renamed to DSNC.H.

@jthyssenrocket
Copy link

Thanks, I've never seen that done before.

@AWADHAMBIKA
Copy link
Contributor

AWADHAMBIKA commented Feb 25, 2021

So, the new code to handle above discussion will be:

if 'zos' == sys.platform:
	sdsnc_h = os.environ['DB2_INC']
	sdsn_macs = os.environ['DB2_MACS']
	if (('DB2_INC' not in os.environ)):
	    dataset_include = "//'%s.SDSNC.H'" % ibm_db_home
	else:
	    dataset_include = "//'%s'" % sdsnc_h
    include_dir = 'sdsnc.h'
    library = []
    library_x = "libdsnao64c.x"
    library_so = "libdsnao64c.so" # fake, but helpful for gen_lib_options in cpython/Lib/distutils/ccompiler.py
    ibm_db_lib = '.'
    if not os.path.isfile(library_x):
		if (('DB2_MACS' not in os.environ)):
	        subprocess.run(['tso', "oput '{}.SDSNMACS(DSNAO64C)' '{}'".format(ibm_db_home, os.path.join(os.getcwd(), library_x))])
	    else:
	        subprocess.run(['tso', "oput '{}(DSNAO64C)' '{}'".format(sdsn_macs, os.path.join(os.getcwd(), library_x))])
    if not os.path.isdir(include_dir):
        os.mkdir(include_dir)
        subprocess.run(['cp', dataset_include, include_dir])
        for f in glob.glob(os.path.join(include_dir, '*')):
            subprocess.run(['chtag', '-tc', '1047', f])
            os.rename(f, '{}.h'.format(f))
    if not os.path.isfile(library_so):
        with open(library_so, "wb") as x_out:
            pass
else:
    library = ['db2']

agreed? And the corresponding new variables i.e. DB2_INC & DB2_MACS will be updated in install.md with comments.

@kparihar07
Copy link
Contributor Author

So, the new code to handle above discussion will be:

if 'zos' == sys.platform:
	sdsnc_h = os.environ['DB2_INC']
	sdsn_macs = os.environ['DB2_MACS']
	if (('DB2_INC' not in os.environ)):
	    dataset_include = "//'%s.SDSNC.H'" % ibm_db_home
	else:
	    dataset_include = "//'%s'" % sdsnc_h
    include_dir = 'sdsnc.h'
    library = []
    library_x = "libdsnao64c.x"
    library_so = "libdsnao64c.so" # fake, but helpful for gen_lib_options in cpython/Lib/distutils/ccompiler.py
    ibm_db_lib = '.'
    if not os.path.isfile(library_x):
		if (('DB2_MACS' not in os.environ)):
	        subprocess.run(['tso', "oput '{}.SDSNMACS(DSNAO64C)' '{}'".format(ibm_db_home, os.path.join(os.getcwd(), library_x))])
	    else:
	        subprocess.run(['tso', "oput '{}(DSNAO64C)' '{}'".format(sdsn_macs, os.path.join(os.getcwd(), library_x))])
    if not os.path.isdir(include_dir):
        os.mkdir(include_dir)
        subprocess.run(['cp', dataset_include, include_dir])
        for f in glob.glob(os.path.join(include_dir, '*')):
            subprocess.run(['chtag', '-tc', '1047', f])
            os.rename(f, '{}.h'.format(f))
    if not os.path.isfile(library_so):
        with open(library_so, "wb") as x_out:
            pass
else:
    library = ['db2']

agreed? And the corresponding new variables i.e. DB2_INC & DB2_MACS will be updated in install.md with comments.

@AWADHAMBIKA
I think DB2_INC and DB2_MACS variable assignment should come under ELSE condition.
Something like this -

	if (('DB2_INC' not in os.environ)):
	    dataset_include = "//'%s.SDSNC.H'" % ibm_db_home
	else:
	    sdsnc_h = os.environ['DB2_INC']
	    dataset_include = "//'%s'" % sdsnc_h
		if (('DB2_MACS' not in os.environ)):
	        subprocess.run(['tso', "oput '{}.SDSNMACS(DSNAO64C)' '{}'".format(ibm_db_home, os.path.join(os.getcwd(), library_x))])
	    else:
		    sdsn_macs = os.environ['DB2_MACS']
	        subprocess.run(['tso', "oput '{}(DSNAO64C)' '{}'".format(sdsn_macs, os.path.join(os.getcwd(), library_x))])

@AWADHAMBIKA
Copy link
Contributor

sure..

bimalkjha added a commit that referenced this pull request Apr 16, 2021
 * Update README with new release version (Bimal Kumar Jha)
 * typo correction in README.md (Bimal Kumar Jha)
 * testcase change for ZOS platform and zos server (Arnab Mukherjee)
 * changing the release tag (Arnab Mukherjee)
 * Add comments (kotofos)
 * Fix error message formatting on python3 (kotofos)
 * Dev release304 (#621) (arnab mukherjee)
 * Update README.md (#617) (Alexander Manley)
 * Code fix in SQL_BOOLEAN (Arnab Mukherjee)
 * update install.md file with the latest information on ZOS platform documentation (Arnab Mukherjee)
 * Fix for #612 (Arnab Mukherjee)
 * Boolean support for django issue (Arnab Mukherjee)
 * Adding changes to handle env variable DB2_IBC and DB2_MACS in case user wants to define their own dataset names (Arnab Mukherjee)
 * Support ODBC keyword CURRENTSCHEMA (#581) (Ke Zhu)
 * Update Install.md (#605) (kparihar7)
 * Update setup.py file (#606) (kparihar7)
 * Get execute_many test running clean in CI (#524) (davidmmooney)
 * Update README.md (Bimal Kumar Jha)
 * Update file name in setup.py (Bimal Kumar Jha)
 * Update MANIFEST.in (arnab mukherjee)
 * Update notifications and add python 3.9 test (Bimal Kumar Jha)
 * Change in install.md as per input from IBM as the ++APAR is now available as PTF. (#597) (Binit Kumar)
 * fix: correct changes file (Bimal Jha)
 * upd: CHANGES (Bimal Jha)
 * deleting Install_z_ibm_db file (amukherjee)
 * Changes for Z/os support along with python 3.9 (amukherjee)
 * Readme and install file releated changes (Arnab Mukherjee)
 * Z odbc support (#579) (Binit Kumar)
 * Update README.md (Saba Kauser)
 * Update README.md (#544) (Saba Kauser)
 * add v11.1 support for win32 and mac (Saba Kauser)
 * add v11.1 support for win32 and Mac (Saba Kauser)
 * Add dependent libraries for docker linux in README (Saba Kauser)
 * new test canse for bool (#527) (Saba Kauser)
 * Update CHANGES (Saba Kauser)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants