GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-82909: Update PC/pyconfig.h to allow disabling pragma based auto-linking by jcfr · Pull Request #19740 · python/cpython

Conversation

@jcfr

@jcfr jcfr commented Apr 27, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Define PY_NO_LINK_LIB to build extension disabling pragma based
auto-linking. This is relevant when using build-system generator
(e.g CMake) where the linking is explicitly handled

https://bugs.python.org/issue38728

  • Issue: Update PC/pyconfig.h to support disabling auto linking #82909

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thewtex, kwryankrattiger, zhengzh, KerstinKeller, and Osyotr reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@jcfr
jcfr requested a review from a team as a code owner April 27, 2020 19:19
@bedevere-bot bedevere-bot added the awaiting review label Apr 27, 2020
@the-knights-who-say-ni

This comment was marked as resolved.

Sign in to view
@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Apr 27, 2020
@jcfr

This comment was marked as resolved.

Sign in to view
@the-knights-who-say-ni the-knights-who-say-ni added CLA signed and removed CLA not signed labels May 6, 2020
@jcfr

jcfr commented May 6, 2020

Copy link
Copy Markdown
Contributor Author

@zooba Thanks for your patience, let me know if you need anything else to move forward with the integration 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mathstuf

mathstuf commented May 12, 2020

Copy link
Copy Markdown

No news entry in Misc/NEWS.d/next/

@jcfr Seems like a release note could be added in the meantime.

jcfr reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mathstuf

mathstuf commented Sep 16, 2020

Copy link
Copy Markdown

Ping? Any update here? It'd be nice to have this in 3.9.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mathstuf

mathstuf commented Sep 5, 2021

Copy link
Copy Markdown

Seems this will miss 3.10 as well.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kwryankrattiger

kwryankrattiger commented Dec 9, 2021

Copy link
Copy Markdown

Ping. This would be really really nice to have sometime soon 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Dec 9, 2021

Copy link
Copy Markdown
Member

I thought we'd already added this? I guess if it's not there, then we should.

Definitely needs a NEWS entry, probably deserves a What's New as well. Not sure if there's any place in the documentation that would suit, but if so, we should mention it for sure.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcfr

jcfr commented Dec 9, 2021

Copy link
Copy Markdown
Contributor Author

Definitely needs a NEWS entry

I can definitely add an entry, What about the C-API section ? See https://github.com/python/cpython/tree/main/Misc/NEWS.d/next/C%20API

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@reder2000 reder2000 mentioned this pull request Dec 11, 2022
pybind11 links against wrong Python library when PYBIND11_FINDPYTHON is present microsoft/vcpkg#23052
Closed
@arhadthedev arhadthedev changed the title bpo-38728: Update PC/pyconfig.h to allow disabling pragma based auto-linking gh-82909: Update PC/pyconfig.h to allow disabling pragma based auto-linking Apr 2, 2023
@arhadthedev arhadthedev added build The build process and cross-build OS-windows labels Apr 2, 2023
@arhadthedev

arhadthedev commented Apr 2, 2023

Copy link
Copy Markdown
Member

I added draft documentation and the NEWS entry for the macro. However, they need improvements.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcfr

jcfr commented Apr 3, 2023

Copy link
Copy Markdown
Contributor Author

@arhadthedev Thanks for your help moving this forward 🙏

arhadthedev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Apr 3, 2023

Copy link
Copy Markdown
Member

I haven't tested the commands added to the docs, but if they do work as described and produce the files, then this looks fine to me.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tasty0tomato

tasty0tomato commented Jun 26, 2023

Copy link
Copy Markdown

It seems that if building Python by oneself, python's lib file will not be found in virtual environment. Hope this issue fixes as quickly as possible

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Jun 26, 2023

Copy link
Copy Markdown
Member

No, virtual environment is only for Python libraries. You'll need to look in base_prefix to find native import libraries.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tasty0tomato

tasty0tomato commented Jun 26, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

@zooba My question is like this:rosinality/stylegan2-pytorch#325 (comment)

So, is it more like to be a question about venv?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Jun 27, 2023

Copy link
Copy Markdown
Member

It looks like Torch is deciding those settings, and it's deciding wrong about where to find the libs files.

There's a revamp of sysconfig going on that will eventually provide a better option for them to find it, but for now, either they need to use sys.base_prefix instead of sys.prefix, or if they already are (which they might be), then there's something wrong with your venv (maybe you've chained multiple venvs together in some unsupported way?)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tasty0tomato

tasty0tomato commented Jun 27, 2023

Copy link
Copy Markdown

@zooba I can give some additional informations. For exmaple,
The source code of python is on D:\Python-3.10.12,
The binary file of Windows and also the dll file are on D:\Python-3.10.12\PCbuild\amd64

And that's maybe why dll file cannot be found?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Jun 28, 2023

Copy link
Copy Markdown
Member

Yeah, many tools are not going to work well when running from a CPython build directory. It's an unsupported configuration.

Try using the PC/layout tool (e.g. python PC\layout --copy <directory> --preset-default) to create an installed-shape directory. That will have the libs at the usual place relative to python.exe. (You need to re-run the command if you rebuild Python, but it does incremental copying. Also, don't run the copied Python from the CPython source directory or it'll get the wrong Lib dir.)

tasty0tomato reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mathstuf

mathstuf commented Dec 28, 2023

Copy link
Copy Markdown

Any progress here? I see conflicts, so at least a rebase is in order. It'd be nice to get this into 3.13 at least…

@vstinner Interested in shepherding this C API change at all?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Dec 28, 2023

Copy link
Copy Markdown
Member

A rebase ought to be enough, and when someone confirms that the build commands shown in the new documentation are correct then this can be merged (as per my last message).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@KerstinKeller

KerstinKeller commented Nov 21, 2024

Copy link
Copy Markdown

This would potentially be extremly helpful, any chance that this will get merged at some point?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Nov 21, 2024

Copy link
Copy Markdown
Member

It looks like the rebase isn't coming, so someone will need to submit a new PR.

It also looks like my last hesitation was that the commands in the docs weren't tested.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Nov 21, 2024
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

jcfr and others added 5 commits March 2, 2025 15:51
@jcfr
bpo-38728: Update PC/pyconfig.h to allow disabling pragma based auto-…
56da8f9
…linking

Define PY_NO_LINK_LIB to build extension disabling pragma based
auto-linking. This is relevant when using build-system generator
(e.g CMake) where the linking is explicitly handled
@arhadthedev @jcfr
Add a news entry
7aa18a2
@arhadthedev @jcfr
Add documentation
29268cc
@arhadthedev @jcfr
Rename PY_NO_LINK_LIB to Py_NO_LINK_LIB
3658f4c
@arhadthedev @jcfr
Fix WARNING: Literal block expected; none found
23c9af6
@jcfr
jcfr force-pushed the fix-issue-38728 branch from a799772 to 23c9af6 Compare March 2, 2025 20:53
zooba
zooba reviewed Mar 3, 2025
View reviewed changes

@zooba zooba left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing wrong with the PR as it is, but I think we can do a bit of tidying here if you want.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread PC/pyconfig.h.in
Comment on lines 311 to +314
#ifdef MS_COREDLL
# if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
/* not building the core - must be an ext */
# if defined(_MSC_VER)
# if defined(_MSC_VER) && !defined(Py_NO_LINK_LIB)

@zooba zooba Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole set of conditions is pretty ugly... any interest in simplifying?

Ideally in this order:

  • check if the feature is explicitly disabled (new variable)
  • check if we're in a context where it should be implicitly disabled (Py_BUILD_CORE[_BUILTIN])
  • check if the compiler supports it (_MSC_VER)

The order doesn't need to be spelled out to anyone reading it, but it should make it easiest to read (the first check has the best name) and easiest to maintain (alternate compilers can be supported in the "middle", not the edges).

It also really doesn't need to be indented by 8 characters. Four would be plenty.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread PC/pyconfig.h.in
/* Define Py_NO_LINK_LIB to build extension disabling pragma
based auto-linking.
This is relevant when using build-system generator (e.g CMake) where
the linking is explicitly handled */

@zooba zooba Mar 3, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't important for this file, though a short header above the entire block (something like "automatically reference python3x.lib") might make it easier to understand the purpose without reading the whole way through.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zooba

zooba commented Mar 10, 2025

Copy link
Copy Markdown
Member

Guess we're not getting those improvements, so we'll leave them for later. Should be an easy first contribution for a sprint.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba
zooba merged commit c3487c9 into python:main Mar 10, 2025
@github-project-automation github-project-automation Bot moved this from Waiting Done to Done in CPython pull requests to have finally merged Mar 10, 2025
@bedevere-app bedevere-app Bot removed the awaiting review label Mar 10, 2025
@jcfr

jcfr commented Mar 15, 2025

Copy link
Copy Markdown
Contributor Author

Thanks everyone for the help moving this forward 🙏

Osyotr reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Osyotr Osyotr mentioned this pull request Apr 2, 2025
[python3] Update to 3.12.9, drop Windows 7 support microsoft/vcpkg#40996
Merged
3 of 4 tasks
Osyotr added a commit to Osyotr/vcpkg that referenced this pull request Apr 5, 2025
@Osyotr
[python3] Backport python/cpython#19740
99f259e
hroncok
hroncok reviewed May 29, 2025
View reviewed changes
Comment thread Doc/extending/windows.rst
:file:`Python.h` triggers an implicit, configure-aware link with the
library. The header file chooses :file:`pythonXY_d.lib` for Debug,
:file:`pythonXY.lib` for Release, and :file:`pythonX.lib` for Release with
the `Limited API <stable-application-binary-interface>`_ enabled.

@hroncok hroncok May 29, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #134830

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mhsmith mhsmith mentioned this pull request Sep 1, 2025
Update PC/pyconfig.h to support disabling auto linking #82909
Closed
@Andrej730 Andrej730 mentioned this pull request Aug 18, 2026
PC/pyconfig.h: improve implicit linking code readibility #155995
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner left review comments
@zooba zooba zooba left review comments
+2 more reviewers
@mathstuf mathstuf mathstuf left review comments
@hroncok hroncok hroncok left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

build The build process and cross-build OS-windows

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

12 participants

@jcfr @the-knights-who-say-ni @mathstuf @kwryankrattiger @zooba @arhadthedev @tasty0tomato @KerstinKeller @vstinner @hroncok @ezio-melotti @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.