[Tutor] building package on mac os

Mats Wichmann mats at wichmann.us
Mon Sep 10 08:57:38 EDT 2018


On 09/10/2018 05:51 AM, Steven D'Aprano wrote:
> Hi Glenn,
> 
> Sorry, I don't think many people here are experts on building packages, 
> especially on MacOS. You could try the "Python-List" mailing list as 
> well.
> 
> I know I can't do more than offer a few vague, general questions which 
> may or may not point you in the right direction. See below.
> 
> On Sun, Sep 09, 2018 at 09:25:10PM +0000, Glenn Schultz via Tutor wrote:
> 
>> I have a package that I am working on.  I am using Pycharm.  The 
>> directories are set up correctly.  
>> In my frameworks I have
>> Python 2.7
>> Python 3.5
>> Python 3.6
>> Python 3.7
>> Current - which is Python 2.7
>>
>> After navigating to the directory with the package I run the following in 
>> my terminal

echoing Steven... PyCharm has some support for package construction, but
I've never used it; if the problem is particular to that environment,
there may be some help available on their forums.

>>
>> python3 setup.py sdist bdist_wheel
>>
>> This runs fine and it appears all is correct with no messages or warning. 
> 
> Are you running that command as the root user, as a priviledged user 
> with elevated permissions, or an ordinary user?
> 
> After you run, where is the package installed?
> 
> You have three different Python 3.x versions, which one does python3 
> run?
> 
> 
> [steve at ando ~]$ which python3
> /usr/local/bin/python3
> 
> [steve at ando ~]$ python3 --version
> Python 3.3.0rc3
> 
> 
>>  Then I go to the main user directory
>> and pip install directory/packagename
> 
> What is the main user directory?
> 
> Which user are you running pip as? What version of Python does that pip 
> work with?
> 
> [steve at ando ~]$ pip --version
> pip 8.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
> 
> So on my system, "pip" with no given version number relies on Python 
> 2.7. If your system is the same, then you're running setup using Python 
> 3 and pip with Python 2, and I have no idea whether or not that will 
> work.

Indeed this is why the recommendation these days is to install as

  python -m pip install

instead of standalone

  pip install

... that way the pip is sure to match the python, for when you're using
a particular virtualenv, etc.


> 
>> It appears the wheel installs in a private/var/ folder

Just a thought: wheels are /cached/, if that's what you meant... so if
you repeat an operation it doesn't have to be re-fetched. On Linux that
is often $HOME/.cache/pip, although it can vary.


> What do you mean by "a private/var/ folder"? It would help if you state 
> the actual path, rather than something that looks like a fake path. If 
> you want to obfuscate the username, you may change it to something 
> generic like "fred":
> 
>     # real path with amusing Monty Python reference
>     /home/biggusdickus/.somethingprivate/var/packages
> 
>     # more professional sounding path
>     /home/fred/.somethingprivate/var/packages
> 
> for example.
> 
> 
>> if I change the statement to python3.6 pip install  directory/packagename
>>
>> I get an error 2 cannot find director.
> 
> 
> Can you copy and paste the full error message? Are you sure that it 
> cannot find *director*, or is it *directory*?
> 
> 
>>  I need to change my current python 
>> to 3.6 and also figure out how to install the package.  I have seen some 
>> instructions to edit the bash file but before I do this I would like to 
>> resolve the install issue
> 
> What does your OS expect "python" to point to? It is dangerous to change 
> the system-wide "python" unless you really know what you are doing.
> 
> It should be harmless to use an alias as an ordinary user. Under bash, 
> you can test it in a shell like this:
> 
>     # check that python3.6 does points where you expect
>     which python3.6
> 
>     # and if so, run this
>     alias python='python3.6'
> 
>     # now confirm python points to Python 3.6
>     which python
> 
> 
> When you are satisfied that works, you can make it permanent by editing 
> your .bashrc file (under your home directory) and inserting that alias 
> line. The alias will take effect in any new shells you open (but not 
> existing shells).

You can also use 'pyenv' to manage multiple pythons.  It will do some
setup magic for you, which can let you switch between versions fairly
smoothly.  Pycharm has its own mechanism for managing multiple versions,
that works fine too, you can assign an interpreter per project (as some
of the commentary above suggests you probably know).





More information about the Tutor mailing list