October 28, 2020
I run into a similar issue today:

-- I try to use a library `pyd`, and
-- my local project has a file called "source/util.d"

the dub build error out:

/.dub/packages/pyd-0.13.1/pyd/infrastructure/util/typelist.d(1,1): Error: package name 'util' conflicts with usage as a module name in file source/util.d


I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name.
October 28, 2020
On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote:
> I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name.

Don't write any module with a single name unless you are guaranteed to never import it.

pyd should have called it like `module pyd.util;`

Then you call yours like `module mw.util;`

This makes such conflicts a lot less likely.
October 28, 2020
On Wednesday, 28 October 2020 at 22:52:33 UTC, Adam D. Ruppe wrote:
> On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote:
>> I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name.
>
> Don't write any module with a single name unless you are guaranteed to never import it.
>
> pyd should have called it like `module pyd.util;`
>
> Then you call yours like `module mw.util;`
>
> This makes such conflicts a lot less likely.


Thanks for the tip, Adam.


And I fixed the imports in multiple files with:

```
$ sed -i 's/import util;/import mw.util;/g' *.d
```

Hope this will help if someone else also run into this issue.

October 28, 2020
On Wed, Oct 28, 2020 at 10:52:33PM +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:
> On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote:
> > I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name.
> 
> Don't write any module with a single name unless you are guaranteed to never import it.
> 
> pyd should have called it like `module pyd.util;`
> 
> Then you call yours like `module mw.util;`
> 
> This makes such conflicts a lot less likely.

IMO, 3rd party libraries should always be in their own package namespace. Leave the top-level for user code! Why should a local module 'util' conflict with any dependency?  It should be the library author's job to make sure his code doesn't conflict with the user's!


T

-- 
Recently, our IT department hired a bug-fix engineer. He used to work for Volkswagen.
October 28, 2020
> IMO, 3rd party libraries should always be in their own package namespace. Leave the top-level for user code! Why should a local module 'util' conflict with any dependency?  It should be the library author's job to make sure his code doesn't conflict with the user's!
>

logged:

https://github.com/ariovistus/pyd/issues/140



1 2
Next ›   Last »