What is currently the recommended way to work with a distutils-based setup.py that requires compilation?

Tim Johnson tim at akwebsoft.com
Tue Nov 8 22:59:19 EST 2016


* Ivan Pozdeev via Python-list <python-list at python.org> [161106 17:28]:
> https://wiki.python.org/moin/WindowsCompilers has now completely replaced
> instructions for `distutils`-based packages (starting with `from
> distutils.core import setup`) with ones for `setuptools`-based ones
> (starting with `from setuptools import setup`).
> 
> However, if I have a `distutils`-based `setup.py`, when I run it,
> `setuptools` is not used - thus the instructions on the page don't work.
> 
> It is possible to run a `distutils`-based script through `setuptools`, as
> `pip` does, but it requires the following code
> (https://github.com/pypa/pip/blob/8.1.2/pip/req/req_install.py#L849 ):
> 
>     python -u -c "import setuptools, tokenize;__file__=<setup.py full path>;
>         exec(compile(getattr(tokenize, 'open', open)(__file__).read()
>         .replace('\\r\\n', '\\n'), __file__, 'exec'))" <setup.py arguments>
> 
> They can't possibly expect me to type that on the command line each time,
> now can they?
Ivan, it looks like you aren't getting any answers from seasoned
list gurus to your question.

So, I'm going to take a stab at this and I hope you are not mislead
or misdirected by my comments.

> They can't possibly expect me to type that on the command line each time,

The code that you are quoting above can be placed in a script file
and executed at will. Once you get the syntax correct, you will then
be able to execute that script at any time.

I don't know what operating system you are using: Linux and Mac work
pretty much similarly when it comes to console scripts, windows will
have a different approach, but not radically so.

I hope this helps or puts you on a constructive path.

> I also asked this at http://stackoverflow.com/q/40174932/648265 a couple of
> days ago (to no avail).
> 
> -- 
> 
> Regards,
> Ivan
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com



More information about the Python-list mailing list