Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT: replace optparse with argparse for 'distutils' scripts #15728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Mar 9, 2020

This is a split-off from #15702 to only focus on distutils.

Considering the fragility of numpy.distutils, care and testing should be considered with these changes across a wide range of environments.

* Force "import numpy.core" to fix "npy_pkg_config.py npymath"
* "npy_pkg_config.py --list-all" (without pkg_name) now supported
@mwtoews mwtoews force-pushed the optparse-distutils branch from 217cf27 to b9ca4d7 Compare March 9, 2020 04:15
@mwtoews
Copy link
Contributor Author

mwtoews commented Mar 9, 2020

While attempting to do some stress-testing of npy_pkg_config.py, it was clear that a few broken things needed to be fixed (hopefully). I'd have to do some bisections to find out the last version that worked, but the current version in master does not appear to have a functional command-line interface, except for simple modules like npy_pkg_config.py mlib --version.

For instance npy_pkg_config.py --list-all raises ValueError: Expect package name on the command line:. But if npy_pkg_config.py mlib --list-all is run from "numpy/core/lib/npy-pkg-config", then the new error was __main__.PkgNotFound: Could not find file(s) ['mlib.ini.ini'].

Another change (which should be discussed here) is to explicitly run import numpy.core if pkgname == "numpy.core", which is necessary to run npy_pkg_config.py npymath. The error raised without this modification is ValueError: You should import numpy.core to get information on npymath. Other possibilities are to use importlib of pkgname.

The fixed behaviour for npy_pkg_config.py --list-all (here done on Windows) is:

> cd C:\Users\user\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy\core\lib\npy-pkg-config
> python D:\src\numpy\numpy\distutils\npy_pkg_config.py --list-all
mlib    mlib - Math library used with this version of numpy
npymath npymath - Portable, core math library implementing C99 standard

(same output of Linux, tested from wherever npy-pkg-config exists)

I've added a "TODO" comment to suggest that the --list-all should consider searching same directories as with the normal pkg_name behaviour.


I've done some stress-testing with options from both utilities on Linux and Windows and everything appears to behave the same as what's in the current master branch. I'd appreciate if anyone else can do some stress-testing too.

@tylerjereddy
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

Base automatically changed from master to main March 4, 2021 02:04
@mwtoews mwtoews closed this Mar 9, 2021
@mwtoews mwtoews deleted the optparse-distutils branch March 9, 2021 10:30
@mwtoews mwtoews restored the optparse-distutils branch March 9, 2021 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants