Skip to content
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

build_ext fails if build_py was not called before #296

Closed
mgorny opened this issue Apr 19, 2022 · 8 comments · Fixed by #297
Closed

build_ext fails if build_py was not called before #296

mgorny opened this issue Apr 19, 2022 · 8 comments · Fixed by #297

Comments

@mgorny
Copy link
Contributor

mgorny commented Apr 19, 2022

For example in aesara:

$ python setup.py build_ext -j12
running build_ext
UPDATING build/lib/aesara/_version.py
error: [Errno 2] No such file or directory: 'build/lib/aesara/_version.py'
mgorny added a commit to mgorny/python-versioneer that referenced this issue Apr 19, 2022
Ensure that `build_py` command is always called prior to `build_ext`.
The distutils/setuptools build systems do not guarantee (or require)
calling `build_py`, therefore versioneer fails to find .py files
if `build_ext` is called immediately on a fresh source tree.

Closes python-versioneer#296
@effigies
Copy link
Contributor

During standard python setup.py install, I think build_py is called before build_ext, but it is not always the case that someone will want to call build_py implicitly in build_ext. For example, here is a StackOverflow post asking how to avoid running build_py before build_ext.

I note that we do avoid running the update if you use --inplace. Would updating your above command to python setup.py build_ext -j12 --inplace get you what you want?

@mgorny
Copy link
Contributor Author

mgorny commented Apr 19, 2022

Building in-place is not an option for us, as separate build dirs are required to handle different versions of Python.

@mgorny
Copy link
Contributor Author

mgorny commented Apr 19, 2022

For the record, the problem is related to the Python build infrastructure for Gentoo packages. I suppose the alternative "fix" would be to skip updating the version if build_py wasn't called but I'm not really sure how to check that. I suppose checking if build dir could be an option.

@effigies
Copy link
Contributor

Might make sense to warn if the file doesn't exist with an error message that explains that it couldn't be updated and you might need to build_py first.

Setup.py does also allow you to pass multiple commands, each with their own options. For this use case, maybe:

python setup.py build_py build_ext -j12

@mgorny
Copy link
Contributor Author

mgorny commented Apr 19, 2022

The whole point is to avoid calling build_py because it makes everything much slower (and it's very slow anyway), and PEP517 build takes care of calling it anyway.

@effigies
Copy link
Contributor

Your PR proposes including build_py as part of build_ext in any project that uses versioneer, so that seems like that will break your use case as well.

I think the file check and warning is probably the right way to go for your use case.

@mgorny
Copy link
Contributor Author

mgorny commented Apr 19, 2022

Ok, I'll update the PR later today.

mgorny added a commit to mgorny/python-versioneer that referenced this issue Apr 19, 2022
Skip version update on `build_ext` command if the respective version
file does not exist.  This could be the case if `build_ext` is called
explicitly without calling `build_py` prior to it.

Closes python-versioneer#296
@mgorny
Copy link
Contributor Author

mgorny commented Apr 19, 2022

…and updated!

mgorny added a commit to mgorny/python-versioneer that referenced this issue Apr 26, 2022
Skip version update on `build_ext` command if the respective version
file does not exist.  This could be the case if `build_ext` is called
explicitly without calling `build_py` prior to it.

Closes python-versioneer#296
mgorny added a commit to mgorny/python-versioneer that referenced this issue Apr 26, 2022
Skip version update on `build_ext` command if the respective version
file does not exist.  This could be the case if `build_ext` is called
explicitly without calling `build_py` prior to it.

Closes python-versioneer#296
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 a pull request may close this issue.

2 participants