[Python-Dev] Why doesn't venv also install python3*-config?
Hello, I'm experimenting with package development on different versions of Python in different virtualenvs. After running "make" I don't do "make install", but rather I set up virtualenvs by running /path/to/source/python -m venv env_dir. This works for as long as I don't need to compile extensions. Once I do that I'm running into trouble because there is no python3-config binary in the venv, so it uses the "system" python3-config which of course returns results for the /usr(/local)/ tree. This seems to go against the idea of an encapsulated and self-contained environment. And the venv created straight from the "not-installed" source tree works so well that having a venv/bin/python3-config whose output points into the source tree seems a logical step. Is this an omission or is there a rationale for not doing it? Of course I can "properly" install different Python versions by using different "configure --prefix" directories. But I like the venv so much in general that this rubs me the wrong way. Thanks! ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/KMG3USMQLQNI6AEX6UUS2WTNFIIIS2XY/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: Why doesn't venv also install python3*-config?
On Thu, 9 Jan 2020 15:18:55 +0100 Victor Stinner wrote: > Which build command rely on python-config? Is it to cross-compile 3rd > party C extensions on the host? Hello, OP speaking here. In two cases I came across this issue. No cross-compiling involved. 1) To debug a Python C extension I wrote a standalone C test program which of course needs to find "Python.h" and libpython*.* for building. I ran into trouble when I tried to build that program in a custom compiled debugging Python environment. 2) I need to recheck this, but it was a "pip install" for a package from pypi org. Probably numpy or pandas errored out with not being able to find "Python.h". I'll try and re-check. ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/KXHEX6UGOMPWOWQPGD7YQTAWECR4Q3KS/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: Why doesn't venv also install python3*-config?
Hi guys,
after I got the whole list into a lather about the merits of
the python-config program, let me rephrase the question:
Is there a "canonical" way of automatically finding the correct
include files and Python runtime library when embedding the Python
interpreter, based on the current virtual environment (and not the
"installed" version)? Upon reding the docs there isn't. And maybe there
should't or cant be any. So if I want to try embedding Python under
different versions I have to either install those into different
directories and use python-config, or I write a trivial Python program
that finds the correct values for the current environment using
sysconfig and outpus those as compiler / linker flags. Easy enough, I
was just surprised that no such solution was already built into the
virtualenv setup mechanism
Here's a quote from the docs
"""
If this procedure [using python-config] doesn’t work for you (it is not
guaranteed to work for all Unix-like platforms; however, we welcome bug
reports) you will have to read your system’s documentation about
dynamic linking and/or examine Python’s Makefile (use
sysconfig.get_makefile_filename() to find its location) and compilation
options. In this case, the sysconfig module is a useful tool to
programmatically extract the configuration values that you will want to
combine together. For example:
>>> import sysconfig
>>> sysconfig.get_config_var('LIBS')
'-lpthread -ldl -lutil'
>>> sysconfig.get_config_var('LINKFORSHARED')
'-Xlinker -export-dynamic'
"""
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/364Q6EZHSFN6DGUUDN3FKOMK4CDS3WJB/
Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: PEP 584: Add Union Operators To dict
This is a great PEP. Just recently I needed this and was surprised that nothing of the sort had been implemented yet (I looked for quite some time). I have one suggestion: Wouldn't it be useful for these operators to also accept sets (functionally acting like a dict with None for all values)? This would make it very elegant to 'normalize' dicts by pruning (dict & set) or padding (set | dict) dictionaries. I would find this useful for efficient data sanitation purposes, as when processing input from web forms. Am 05.02.2020 02:28 schrieb Guido van Rossum: Thanks Brandt (and Steven of course)! If there are no objections by next week I'll recommend this to the Steering Council for acceptance. In the meantime, I am wondering about the reference implementation -- is it suitable to submit as a PR? Or is it a toy written in pure Python? (I found it a little tricky to follow your branch.) On Tue, Feb 4, 2020 at 4:57 PM Brandt Bucher wrote: Steven D'Aprano and I have pushed a third draft of PEP 584: https://www.python.org/dev/peps/pep-0584/ [1] The accompanying reference implementation is on GitHub: https://github.com/brandtbucher/cpython/tree/addiction [2] For those who have been following the discussions over the past year on python-ideas, this new draft does not contain much additional content; the most notable difference is that the choice of operator has been changed from + to |. The rest of the revisions are mostly reformatting and reorganizing the information to bring the document in line with PEP standards. Please let us know what you think – we'd love to hear any *new* feedback that hasn't yet been addressed in the PEP or the related discussions it links to! Thanks! Brandt ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ [3] Message archived at https://mail.python.org/archives/list/[email protected]/message/TTIKCDIPC2CDHX23Y57CPHDSVYOWCCER/ [4] Code of Conduct: http://python.org/psf/codeofconduct/ [5] -- --Guido van Rossum (python.org/~guido [6]) _Pronouns: he/him __(why is my pronoun here?)_ [7] Links: -- [1] https://www.python.org/dev/peps/pep-0584/ [2] https://github.com/brandtbucher/cpython/tree/addiction [3] https://mail.python.org/mailman3/lists/python-dev.python.org/ [4] https://mail.python.org/archives/list/[email protected]/message/TTIKCDIPC2CDHX23Y57CPHDSVYOWCCER/ [5] http://python.org/psf/codeofconduct/ [6] http://python.org/~guido [7] http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/ ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/NFVVGNXBSABWIPCDH6C3AQA65R37DFPJ/ Code of Conduct: http://python.org/psf/codeofconduct/ ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/CL2AKG47ZJJQXHUREHTD47VQZYJZNJLH/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: PEP 584: Add Union Operators To dict
Depends on what d is.
type({})
So the result is {(1, 2): None}, but the ambiguity comes from the
definition of {}, not from my proposal.
Am 05.02.2020 18:19 schrieb Serhiy Storchaka:
05.02.20 14:27, Musbur пише:
I have one suggestion: Wouldn't it be useful for these operators to
also accept sets (functionally acting like a dict with None for all
values)? This would make it very elegant to 'normalize' dicts by
pruning (dict & set) or padding (set | dict) dictionaries. I would
find this useful for efficient data sanitation purposes, as when
processing input from web forms.
d = {}
d |= {(1, 2)}
What is d now? {1: 2} or {(1, 2): None}
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/ZUXJBYUHXGAKLH3TOVB4UUXQUBFOQAIK/
Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2ENA4EV2IVHTE64YVXT4MK52MYU5PLGR/
Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes
On Fri, 20 Mar 2020 20:49:12 - "Dennis Sweeney" wrote: > exactly same way (as a character set) in each case. Looking at how > the argument is used, I'd argue that ``lstrip``/``rstrip``/``strip`` > are much more similar to each other than they are to the proposed > methods Correct, but I don't like the word "cut" because it suggests that something is cut into pieces which can be used later separately. I'd propose to use "trim" instead of "cut" because it makes clear that something is cut off and discarded, and it is clearly different from "strip". ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/ZPL56AAEOQ7P7V4LMMFPMWXFPNJ6HFAR/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Problem with instantiating a C extension class from another class
Hello,
(I've asked this question before on python-list but only got scarce
and ultimately unhelpful answers. Although this isn't about Python
development itself, I'm assuming that there is more CPython
knowledge on this list than on the other, so please bear with me.)
I've written a C extension module, each defining a class
(called Series and CLHist, respectively). I can import both modules in
Python and use the classes. Everything works fine, also according to
valgrind.
Now I want to return a Series instance directly from a CLHist
method, and that immediately crashes Python with a segfault.
Here's a bit of code and just the _new, _init, and _finalize methods
which I've sprinkled with debugging code. When I instantiate a Series
object from Python, I see output from all three methods. When I call
pyseries_new() from C, none of the three functions are called and it
crashes.
At some point I thought maybe I should call PyType_Ready() from the C
side before instantiating Series. In a "standard" (system) Python
installation, it printed the desired debugging output and crashed
later. Under a debugging Python installation I built it outputs
nothing except an interesting post-mortem "Fatal Python error: UNREF
invalid object" (see below).
Here's my C code with the boilerplate stuff left out.
typedef struct {
PyObject_HEAD
struct clh_series *series;
} Series;
static PyObject *Series_new(PyTypeObject *type,
PyObject *args, PyObject *kw) {
Series *self;
self = (Series *) type->tp_alloc(type, 0);
fprintf(stderr, "Series_new(%p)\n", self);
self->series = NULL;
return (PyObject*)self;
}
static int Series_init(Series *self, PyObject *args, PyObject *kw) {
fprintf(stderr, "Series_init(%p)\n", self);
self->series = NULL;
return 0;
}
static void Series_finalize(PyObject *self) {
fprintf(stderr, "Series_finalize(%p)\n", self);
clh_series_free(((Series*)self)->series);
}
/* To create a new Series object directly from C */
PyObject *pyseries_new(struct clh_series *series) {
Series *pyseries;
pyseries = PyObject_New(Series, &series_type);
PyObject_Init((PyObject *)pyseries, &series_type);
pyseries->series = series;
return (PyObject *) pyseries;
}
Here's the debugging output:
* ob
object :
type: tuple
refcount: 0
address : 0x7f1a4e2f97a8
* op->_ob_prev->_ob_next
object : <_Series object at 0x7f1a4e2ee9d0>
type: _Series
refcount: 1
address : 0x7f1a4e2ee9d0
* op->_ob_next->_ob_prev
object :
type: tuple
refcount: 0
address : 0x7f1a4e2f97a8
Fatal Python error: UNREF invalid object
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/ILMRMQ64P7H6KHH2BZQPDYGXW773MOII/
Code of Conduct: http://python.org/psf/codeofconduct/
[Python-Dev] Re: Problem with instantiating a C extension class from another class
On Mon, 6 Apr 2020 08:32:34 +1000 Nick Coghlan wrote: > Hi Musbur, > > While python-dev is specifically for core development, the "specific > interest group" mailing lists are for both change proposals and > existing usage questions. > > I've cc'ed capi-sig on this reply. Hi Nick, thanks for forwarding the post. BTW, I've posted a complete, self-contained example on stackoverflow (which also received zero attention so far): https://stackoverflow.com/questions/61025268/how-to-instantiate-a-custom-object-from-within-a-c-module Regards ___ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/HO47V7CEBKICENCVRYJB44MPLE7VCUVO/ Code of Conduct: http://python.org/psf/codeofconduct/
