<div dir="ltr">Yeah, checked it into my conda binder.  I'm not having any difficulties.  You guys are way beyond me at this point.  Should I put x3d in my environment.yml dependencies?<div><br></div><div>Thanks,</div><div><br></div><div>John</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 23, 2020 at 9:43 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com">andreasplesch@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This is only about the pip package. When you use 'pip install x3d'<br>
instead of a local x3d.py module, you would have to use import x3d.x3d<br>
. But I think you are using a local x3d.py file.<br>
<br>
-Andreas<br>
<br>
On Thu, Apr 23, 2020 at 10:39 PM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br>
><br>
> Are you guys making changes to x3d.py? cuz if you are, I haven't seen any since<br>
><br>
> Apr 22 00:23 CST<br>
><br>
> I notice that I have a cache for x3d.cpython compiled pyc files.  Last time I tried my version it worked?<br>
><br>
> John<br>
><br>
> On Thu, Apr 23, 2020 at 9:30 PM Peitso, Loren (CIV) <<a href="mailto:lepeitso@nps.edu" target="_blank">lepeitso@nps.edu</a>> wrote:<br>
>><br>
>> Import x3d.x3d as x<br>
>><br>
>> I don't want to think about circularly adding x3d into the symbol table as short for itself.  But there is no requirement for a programmer to subject themselves to oververbosity.<br>
>><br>
>> v/r Loren<br>
>><br>
>> Sent from my iPhone<br>
>><br>
>> On Apr 23, 2020, at 17:47, John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br>
>><br>
>> <br>
>> x3dpsail is my name. Should I change it to pyx3d?   Pick one, and I will switch, I haven't deployed to PyPi yet.<br>
>><br>
>> I think it may be useful to differentiate the *sails.  In other words, the python Don is creating is NOT related to X3DJSAIL until he adds the stylesheet translations to it.<br>
>><br>
>> Of course, the Navy may object to my use of sail.  That's probably a government owned name.<br>
>><br>
>> John<br>
>> John<br>
>><br>
>> On Thu, Apr 23, 2020 at 7:39 PM Don Brutzman <<a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a>> wrote:<br>
>>><br>
>>> Thanks for the great analysis Andreas and Loren.  Very interesting.  Will study and test further.<br>
>>><br>
>>> Meanwhile as more background, the goal I have set for a python programmer considering package prefixes is to be able to work either way, depending on python programmer preference.<br>
>>><br>
>>> I have gotten both forms to work and indeed have tried to document it that way, both in the html documentation and in the X3dToPython.xslt conversion stylesheet options.<br>
>>><br>
>>> The terse form is far preferred if you are just building an X3D model and aren't using other packages.  Otherwise it gets objectionably verbose as you build the scene graph.<br>
>>><br>
>>> If a python programmer wants to use a variety of different packages that might overload some of the class names, they can use the prefix where they prefer.<br>
>>><br>
>>> So I think this situation is likely a case of "when you come to a fork in the road, take it!" - Yogi Berra<br>
>>><br>
>>> If a second non-eponymous package name is necessary, might use x3dpsail.<br>
>>><br>
>>> Lots to consider - again thanks.<br>
>>><br>
>>><br>
>>> On 4/23/2020 4:27 PM, Peitso, Loren (CIV) wrote:<br>
>>> > That is the Python convention.<br>
>>> ><br>
>>> > Package-name dot module-name<br>
>>> ><br>
>>> > The package name is simply the directory holding all the associated modules.<br>
>>> ><br>
>>> > v/r Loren<br>
>>> ><br>
>>> > Sent from my iPhone<br>
>>> ><br>
>>> >> On Apr 23, 2020, at 16:22, Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>> wrote:<br>
>>> >><br>
>>> >> ok, delving deeper into python packages versus modules, I think I<br>
>>> >> found the way to import x3d with the current PyPi package after<br>
>>> >> installation:<br>
>>> >><br>
>>> >> $ python<br>
>>> >> Python 3.7.6 | packaged by conda-forge | (default, Jan  7 2020, 22:33:48)<br>
>>> >> [GCC 7.3.0] on linux<br>
>>> >> Type "help", "copyright", "credits" or "license" for more information.<br>
>>> >>>>> import x3d.x3d<br>
>>> >> x3d.py package loaded, have fun with X3D Graphics!<br>
>>> >>>>> help(x3d.x3d)<br>
>>> >><br>
>>> >> Note the repeated x3d.x3d. This refers to the package directory x3d<br>
>>> >> and then to the module file x3d.py . This works with or without the<br>
>>> >> unmodified __init__.py file.<br>
>>> >><br>
>>> >> It looks awkward but may be would you prefer. If it is documented I<br>
>>> >> think it would be ok since the import and from statements allow for<br>
>>> >> more convenient naming later.<br>
>>> >><br>
>>> >> -Andreas<br>
>>> >><br>
>>> >>> On Thu, Apr 23, 2020 at 7:00 PM Andreas Plesch <<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>> wrote:<br>
>>> >>><br>
>>> >>> I tried to investigate this some more with x3d-0.0.27. I think one<br>
>>> >>> consequence of having the same name ('x3d') for the package and for<br>
>>> >>> the source file ('x3d.py') is that if you import x3d by referencing<br>
>>> >>> the source file, the compiled python gets cached and then possibly<br>
>>> >>> reused even after the source is removed and only the package install<br>
>>> >>> should be available.<br>
>>> >>><br>
>>> >>> I would recommend considering renaming the package (say to x3dsai or<br>
>>> >>> X3D) or renaming x3d.py to say x3dclasses.py . Either way, I think,<br>
>>> >>> the 'from x3dclasses import *' line will be still necessary in<br>
>>> >>> __init__.py, for the package. Looking through various packages, this<br>
>>> >>> seems to be not an uncommon pattern for the __init__.py file. This<br>
>>> >>> kind of renaming will also make it easier to find problems with<br>
>>> >>> packaging.<br>
>>> >>><br>
>>> >>> -Andreas<br>
>>> >>><br>
>>> >>>> On Thu, Apr 23, 2020 at 3:43 PM Don Brutzman <<a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a>> wrote:<br>
>>> >>>><br>
>>> >>>> Thanks for detailed explanation.  I'll read up further on this.<br>
>>> >>>><br>
>>> >>>> Loren:  hope you can look at this issue with us also, seems fundamental.<br>
>>> >>>><br>
>>> >>>><br>
>>> >>>> On 4/23/2020 12:24 PM, Andreas Plesch wrote:<br>
>>> >>>>> Hi Don,<br>
>>> >>>>><br>
>>> >>>>> PyPi requirements are met but that does not necessarily mean there is<br>
>>> >>>>> any functionality.<br>
>>> >>>>><br>
>>> >>>>> I think you still need to add this line to the autogeneration of __init__.py<br>
>>> >>>>><br>
>>> >>>>> # import the x3d.py module<br>
>>> >>>>> from x3d import *<br>
>>> >>>>><br>
>>> >>>>> since I did not see it in the file you attached. Without it, the<br>
>>> >>>>> package is installed and can be imported but the imported object does<br>
>>> >>>>> not have any attributes or methods. With it, the x3d module from<br>
>>> >>>>> x3d.py gets imported and then the classes it provides exported as<br>
>>> >>>>> properties of the (new) module provided by the package.<br>
>>> >>>>><br>
>>> >>>>> It is a bit confusing since in the __init__.py file the "x3d" in "from<br>
>>> >>>>> x3d import *" refers to the x3d.py file included in the package while<br>
>>> >>>>> after installation of the x3d PyPi package 'import x3d' in a python<br>
>>> >>>>> script refers to the imported package.<br>
>>> >>>>><br>
>>> >>>>> I am not a PyPi expert and there may be other ways to properly package<br>
>>> >>>>> but adding the above line seemed like a good solution. I think without<br>
>>> >>>>> it the python system is not aware of the x3d.py file and the objects<br>
>>> >>>>> it provides.<br>
>>> >>>>><br>
>>> >>>>> Can you reproduce the error below on a system which does not<br>
>>> >>>>> previously have x3d.py anywhere ?<br>
>>> >>>>><br>
>>> >>>>>>> $ pip install x3d<br>
>>> >>>>>>> Collecting x3d<br>
>>> >>>>>>>     Downloading <a href="https://files.pythonhosted.org/packages/3b/4b/2a7cb8f738e5bf03beb729989fc1c0f52a86ddf61ea3fb38c61c55afd41b/x3d-0.0.26-py3-none-any.whl" rel="noreferrer" target="_blank">https://files.pythonhosted.org/packages/3b/4b/2a7cb8f738e5bf03beb729989fc1c0f52a86ddf61ea3fb38c61c55afd41b/x3d-0.0.26-py3-none-any.whl</a><br>
>>> >>>>>>> (204kB)<br>
>>> >>>>>>>        |████████████████████████████████| 204kB 5.6MB/s<br>
>>> >>>>>>> Installing collected packages: x3d<br>
>>> >>>>>>> Successfully installed x3d-0.0.26<br>
>>> >>>>>>> $ python<br>
>>> >>>>>>> Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21)<br>
>>> >>>>>>> [GCC 7.3.0] :: Anaconda, Inc. on linux<br>
>>> >>>>>>> Type "help", "copyright", "credits" or "license" for more information.<br>
>>> >>>>>>>>>> import x3d<br>
>>> >>>>>>>>>> x3d.X3D()<br>
>>> >>>>>>> Traceback (most recent call last):<br>
>>> >>>>>>>     File "<stdin>", line 1, in <module><br>
>>> >>>>>>> AttributeError: module 'x3d' has no attribute 'X3D'<br>
>>> >>>>><br>
>>> >>>>> -Andreas<br>
>>> >>>>><br>
>>> >>>>> On Thu, Apr 23, 2020 at 2:46 PM Don Brutzman <<a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a>> wrote:<br>
>>> >>>>>><br>
>>> >>>>>> Thanks for your note Andreas.  __init__.py is autogenerated from X3DUOM whenever producing x3d.py package.<br>
>>> >>>>>><br>
>>> >>>>>> Latest is attached, also online at<br>
>>> >>>>>><br>
>>> >>>>>> * <a href="https://sourceforge.net/p/x3d/code/30232/tree/www.web3d.org/x3d/stylesheets/python/x3d/" rel="noreferrer" target="_blank">https://sourceforge.net/p/x3d/code/30232/tree/www.web3d.org/x3d/stylesheets/python/x3d/</a><br>
>>> >>>>>><br>
>>> >>>>>> * <a href="https://sourceforge.net/p/x3d/code/30232/tree/www.web3d.org/x3d/stylesheets/python/x3d/__init__.py" rel="noreferrer" target="_blank">https://sourceforge.net/p/x3d/code/30232/tree/www.web3d.org/x3d/stylesheets/python/x3d/__init__.py</a><br>
>>> >>>>>><br>
>>> >>>>>> Just rechecked, yes 'X3D' is present there on line following # Statements<br>
>>> >>>>>><br>
>>> >>>>>> Perhaps __init__.py isn't included properly?? Everything seems to pass PyPi requirements.<br>
>>> >>>>>><br>
>>> >>>>>> I suspect you have to either use 'X3D' or 'x3d.X3D' according to how you have imported.  All the examples I'm testing/producing avoid the prefix, but I think there is a unit test in there.  Can add more tests, or improve documentation, as you think best.<br>
>>> >>>>>><br>
>>> >>>>>> Shouldn't matter but am using latest Python (currently 3.8.2) in my testing.<br>
>>> >>>>>><br>
>>> >>>>>> So, not seeing something to fix... let's persist please until this is sorted out satisfactorily.<br>
>>> >>>>>><br>
>>> >>>>>><br>
>>> >>>>>><br>
>>> >>>>>> On 4/23/2020 7:00 AM, Andreas Plesch wrote:<br>
>>> >>>>>>> Importing the x3d.py module from the x3d.py file works (if the x3d.py<br>
>>> >>>>>>> file is in te python path).<br>
>>> >>>>>>><br>
>>> >>>>>>> For convenience, there is also x3d python package (pip) which is<br>
>>> >>>>>>> available from the pip registry and can be installed by:<br>
>>> >>>>>>><br>
>>> >>>>>>> pip install x3d<br>
>>> >>>>>>><br>
>>> >>>>>>> to the system python modules.<br>
>>> >>>>>>><br>
>>> >>>>>>> However, this does not quite work:<br>
>>> >>>>>>><br>
>>> >>>>>>> $ pip install x3d<br>
>>> >>>>>>> Collecting x3d<br>
>>> >>>>>>>     Downloading <a href="https://files.pythonhosted.org/packages/3b/4b/2a7cb8f738e5bf03beb729989fc1c0f52a86ddf61ea3fb38c61c55afd41b/x3d-0.0.26-py3-none-any.whl" rel="noreferrer" target="_blank">https://files.pythonhosted.org/packages/3b/4b/2a7cb8f738e5bf03beb729989fc1c0f52a86ddf61ea3fb38c61c55afd41b/x3d-0.0.26-py3-none-any.whl</a><br>
>>> >>>>>>> (204kB)<br>
>>> >>>>>>>        |████████████████████████████████| 204kB 5.6MB/s<br>
>>> >>>>>>> Installing collected packages: x3d<br>
>>> >>>>>>> Successfully installed x3d-0.0.26<br>
>>> >>>>>>> jovyan@jupyter-gesiscss-2dnotebo-2dgetting-5fstarted-2d7wbaxlkp:~$ python<br>
>>> >>>>>>> Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21)<br>
>>> >>>>>>> [GCC 7.3.0] :: Anaconda, Inc. on linux<br>
>>> >>>>>>> Type "help", "copyright", "credits" or "license" for more information.<br>
>>> >>>>>>>>>> import x3d<br>
>>> >>>>>>>>>> x3d.X3D()<br>
>>> >>>>>>> Traceback (most recent call last):<br>
>>> >>>>>>>     File "<stdin>", line 1, in <module><br>
>>> >>>>>>> AttributeError: module 'x3d' has no attribute 'X3D'<br>
>>> >>>>>>><br>
>>> >>>>>>> I think what is needed is to actually import the module in the<br>
>>> >>>>>>> __init__.py file for the pip package.<br>
>>> >>>>>>><br>
>>> >>>>>>> # __init__.py needed for properly configuring pypi distribution of<br>
>>> >>>>>>> x3d.py package<br>
>>> >>>>>>><br>
>>> >>>>>>> # According to _Learning Python_ by Mark Lutz, fifth edition:<br>
>>> >>>>>>> # - Empty __init.py__ no longer required as of Python 3.3.  p. 761<br>
>>> >>>>>>> # - Using __init.py__ is performance advantage for loading, even when<br>
>>> >>>>>>> empty.  p. 761<br>
>>> >>>>>>> # - Using __all__ list to define exported values for import * is<br>
>>> >>>>>>> allowed but not required.  p. 735 and 771-772.<br>
>>> >>>>>>><br>
>>> >>>>>>> # 6.4.1. Importing * From a Package<br>
>>> >>>>>>> # <a href="https://docs.python.org/3/tutorial/modules.html#importing-from-a-package" rel="noreferrer" target="_blank">https://docs.python.org/3/tutorial/modules.html#importing-from-a-package</a><br>
>>> >>>>>>><br>
>>> >>>>>>> # indicates that<br>
>>> >>>>>>> #     from packagename import *<br>
>>> >>>>>>> # "then imports whatever names are defined in the package" and<br>
>>> >>>>>>> # "Although certain modules are designed to export only names that<br>
>>> >>>>>>> follow certain patterns when you use import *,<br>
>>> >>>>>>> #     it is still considered bad practice in production code."<br>
>>> >>>>>>><br>
>>> >>>>>>> # TODO testing continues to fix x3d.py package's class visibility<br>
>>> >>>>>>> satisfactorily for end users<br>
>>> >>>>>>><br>
>>> >>>>>>> ## import the x3d.py module<br>
>>> >>>>>>> from x3d import *<br>
>>> >>>>>>><br>
>>> >>>>>>> __all__ = [<br>
>>> >>>>>>>       # Field types<br>
>>> >>>>>>><br>
>>> >>>>>>> With that change in the __init__.py file, the pip package works for me:<br>
>>> >>>>>>><br>
>>> >>>>>>> $ python<br>
>>> >>>>>>> Python 3.7.6 | packaged by conda-forge | (default, Jan  7 2020, 22:33:48)<br>
>>> >>>>>>> [GCC 7.3.0] on linux<br>
>>> >>>>>>> Type "help", "copyright", "credits" or "license" for more information.<br>
>>> >>>>>>>>>> import x3d<br>
>>> >>>>>>> x3d.py package loaded, have fun with X3D Graphics!<br>
>>> >>>>>>>>>> x3d.X3D<br>
>>> >>>>>>> <class 'x3d.X3D'><br>
>>> >>>>>>>>>> x3d.Box().toXML()<br>
>>> >>>>>>> '<Box/>\n'<br>
>>> >>>>>>>>>><br>
>>> >>>>>>><br>
>>> >>>>>>> Perhaps this change could be applied to the next release of the x3d<br>
>>> >>>>>>> pip package. I could not find the __init__.py file on sourceforge.<br>
>>> >>>>>>><br>
>>> >>>>>>> Cheers,<br>
>>> >>>>>>><br>
>>> >>>>>>> -Andreas<br>
>>> >>>>>>><br>
>>> >>>>>><br>
>>> >>>>>> all the best, Don<br>
>>> >>>>>> --<br>
>>> >>>>>> Don Brutzman  Naval Postgraduate School, Code USW/Br       <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
>>> >>>>>> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149<br>
>>> >>>>>> X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
>>> >>>>><br>
>>> >>>>><br>
>>> >>>>><br>
>>> >>>><br>
>>> >>>> all the best, Don<br>
>>> >>>> --<br>
>>> >>>> Don Brutzman  Naval Postgraduate School, Code USW/Br       <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
>>> >>>> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149<br>
>>> >>>> X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>> --<br>
>>> >>> Andreas Plesch<br>
>>> >>> Waltham, MA 02453<br>
>>> >><br>
>>> >><br>
>>> >><br>
>>> >> --<br>
>>> >> Andreas Plesch<br>
>>> >> Waltham, MA 02453<br>
>>><br>
>>> all the best, Don<br>
>>> --<br>
>>> Don Brutzman  Naval Postgraduate School, Code USW/Br       <a href="mailto:brutzman@nps.edu" target="_blank">brutzman@nps.edu</a><br>
>>> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149<br>
>>> X3D graphics, virtual worlds, navy robotics <a href="http://faculty.nps.edu/brutzman" rel="noreferrer" target="_blank">http://faculty.nps.edu/brutzman</a><br>
>>><br>
>>> _______________________________________________<br>
>>> x3d-public mailing list<br>
>>> <a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
>>> <a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
<br>
<br>
<br>
-- <br>
Andreas Plesch<br>
Waltham, MA 02453<br>
</blockquote></div>