[Tutor] building package on mac os

Steven D'Aprano steve at pearwood.info
Mon Sep 10 07:51:17 EDT 2018


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
> 
> 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.

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

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).


Hope this was helpful.



-- 
Steve


More information about the Tutor mailing list